Skip to content

Commit 38a2b8e

Browse files
committed
ext/phar: Fix tests [WIP]
Need to update ext/phar/tests/file/nophar.phar somehow to remove the deprecation...
1 parent daec4c4 commit 38a2b8e

14 files changed

+46
-80
lines changed

ext/phar/tests/fgc_edgecases.phpt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ file_put_contents($pname . '/foo/hi', '<?php
2828
echo file_get_contents("foo/" . basename(__FILE__));
2929
$context = stream_context_create();
3030
try {
31-
file_get_contents("./hi", 0, $context, 0, -1);
31+
file_get_contents("./hi", false, $context, 0, -1);
3232
} catch (ValueError $exception) {
3333
echo $exception->getMessage() . "\n";
3434
}
3535
echo file_get_contents("fgc_edgecases.txt");
3636
set_include_path("' . addslashes(__DIR__) . '");
3737
echo file_get_contents("fgc_edgecases.txt", true);
38-
echo file_get_contents("./hi", 0, $context);
38+
echo file_get_contents("./hi", false, $context);
3939
echo file_get_contents("../oops");
40-
echo file_get_contents("./hi", 0, $context, 50000);
40+
echo file_get_contents("./hi", false, $context, 50000);
4141
echo file_get_contents("./hi");
42-
echo file_get_contents("./hi", 0, $context, 0, 0);
42+
echo file_get_contents("./hi", false, $context, 0, 0);
4343
?>
4444
');
4545

@@ -56,18 +56,18 @@ blah
5656
echo file_get_contents("foo/" . basename(__FILE__));
5757
$context = stream_context_create();
5858
try {
59-
file_get_contents("./hi", 0, $context, 0, -1);
59+
file_get_contents("./hi", false, $context, 0, -1);
6060
} catch (ValueError $exception) {
6161
echo $exception->getMessage() . "\n";
6262
}
6363
echo file_get_contents("fgc_edgecases.txt");
6464
set_include_path("%stests");
6565
echo file_get_contents("fgc_edgecases.txt", true);
66-
echo file_get_contents("./hi", 0, $context);
66+
echo file_get_contents("./hi", false, $context);
6767
echo file_get_contents("../oops");
68-
echo file_get_contents("./hi", 0, $context, 50000);
68+
echo file_get_contents("./hi", false, $context, 50000);
6969
echo file_get_contents("./hi");
70-
echo file_get_contents("./hi", 0, $context, 0, 0);
70+
echo file_get_contents("./hi", false, $context, 0, 0);
7171
?>
7272
file_get_contents(): Argument #5 ($length) must be greater than or equal to 0
7373
test
@@ -76,18 +76,18 @@ test
7676
echo file_get_contents("foo/" . basename(__FILE__));
7777
$context = stream_context_create();
7878
try {
79-
file_get_contents("./hi", 0, $context, 0, -1);
79+
file_get_contents("./hi", false, $context, 0, -1);
8080
} catch (ValueError $exception) {
8181
echo $exception->getMessage() . "\n";
8282
}
8383
echo file_get_contents("fgc_edgecases.txt");
8484
set_include_path("%stests");
8585
echo file_get_contents("fgc_edgecases.txt", true);
86-
echo file_get_contents("./hi", 0, $context);
86+
echo file_get_contents("./hi", false, $context);
8787
echo file_get_contents("../oops");
88-
echo file_get_contents("./hi", 0, $context, 50000);
88+
echo file_get_contents("./hi", false, $context, 50000);
8989
echo file_get_contents("./hi");
90-
echo file_get_contents("./hi", 0, $context, 0, 0);
90+
echo file_get_contents("./hi", false, $context, 0, 0);
9191
?>
9292

9393
Warning: file_get_contents(phar://%sfgc_edgecases.phar.php/oops): Failed to open stream: phar error: path "oops" is a directory in phar://%sfgc_edgecases.phar.php/foo/hi on line %d
@@ -97,16 +97,16 @@ Warning: file_get_contents(): Failed to seek to position 50000 in the stream in
9797
echo file_get_contents("foo/" . basename(__FILE__));
9898
$context = stream_context_create();
9999
try {
100-
file_get_contents("./hi", 0, $context, 0, -1);
100+
file_get_contents("./hi", false, $context, 0, -1);
101101
} catch (ValueError $exception) {
102102
echo $exception->getMessage() . "\n";
103103
}
104104
echo file_get_contents("fgc_edgecases.txt");
105105
set_include_path("%stests");
106106
echo file_get_contents("fgc_edgecases.txt", true);
107-
echo file_get_contents("./hi", 0, $context);
107+
echo file_get_contents("./hi", false, $context);
108108
echo file_get_contents("../oops");
109-
echo file_get_contents("./hi", 0, $context, 50000);
109+
echo file_get_contents("./hi", false, $context, 50000);
110110
echo file_get_contents("./hi");
111-
echo file_get_contents("./hi", 0, $context, 0, 0);
111+
echo file_get_contents("./hi", false, $context, 0, 0);
112112
?>

ext/phar/tests/mounteddir.phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ $pname = 'phar://' . $fname;
1313

1414
$a = new Phar($fname);
1515
$a['index.php'] = '<?php
16-
Phar::mount("testit", dirname(Phar::running(0)) . "/testit");
17-
echo file_get_contents(Phar::running(1) . "/testit/extfile.php"), "\n";
18-
echo file_get_contents(Phar::running(1) . "/testit/directory"), "\n";
19-
echo file_get_contents(Phar::running(1) . "/testit/existing.txt"), "\n";
16+
Phar::mount("testit", dirname(Phar::running(false)) . "/testit");
17+
echo file_get_contents(Phar::running(true) . "/testit/extfile.php"), "\n";
18+
echo file_get_contents(Phar::running(true) . "/testit/directory"), "\n";
19+
echo file_get_contents(Phar::running(true) . "/testit/existing.txt"), "\n";
2020
include "testit/extfile.php";
2121
include "testit/extfile2.php";
2222
try {
23-
Phar::mount(".phar/stub.php", dirname(Phar::running(0)) . "/testit/extfile.php");
23+
Phar::mount(".phar/stub.php", dirname(Phar::running(false)) . "/testit/extfile.php");
2424
} catch (Exception $e) {
2525
echo $e->getMessage(),"\n";
2626
}

ext/phar/tests/phar_buildfromiterator4.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool) current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/phar_buildfromiterator6.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool)current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/phar_buildfromiterator7.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool) current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/readfile_edgecases.phpt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $context = stream_context_create();
2222
readfile("readfile_edgecases.txt");
2323
set_include_path("' . addslashes(__DIR__) . '");
2424
readfile("readfile_edgecases.txt", true);
25-
readfile("./hi", 0, $context);
25+
readfile("./hi", false, $context);
2626
readfile("../oops");
2727
?>
2828
');
@@ -39,7 +39,7 @@ $context = stream_context_create();
3939
readfile("readfile_edgecases.txt");
4040
set_include_path("%stests");
4141
readfile("readfile_edgecases.txt", true);
42-
readfile("./hi", 0, $context);
42+
readfile("./hi", false, $context);
4343
readfile("../oops");
4444
?>
4545
test
@@ -50,7 +50,7 @@ $context = stream_context_create();
5050
readfile("readfile_edgecases.txt");
5151
set_include_path("%stests");
5252
readfile("readfile_edgecases.txt", true);
53-
readfile("./hi", 0, $context);
53+
readfile("./hi", false, $context);
5454
readfile("../oops");
5555
?>
5656

