Skip to content

Commit

Permalink
Merge branch '6.2' into 6.3
Browse files Browse the repository at this point in the history
* 6.2:
  [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
  • Loading branch information
nicolas-grekas committed Jul 13, 2023
2 parents fafab0d + 6fd823b commit f504692
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Caster/SplCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ private static function castSplArray(\ArrayObject|\ArrayIterator $c, array $a, S
$a = Caster::castObject($c, $c::class, method_exists($c, '__debugInfo'), $stub->class);
$c->setFlags($flags);
}

unset($a["\0ArrayObject\0storage"], $a["\0ArrayIterator\0storage"]);

$a += [
$prefix.'storage' => $c->getArrayCopy(),
$prefix.'flag::STD_PROP_LIST' => (bool) ($flags & \ArrayObject::STD_PROP_LIST),
$prefix.'flag::ARRAY_AS_PROPS' => (bool) ($flags & \ArrayObject::ARRAY_AS_PROPS),
];
Expand Down
2 changes: 1 addition & 1 deletion Dumper/ContextProvider/SourceContextProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function getContext(): ?array

$file = $trace[1]['file'];
$line = $trace[1]['line'];
$name = false;
$name = '-' === $file || 'Standard input code' === $file ? 'Standard input code' : false;
$fileExcerpt = false;

for ($i = 2; $i < $this->limit; ++$i) {
Expand Down
4 changes: 2 additions & 2 deletions Tests/Caster/SplCasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class([123]) extends \ArrayObject {};
$expected = <<<EOTXT
ArrayObject@anonymous {
+"foo": 234
-storage: array:1 [
storage: array:1 [
0 => 123
]
flag::STD_PROP_LIST: false
Expand All @@ -192,7 +192,7 @@ public function testArrayIterator()
$expected = <<<EOTXT
Symfony\Component\VarDumper\Tests\Caster\MyArrayIterator {
-foo: 123
-storage: array:1 [
storage: array:1 [
0 => 234
]
flag::STD_PROP_LIST: false
Expand Down
69 changes: 69 additions & 0 deletions Tests/Dumper/functions/dump_data_collector_with_spl_array.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
--TEST--
Test integration with Symfony's DumpDataCollector
--FILE--
<?php
putenv('NO_COLOR=1');

$vendor = __DIR__;
while (!file_exists($vendor.'/vendor')) {
$vendor = dirname($vendor);
}
require $vendor.'/vendor/autoload.php';

use Symfony\Component\HttpKernel\DataCollector\DumpDataCollector;
use Symfony\Component\VarDumper\Cloner\VarCloner;
use Symfony\Component\VarDumper\VarDumper;

VarDumper::setHandler(function ($var, string $label = null) {
$dumper = new DumpDataCollector();
$cloner = new VarCloner();
$handler = function ($var, string $label = null) use ($dumper, $cloner) {
$var = $cloner->cloneVar($var);
if (null !== $label) {
$var = $var->withContext(['label' => $label]);
}

$dumper->dump($var);
};
VarDumper::setHandler($handler);
$handler($var, $label);
});

$arrayObject = new \ArrayObject();
dump($arrayObject);
$arrayObject['X'] = 'A';
$arrayObject['Y'] = new \ArrayObject(['type' => 'object']);
$arrayObject['Y']['Z'] = 'B';

$arrayIterator = new \ArrayIterator();
dump($arrayIterator);
$arrayIterator['X'] = 'A';
$arrayIterator['Y'] = new \ArrayIterator(['type' => 'object']);
$arrayIterator['Y']['Z'] = 'B';

$recursiveArrayIterator = new \RecursiveArrayIterator();
dump($recursiveArrayIterator);
$recursiveArrayIterator['X'] = 'A';
$recursiveArrayIterator['Y'] = new \RecursiveArrayIterator(['type' => 'object']);
$recursiveArrayIterator['Y']['Z'] = 'B';

--EXPECTF--
%s on line %d:
ArrayObject {#%d
storage: []
flag::STD_PROP_LIST: false
flag::ARRAY_AS_PROPS: false
iteratorClass: "ArrayIterator"
}
%s on line %d:
ArrayIterator {#%d
storage: []
flag::STD_PROP_LIST: false
flag::ARRAY_AS_PROPS: false
}
%s on line %d:
RecursiveArrayIterator {#%d
storage: []
flag::STD_PROP_LIST: false
flag::ARRAY_AS_PROPS: false
}
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"require-dev": {
"ext-iconv": "*",
"symfony/console": "^5.4|^6.0",
"symfony/http-kernel": "^5.4|^6.0",
"symfony/process": "^5.4|^6.0",
"symfony/uid": "^5.4|^6.0",
"twig/twig": "^2.13|^3.0.4"
Expand Down

0 comments on commit f504692

Please sign in to comment.