Skip to content

Commit a9191b6

Browse files
nicolas-grekasfabpot
authored andcommitted
Bump minimum version of PHP to 8.1
1 parent 410963d commit a9191b6

File tree

7 files changed

+25
-149
lines changed

7 files changed

+25
-149
lines changed

Caster/ReflectionCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static function castReflectionGenerator(\ReflectionGenerator $c, array $a
144144
array_unshift($trace, [
145145
'function' => 'yield',
146146
'file' => $function->getExecutingFile(),
147-
'line' => $function->getExecutingLine() - (int) (\PHP_VERSION_ID < 80100),
147+
'line' => $function->getExecutingLine(),
148148
]);
149149
$trace[] = $frame;
150150
$a[$prefix.'trace'] = new TraceStub($trace, false, 0, -1, -1);

Cloner/VarCloner.php

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -121,46 +121,8 @@ protected function doClone(mixed $var): array
121121
}
122122
$stub = $arrayStub;
123123

124-
if (\PHP_VERSION_ID >= 80100) {
125-
$stub->class = array_is_list($v) ? Stub::ARRAY_INDEXED : Stub::ARRAY_ASSOC;
126-
$a = $v;
127-
break;
128-
}
129-
130-
$stub->class = Stub::ARRAY_INDEXED;
131-
132-
$j = -1;
133-
foreach ($v as $gk => $gv) {
134-
if ($gk !== ++$j) {
135-
$stub->class = Stub::ARRAY_ASSOC;
136-
$a = $v;
137-
$a[$gid] = true;
138-
break;
139-
}
140-
}
141-
142-
// Copies of $GLOBALS have very strange behavior,
143-
// let's detect them with some black magic
144-
if (isset($v[$gid])) {
145-
unset($v[$gid]);
146-
$a = [];
147-
foreach ($v as $gk => &$gv) {
148-
if ($v === $gv && !isset($hardRefs[\ReflectionReference::fromArrayElement($v, $gk)->getId()])) {
149-
unset($v);
150-
$v = new Stub();
151-
$v->value = [$v->cut = \count($gv), Stub::TYPE_ARRAY => 0];
152-
$v->handle = -1;
153-
$gv = &$a[$gk];
154-
$hardRefs[\ReflectionReference::fromArrayElement($a, $gk)->getId()] = &$gv;
155-
$gv = $v;
156-
}
157-
158-
$a[$gk] = &$gv;
159-
}
160-
unset($gv);
161-
} else {
162-
$a = $v;
163-
}
124+
$stub->class = array_is_list($v) ? Stub::ARRAY_INDEXED : Stub::ARRAY_ASSOC;
125+
$a = $v;
164126
break;
165127

166128
case \is_object($v):

Dumper/AbstractDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function setOutput($output)
7373
$output = fopen($output, 'w');
7474
}
7575
$this->outputStream = $output;
76-
$this->lineDumper = [$this, 'echoLine'];
76+
$this->lineDumper = $this->echoLine(...);
7777
}
7878

7979
return $prev;

Tests/Caster/ReflectionCasterTest.php

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public function testReflectionParameter()
153153