ext/phar/tests/tar/phar_buildfromiterator4.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool)current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/tar/phar_buildfromiterator6.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool)current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/tar/phar_buildfromiterator7.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool)current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/withphar.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ phar
66
<?php
77
include __DIR__ . '/files/nophar.phar';
88
?>
9-
--EXPECT--
9+
--EXPECTF--
10+
Deprecated: class_exists(): Passing int to parameter #2 ($autoload) of type bool is deprecated in %s/files/nophar.phar on line 5
1011
in b
1112
<?php include "b/c.php";
1213
in d

ext/phar/tests/withphar_web.phpt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ PATH_INFO=/web.php
1212
files/nophar.phar
1313
--EXPECTHEADERS--
1414
Content-type: text/html; charset=UTF-8
15-
--EXPECT--
15+
--EXPECTF--
16+
Deprecated: class_exists(): Passing int to parameter #2 ($autoload) of type bool is deprecated in %s on line %d
1617
web

ext/phar/tests/zip/phar_buildfromiterator4.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool)current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/zip/phar_buildfromiterator6.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool)current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

ext/phar/tests/zip/phar_buildfromiterator7.phpt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ phar.readonly=0
99
<?php
1010
class myIterator implements Iterator
1111
{
12-
var $a;
13-
function __construct(array $a)
14-
{
15-
$this->a = $a;
16-
}
12+
function __construct(public array $a) {}
1713
function next(): void {
1814
echo "next\n";
1915
next($this->a);
@@ -28,7 +24,7 @@ class myIterator implements Iterator
2824
}
2925
function valid(): bool {
3026
echo "valid\n";
31-
return current($this->a);
27+
return (bool)current($this->a);
3228
}
3329
function rewind(): void {
3430
echo "rewind\n";

0 commit comments

Comments
 (0)