Skip to content

Commit 6fd823b

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Security] Allow custom scheme to be used as redirection URIs [Validator] Do not mock metadata factory on debug command tests [HttpKernel][WebProfilerBundle] Fix search feature update Intl component to take into account B-variant when converting Alpha3 to Alpha2. fixing issue with Darwin. [VarDumper] Fix dumping `ArrayObject` with `DumpDataCollector` [VarDumper] Add tests to demonstrate a bug when dumping ArrayObject with full stack fmk [DebugBundle][FrameworkBundle] Fix using the framework without the Console component [FrameworkBundle] Add missing monolog channel tag to the `messenger:failed:retry` command fetch all known ChoiceType values at once [RateLimiter] fix incorrect retryAfter of FixedWindow Fix Finder phpdoc
2 parents 5774ae9 + e706c99 commit 6fd823b

File tree

6 files changed

+78
-3
lines changed

6 files changed

+78
-3
lines changed

Caster/SplCaster.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,11 @@ private static function castSplArray(\ArrayObject|\ArrayIterator $c, array $a, S
221221
$a = Caster::castObject($c, $c::class, method_exists($c, '__debugInfo'), $stub->class);
222222
$c->setFlags($flags);
223223
}
224+
225+
unset($a["\0ArrayObject\0storage"], $a["\0ArrayIterator\0storage"]);
226+
224227
$a += [
228+
$prefix.'storage' => $c->getArrayCopy(),
225229
$prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
226230
$prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
227231
];

Dumper/ContextProvider/SourceContextProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getContext(): ?array
4444

4545
$file = $trace[1]['file'];
4646
$line = $trace[1]['line'];
47-
$name = false;
47+
$name = '-' === $file || 'Standard input code' === $file ? 'Standard input code' : false;
4848
$fileExcerpt = false;
4949

5050
for ($i = 2; $i < $this->limit; ++$i) {

Tests/Caster/SplCasterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class([123]) extends \ArrayObject {};
174174
$expected = <<<EOTXT
175175
ArrayObject@anonymous {
176176
+"foo": 234
177-
-storage: array:1 [
177+
storage: array:1 [
178178
0 => 123
179179
]
180180
flag::STD_PROP_LIST: false
@@ -192,7 +192,7 @@ public function testArrayIterator()
192192
$expected = <<<EOTXT
193193
Symfony\Component\VarDumper\Tests\Caster\MyArrayIterator {
194194
-foo: 123
195-
-storage: array:1 [
195+
storage: array:1 [
196196
0 => 234
197197
]
198198
flag::STD_PROP_LIST: false
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
--TEST--
2+
Test integration with Symfony's DumpDataCollector
3+
--FILE--
4+
<?php
5+
putenv('NO_COLOR=1');
6+
7+
$vendor = __DIR__;
8+
while (!file_exists($vendor.'/vendor')) {
9+
$vendor = dirname($vendor);
10+
}
11+
require $vendor.'/vendor/autoload.php';
12+
13+
use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
14+
use Symfony\Component\VarDumper\Cloner\VarCloner;
15+
use Symfony\Component\VarDumper\VarDumper;
16+
17+
VarDumper::setHandler(function ($var, string $label = null) {
18+
$dumper = new DumpDataCollector();
19+
$cloner = new VarCloner();
20+
$handler = function ($var, string $label = null) use ($dumper, $cloner) {
21+
$var = $cloner->cloneVar($var);
22+
if (null !== $label) {
23+
$var = $var->withContext(['label' => $label]);
24+
}
25+
26+
$dumper->dump($var);
27+
};
28+
VarDumper::setHandler($handler);
29+
$handler($var, $label);
30+
});
31+
32+
$arrayObject = new \ArrayObject();
33+
dump($arrayObject);
34+
$arrayObject['X'] = 'A';
35+
$arrayObject['Y'] = new \ArrayObject(['type' => 'object']);
36+
$arrayObject['Y']['Z'] = 'B';
37+
38+
$arrayIterator = new \ArrayIterator();
39+
dump($arrayIterator);
40+
$arrayIterator['X'] = 'A';
41+
$arrayIterator['Y'] = new \ArrayIterator(['type' => 'object']);
42+
$arrayIterator['Y']['Z'] = 'B';
43+
44+
$recursiveArrayIterator = new \RecursiveArrayIterator();
45+
dump($recursiveArrayIterator);
46+
$recursiveArrayIterator['X'] = 'A';
47+
$recursiveArrayIterator['Y'] = new \RecursiveArrayIterator(['type' => 'object']);
48+
$recursiveArrayIterator['Y']['Z'] = 'B';
49+
50+
--EXPECTF--
51+
%s on line %d:
52+
ArrayObject {#%d
53+
storage: []
54+
flag::STD_PROP_LIST: false
55+
flag::ARRAY_AS_PROPS: false
56+
iteratorClass: "ArrayIterator"
57+
}
58+
%s on line %d:
59+
ArrayIterator {#%d
60+
storage: []
61+
flag::STD_PROP_LIST: false
62+
flag::ARRAY_AS_PROPS: false
63+
}
64+
%s on line %d:
65+
RecursiveArrayIterator {#%d
66+
storage: []
67+
flag::STD_PROP_LIST: false
68+
flag::ARRAY_AS_PROPS: false
69+
}

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"require-dev": {
2323
"ext-iconv": "*",
2424
"symfony/console": "^5.4|^6.0",
25+
"symfony/http-kernel": "^5.4|^6.0",
2526
"symfony/process": "^5.4|^6.0",
2627
"symfony/uid": "^5.4|^6.0",
2728
"twig/twig": "^2.13|^3.0.4"

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<testsuites>
1818
<testsuite name="Symfony VarDumper Component Test Suite">
1919
<directory>./Tests/</directory>
20+
<directory suffix=".phpt">./Tests/Dumper/functions/</directory>
2021
</testsuite>
2122
</testsuites>
2223

0 commit comments

Comments
 (0)