Skip to content

Commit 399d6c1

Browse files
Merge branch '5.0' into 5.1
* 5.0: (28 commits) [Cache] $lifetime cannot be null [Serializer] minor cleanup fix merge Run PHP 8 as 7.4.99 Remove calls to deprecated ReflectionParameter::getClass(). [VarDumper] fix PHP 8 support Add php 8 to travis. [Cache] Accessing undefined constants raises an Error in php8 [Cache] allow DBAL v3 Skip Doctrine DBAL on php 8 until we have a compatible version. [DomCrawler] Catch expected ValueError. Made method signatures compatible with their corresponding traits. [ErrorHandler] Apply php8 fixes from Debug component. [DomCrawler] Catch expected ValueError. [Validator] Catch expected ValueError. [VarDumper] ReflectionFunction::isDisabled() is deprecated. [BrowserKit] Raw body with custom Content-Type header [PropertyAccess] Parse php 8 TypeErrors correctly. [Intl] Fix call to ReflectionProperty::getValue() for static properties. [HttpKernel] Prevent calling method_exists() with non-string values. ...
2 parents a806800 + 25095a0 commit 399d6c1

File tree

8 files changed

+28
-22
lines changed

8 files changed

+28
-22
lines changed

Caster/Caster.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ public static function castObject(object $obj, string $class, bool $hasDebugInfo
9494
if ($hasDebugInfo && \is_array($debugInfo)) {
9595
foreach ($debugInfo as $k => $v) {
9696
if (!isset($k[0]) || "\0" !== $k[0]) {
97+
if (\array_key_exists(self::PREFIX_DYNAMIC.$k, $a)) {
98+
continue;
99+
}
97100
$k = self::PREFIX_VIRTUAL.$k;
98101
}
99102

Caster/ReflectionCaster.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ private static function addExtra(array &$a, \Reflector $c)
376376
private static function addMap(array &$a, \Reflector $c, array $map, string $prefix = Caster::PREFIX_VIRTUAL)
377377
{
378378
foreach ($map as $k => $m) {
379+
if (\PHP_VERSION_ID >= 80000 && 'isDisabled' === $k) {
380+
continue;
381+
}
382+
379383
if (method_exists($c, $m) && false !== ($m = $c->$m()) && null !== $m) {
380384
$a[$prefix.$k] = $m instanceof \Reflector ? $m->name : $m;
381385
}

Caster/SplCaster.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,15 +162,6 @@ public static function castFileObject(\SplFileObject $c, array $a, Stub $stub, b
162162
return $a;
163163
}
164164

165-
public static function castFixedArray(\SplFixedArray $c, array $a, Stub $stub, bool $isNested)
166-
{
167-
$a += [
168-
Caster::PREFIX_VIRTUAL.'storage' => $c->toArray(),
169-
];
170-
171-
return $a;
172-
}
173-
174165
public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $stub, bool $isNested)
175166
{
176167
$storage = [];
@@ -209,22 +200,23 @@ public static function castWeakReference(\WeakReference $c, array $a, Stub $stub
209200
private static function castSplArray($c, array $a, Stub $stub, bool $isNested): array
210201
{
211202
$prefix = Caster::PREFIX_VIRTUAL;
212-
$class = $stub->class;
213203
$flags = $c->getFlags();
214204

215205
if (!($flags & \ArrayObject::STD_PROP_LIST)) {
216206
$c->setFlags(\ArrayObject::STD_PROP_LIST);
217-
$a = Caster::castObject($c, $class);
207+
$a = Caster::castObject($c, \get_class($c), method_exists($c, '__debugInfo'), $stub->class);
218208
$c->setFlags($flags);
219209
}
210+
if (\PHP_VERSION_ID < 70400) {
211+
$a[$prefix.'storage'] = $c->getArrayCopy();
212+
}
220213
$a += [
221214
$prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
222215
$prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
223216
];
224217
if ($c instanceof \ArrayObject) {
225218
$a[$prefix.'iteratorClass'] = new ClassStub($c->getIteratorClass());
226219
}
227-
$a[$prefix.'storage'] = $c->getArrayCopy();
228220

229221
return $a;
230222
}

Cloner/AbstractCloner.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ abstract class AbstractCloner implements ClonerInterface
115115
'SplDoublyLinkedList' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castDoublyLinkedList'],
116116
'SplFileInfo' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileInfo'],
117117
'SplFileObject' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFileObject'],
118-
'SplFixedArray' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castFixedArray'],
119118
'SplHeap' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'],
120119
'SplObjectStorage' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castObjectStorage'],
121120
'SplPriorityQueue' => ['Symfony\Component\VarDumper\Caster\SplCaster', 'castHeap'],

Tests/Caster/PdoCasterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public function testCastPdo()
3030
{
3131
$pdo = new \PDO('sqlite::memory:');
3232
$pdo->setAttribute(\PDO::ATTR_STATEMENT_CLASS, ['PDOStatement', [$pdo]]);
33+
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
3334

3435
$cast = PdoCaster::castPdo($pdo, [], new Stub(), false);
3536

@@ -45,7 +46,7 @@ public function testCastPdo()
4546
"\x00~\x00inTransaction" => false
4647
"\x00~\x00attributes" => array:9 [
4748
"CASE" => NATURAL
48-
"ERRMODE" => SILENT
49+
"ERRMODE" => EXCEPTION
4950
"PERSISTENT" => false
5051
"DRIVER_NAME" => "sqlite"
5152
"ORACLE_NULLS" => NATURAL

Tests/Caster/ReflectionCasterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public function testReflectionCaster()
4949
%A]
5050
methods: array:%d [
5151
%A
52-
"export" => ReflectionMethod {
53-
+name: "export"
52+
"__construct" => ReflectionMethod {
53+
+name: "__construct"
5454
+class: "ReflectionClass"
5555
%A parameters: {
5656
$%s: ReflectionParameter {

Tests/Caster/SplCasterTest.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,17 @@ public function testCastArrayObject()
172172
$expected = <<<EOTXT
173173
ArrayObject {
174174
+"foo": 234
175+
-storage: array:1 [
176+
0 => 123
177+
]
175178
flag::STD_PROP_LIST: false
176179
flag::ARRAY_AS_PROPS: false
177180
iteratorClass: "ArrayIterator"
178-
storage: array:1 [
179-
0 => 123
180-
]
181181
}
182182
EOTXT;
183+
if (\PHP_VERSION_ID < 70400) {
184+
$expected = str_replace('-storage:', 'storage:', $expected);
185+
}
183186
$this->assertDumpEquals($expected, $var);
184187
}
185188

@@ -190,13 +193,16 @@ public function testArrayIterator()
190193
$expected = <<<EOTXT
191194
Symfony\Component\VarDumper\Tests\Caster\MyArrayIterator {
192195
-foo: 123
193-
flag::STD_PROP_LIST: false
194-
flag::ARRAY_AS_PROPS: false
195-
storage: array:1 [
196+
-storage: array:1 [
196197
0 => 234
197198
]
199+
flag::STD_PROP_LIST: false
200+
flag::ARRAY_AS_PROPS: false
198201
}
199202
EOTXT;
203+
if (\PHP_VERSION_ID < 70400) {
204+
$expected = str_replace('-storage:', 'storage:', $expected);
205+
}
200206
$this->assertDumpEquals($expected, $var);
201207
}
202208

Tests/Dumper/CliDumperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ public function provideDumpWithCommaFlagTests()
199199

200200
/**
201201
* @requires extension xml
202+
* @requires PHP < 8.0
202203
*/
203204
public function testXmlResource()
204205
{

0 commit comments

Comments
 (0)