154154
public function testReflectionParameterScalar()
155155
{
156-
$f = eval('return function (int $a) {};');
156+
$f = function (int $a) {};
157157
$var = new \ReflectionParameter($f, 0);
158158

159159
$this->assertDumpMatchesFormat(
@@ -170,7 +170,7 @@ public function testReflectionParameterScalar()
170170

171171
public function testReflectionParameterMixed()
172172
{
173-
$f = eval('return function (mixed $a) {};');
173+
$f = function (mixed $a) {};
174174
$var = new \ReflectionParameter($f, 0);
175175

176176
$this->assertDumpMatchesFormat(
@@ -188,7 +188,7 @@ public function testReflectionParameterMixed()
188188

189189
public function testReflectionParameterUnion()
190190
{
191-
$f = eval('return function (int|float $a) {};');
191+
$f = function (int|float $a) {};
192192
$var = new \ReflectionParameter($f, 0);
193193

194194
$this->assertDumpMatchesFormat(
@@ -205,7 +205,7 @@ public function testReflectionParameterUnion()
205205

206206
public function testReflectionParameterNullableUnion()
207207
{
208-
$f = eval('return function (int|float|null $a) {};');
208+
$f = function (int|float|null $a) {};
209209
$var = new \ReflectionParameter($f, 0);
210210

211211
$this->assertDumpMatchesFormat(
@@ -221,12 +221,9 @@ public function testReflectionParameterNullableUnion()
221221
);
222222
}
223223

224-
/**
225-
* @requires PHP 8.1
226-
*/
227224
public function testReflectionParameterIntersection()
228225
{
229-
$f = eval('return function (Traversable&Countable $a) {};');
226+
$f = function (\Traversable&\Countable $a) {};
230227
$var = new \ReflectionParameter($f, 0);
231228

232229
$this->assertDumpMatchesFormat(
@@ -296,9 +293,6 @@ public function testReflectionUnionType()
296293
);
297294
}
298295

299-
/**
300-
* @requires PHP 8.1
301-
*/
302296
public function testReflectionIntersectionType()
303297
{
304298
$var = (new \ReflectionProperty(ReflectionIntersectionTypeFixture::class, 'a'))->getType();
@@ -339,17 +333,16 @@ public function testExtendsReflectionType()
339333

340334
public function testReturnType()
341335
{
342-
$f = eval('return function ():int {};');
343-
$line = __LINE__ - 1;
336+
$f = function ():int {};
344337

345338
$this->assertDumpMatchesFormat(
346339
<<<EOTXT
347340
Closure(): int {
348341
returnType: "int"
349342
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
350343
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
351-
file: "%sReflectionCasterTest.php($line) : eval()'d code"
352-
line: "1 to 1"
344+
file: "%s"
345+
line: "%s"
353346
}
354347
EOTXT
355348
, $f
@@ -358,17 +351,16 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
358351

359352
public function testMixedReturnType()
360353
{
361-
$f = eval('return function (): mixed {};');
362-
$line = __LINE__ - 1;
354+
$f = function (): mixed {};
363355

364356
$this->assertDumpMatchesFormat(
365357
<<<EOTXT
366358
Closure(): mixed {
367359
returnType: "mixed"
368360
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
369361
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
370-
file: "%sReflectionCasterTest.php($line) : eval()'d code"
371-
line: "1 to 1"
362+
file: "%s"
363+
line: "%s"
372364
}
373365
EOTXT
374366
, $f
@@ -377,17 +369,16 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
377369

378370
public function testUnionReturnType()
379371
{
380-
$f = eval('return function (): int|float {};');
381-
$line = __LINE__ - 1;
372+
$f = function (): int|float {};
382373

383374
$this->assertDumpMatchesFormat(
384375
<<<EOTXT
385376
Closure(): int|float {
386377
returnType: "int|float"
387378
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
388379
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
389-
file: "%sReflectionCasterTest.php($line) : eval()'d code"
390-
line: "1 to 1"
380+
file: "%s"
381+
line: "%s"
391382
}
392383
EOTXT
393384
, $f
@@ -396,17 +387,16 @@ class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
396387

397388
public function testNullableUnionReturnType()
398389
{
399-
$f = eval('return function (): int|float|null {};');
400-
$line = __LINE__ - 1;
390+
$f = function (): int|float|null {};
401391

402392
$this->assertDumpMatchesFormat(
403393
<<<EOTXT
404394
Closure(): int|float|null {
405395
returnType: "int|float|null"
406396
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
407397
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
408-
file: "%sReflectionCasterTest.php($line) : eval()'d code"
409-
line: "1 to 1"
398+
file: "%s"
399+
line: "%s"
410400
}
411401
EOTXT
412402
, $f
@@ -485,21 +475,17 @@ public function testGenerator()
485475
$this->assertDumpMatchesFormat($expectedDump, $generator);
486476
}
487477

488-
/**
489-
* @requires PHP 8.1
490-
*/
491478
public function testNewInInitializer()
492479
{
493-
$f = eval('return function ($a = new stdClass()) {};');
494-
$line = __LINE__ - 1;
480+
$f = function ($a = new \stdClass()) {};
495481

496482
$this->assertDumpMatchesFormat(
497483
<<<EOTXT
498484
Closure(\$a = new stdClass) {
499485
class: "Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest"
500486
this: Symfony\Component\VarDumper\Tests\Caster\ReflectionCasterTest { …}
501-
file: "%sReflectionCasterTest.php($line) : eval()'d code"
502-
line: "1 to 1"
487+
file: "%s"
488+
line: "%s"
503489
}
504490
EOTXT
505491
, $f

Tests/Cloner/VarClonerTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,6 @@ public function testPhp74()
571571
$this->assertStringMatchesFormat($expected, print_r($clone, true));
572572
}
573573

574-
/**
575-
* @requires PHP 8.1
576-
*/
577574
public function testPhp81Enums()
578575
{
579576
$data = new Php81Enums();

Tests/Dumper/CliDumperTest.php

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -380,75 +380,6 @@ public function testRefsInProperties()
380380
+"bar": &1 "foo"
381381
}
382382
383-
EOTXT
384-
,
385-
$out
386-
);
387-
}
388-
389-
/**
390-
* @runInSeparateProcess
391-
* @preserveGlobalState disabled
392-
* @requires PHP < 8.1
393-
*/
394-
public function testSpecialVars56()
395-
{
396-
$var = $this->getSpecialVars();
397-
398-
$this->assertDumpEquals(
399-
<<<'EOTXT'
400-
array:3 [
401-
0 => array:1 [
402-
0 => &1 array:1 [
403-
0 => &1 array:1 [&1]
404-
]
405-
]
406-
1 => array:1 [
407-
"GLOBALS" => & array:1 [ …1]
408-
]
409-
2 => &3 array:1 [
410-
"GLOBALS" => &3 array:1 [&3]
411-
]
412-
]
413-
EOTXT
414-
,
415-
$var
416-
);
417-
}
418-
419-
/**
420-
* @runInSeparateProcess
421-
* @preserveGlobalState disabled
422-
* @requires PHP < 8.1
423-
*/
424-
public function testGlobals()
425-
{
426-
$var = $this->getSpecialVars();
427-
unset($var[0]);
428-
$out = '';
429-
430-
$dumper = new CliDumper(function ($line, $depth) use (&$out) {
431-
if ($depth >= 0) {
432-
$out .= str_repeat(' ', $depth).$line."\n";
433-
}
434-
});
435-
$dumper->setColors(false);
436-
$cloner = new VarCloner();
437-
438-
$data = $cloner->cloneVar($var);
439-
$dumper->dump($data);
440-
441-
$this->assertSame(
442-
<<<'EOTXT'
443-
array:2 [
444-
1 => array:1 [
445-
"GLOBALS" => & array:1 [ …1]
446-
]
447-
2 => &2 array:1 [
448-
"GLOBALS" => &2 array:1 [&2]
449-
]
450-
]
451-
452383
EOTXT
453384
,
454385
$out

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
],
1818
"require": {
19-
"php": ">=8.0.2",
19+
"php": ">=8.1",
2020
"symfony/polyfill-mbstring": "~1.0"
2121
},
2222
"require-dev": {

0 commit comments

Comments
 (0)