From 147e212346a2593e39fc71622502335fb3d0ed1d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 24 Jan 2023 15:02:24 +0100 Subject: [PATCH 01/11] Update license years (last time) --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 72412a62..29f72d5e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2023 Fabien Potencier +Copyright (c) 2014-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From d1347f047357ff91b8e93c9d3b57d92c554daed0 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 7 Feb 2023 16:02:15 +0100 Subject: [PATCH 02/11] [VarExporter] Fix lazy-proxying readonly classes on PHP 8.3 --- Caster/SymfonyCaster.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Caster/SymfonyCaster.php b/Caster/SymfonyCaster.php index f2ee0d62..3b13666c 100644 --- a/Caster/SymfonyCaster.php +++ b/Caster/SymfonyCaster.php @@ -76,12 +76,21 @@ public static function castLazyObjectState($state, array $a, Stub $stub, bool $i $stub->cut += \count($a) - 1; - return ['status' => new ConstStub(match ($a['status']) { + $instance = $a['realInstance'] ?? null; + + $a = ['status' => new ConstStub(match ($a['status']) { LazyObjectState::STATUS_INITIALIZED_FULL => 'INITIALIZED_FULL', LazyObjectState::STATUS_INITIALIZED_PARTIAL => 'INITIALIZED_PARTIAL', LazyObjectState::STATUS_UNINITIALIZED_FULL => 'UNINITIALIZED_FULL', LazyObjectState::STATUS_UNINITIALIZED_PARTIAL => 'UNINITIALIZED_PARTIAL', }, $a['status'])]; + + if ($instance) { + $a['realInstance'] = $instance; + --$stub->cut; + } + + return $a; } public static function castUuid(Uuid $uuid, array $a, Stub $stub, bool $isNested) From 3c2942a403bf1950b86ceab0bcd56457b9bb2bb9 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 14 Dec 2022 15:42:16 +0100 Subject: [PATCH 03/11] Migrate to `static` data providers using `rector/rector` --- Tests/Caster/CasterTest.php | 2 +- Tests/Caster/DateCasterTest.php | 8 ++++---- Tests/Caster/SplCasterTest.php | 4 ++-- Tests/Caster/XmlReaderCasterTest.php | 2 +- Tests/Command/Descriptor/CliDescriptorTest.php | 2 +- Tests/Command/Descriptor/HtmlDescriptorTest.php | 2 +- Tests/Command/ServerDumpCommandTest.php | 2 +- Tests/Dumper/CliDumperTest.php | 4 ++-- Tests/Dumper/HtmlDumperTest.php | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Tests/Caster/CasterTest.php b/Tests/Caster/CasterTest.php index 66cd5fbe..55eb4040 100644 --- a/Tests/Caster/CasterTest.php +++ b/Tests/Caster/CasterTest.php @@ -46,7 +46,7 @@ public function testFilter($filter, $expectedDiff, $listedProperties = null) $this->assertSame($expectedDiff, array_diff_assoc(self::$referenceArray, $filteredArray)); } - public function provideFilter() + public static function provideFilter() { return [ [ diff --git a/Tests/Caster/DateCasterTest.php b/Tests/Caster/DateCasterTest.php index 335aa7dd..40835671 100644 --- a/Tests/Caster/DateCasterTest.php +++ b/Tests/Caster/DateCasterTest.php @@ -74,7 +74,7 @@ public function testCastDateTime($time, $timezone, $xDate, $xTimestamp, $xInfos) $this->assertDumpMatchesFormat($xDump, $cast["\0~\0date"]); } - public function provideDateTimes() + public static function provideDateTimes() { return [ ['2017-04-30 00:00:00.000000', 'Europe/Zurich', '2017-04-30 00:00:00.0 Europe/Zurich (+02:00)', 1493503200, 'Sunday, April 30, 2017%Afrom now%ADST On'], @@ -194,7 +194,7 @@ public function testCastInterval($intervalSpec, $ms, $invert, $xInterval, $xSeco $this->assertDumpMatchesFormat($xDump, $cast["\0~\0interval"]); } - public function provideIntervals() + public static function provideIntervals() { return [ ['PT0S', 0, 0, '0s', '0s'], @@ -293,7 +293,7 @@ public function testCastTimeZone($timezone, $xTimezone, $xRegion) $this->assertDumpMatchesFormat($xDump, $cast["\0~\0timezone"]); } - public function provideTimeZones() + public static function provideTimeZones() { $xRegion = \extension_loaded('intl') ? '%s' : ''; @@ -370,7 +370,7 @@ public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDa $this->assertDumpMatchesFormat($xDump, $cast["\0~\0period"]); } - public function providePeriods() + public static function providePeriods() { $periods = [ ['2017-01-01', 'P1D', '2017-01-03', 0, 'every + 1d, from [2017-01-01 00:00:00.0 to 2017-01-03 00:00:00.0[', '1) 2017-01-01%a2) 2017-01-02'], diff --git a/Tests/Caster/SplCasterTest.php b/Tests/Caster/SplCasterTest.php index 5bba4e55..4093471f 100644 --- a/Tests/Caster/SplCasterTest.php +++ b/Tests/Caster/SplCasterTest.php @@ -21,7 +21,7 @@ class SplCasterTest extends TestCase { use VarDumperTestTrait; - public function getCastFileInfoTests() + public static function getCastFileInfoTests() { return [ [__FILE__, <<<'EOTXT' @@ -135,7 +135,7 @@ public function testCastSplDoublyLinkedList($modeValue, $modeDump) $this->assertDumpMatchesFormat($dump, $var); } - public function provideCastSplDoublyLinkedList() + public static function provideCastSplDoublyLinkedList() { return [ [\SplDoublyLinkedList::IT_MODE_FIFO, 'IT_MODE_FIFO | IT_MODE_KEEP'], diff --git a/Tests/Caster/XmlReaderCasterTest.php b/Tests/Caster/XmlReaderCasterTest.php index cde1d7e9..78416f30 100644 --- a/Tests/Caster/XmlReaderCasterTest.php +++ b/Tests/Caster/XmlReaderCasterTest.php @@ -64,7 +64,7 @@ public function testNodes($seek, $expectedDump) $this->assertDumpMatchesFormat($expectedDump, $this->reader); } - public function provideNodes() + public static function provideNodes() { return [ [0, <<<'EODUMP' diff --git a/Tests/Command/Descriptor/CliDescriptorTest.php b/Tests/Command/Descriptor/CliDescriptorTest.php index 56fb2187..5941508a 100644 --- a/Tests/Command/Descriptor/CliDescriptorTest.php +++ b/Tests/Command/Descriptor/CliDescriptorTest.php @@ -54,7 +54,7 @@ public function testDescribe(array $context, string $expectedOutput, bool $decor $this->assertStringMatchesFormat(trim($expectedOutput), str_replace(\PHP_EOL, "\n", trim($output->fetch()))); } - public function provideContext() + public static function provideContext() { yield 'source' => [ [ diff --git a/Tests/Command/Descriptor/HtmlDescriptorTest.php b/Tests/Command/Descriptor/HtmlDescriptorTest.php index 426e99d3..09acf149 100644 --- a/Tests/Command/Descriptor/HtmlDescriptorTest.php +++ b/Tests/Command/Descriptor/HtmlDescriptorTest.php @@ -63,7 +63,7 @@ public function testDescribe(array $context, string $expectedOutput) $this->assertStringMatchesFormat(trim($expectedOutput), trim(preg_replace('@@s', '', $output->fetch()))); } - public function provideContext() + public static function provideContext() { yield 'source' => [ [ diff --git a/Tests/Command/ServerDumpCommandTest.php b/Tests/Command/ServerDumpCommandTest.php index fe1a9b05..d593608d 100644 --- a/Tests/Command/ServerDumpCommandTest.php +++ b/Tests/Command/ServerDumpCommandTest.php @@ -32,7 +32,7 @@ public function testComplete(array $input, array $expectedSuggestions) $this->assertSame($expectedSuggestions, $tester->complete($input)); } - public function provideCompletionSuggestions() + public static function provideCompletionSuggestions() { yield 'option --format' => [ ['--format', ''], diff --git a/Tests/Dumper/CliDumperTest.php b/Tests/Dumper/CliDumperTest.php index 92b7119a..d94b15ff 100644 --- a/Tests/Dumper/CliDumperTest.php +++ b/Tests/Dumper/CliDumperTest.php @@ -157,7 +157,7 @@ public function testDumpWithCommaFlagsAndExceptionCodeExcerpt() , $dump); } - public function provideDumpWithCommaFlagTests() + public static function provideDumpWithCommaFlagTests() { $expected = <<<'EOTXT' array:3 [ @@ -492,7 +492,7 @@ public function testIncompleteClass() ); } - public function provideDumpArrayWithColor() + public static function provideDumpArrayWithColor() { yield [ ['foo' => 'bar'], diff --git a/Tests/Dumper/HtmlDumperTest.php b/Tests/Dumper/HtmlDumperTest.php index 1fd98640..8c9592e4 100644 --- a/Tests/Dumper/HtmlDumperTest.php +++ b/Tests/Dumper/HtmlDumperTest.php @@ -180,7 +180,7 @@ public function testDumpString($var, $needle) $this->assertStringContainsString($needle, $out); } - public function varToDumpProvider() + public static function varToDumpProvider() { return [ [['dummy' => new ImgStub('dummy', 'img/png', '100em')], ''], From dab98eb8ae318af32ca1e6470acedbe37bc3b56e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 14 Feb 2023 09:53:37 +0100 Subject: [PATCH 04/11] Fix merge --- Tests/Caster/FFICasterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Caster/FFICasterTest.php b/Tests/Caster/FFICasterTest.php index ac4aa93d..32fea5fc 100644 --- a/Tests/Caster/FFICasterTest.php +++ b/Tests/Caster/FFICasterTest.php @@ -90,7 +90,7 @@ public function testCastNamedEnum() PHP, \FFI::new('enum Example { a, b }')); } - public function scalarsDataProvider(): array + public static function scalarsDataProvider(): array { return [ 'int8_t' => ['int8_t', '0', 1, 1], From 794b643de837bbb5e61524ed2db60640db76efca Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 16 Feb 2023 10:33:00 +0100 Subject: [PATCH 05/11] CS fix --- Tests/Caster/MysqliCasterTest.php | 1 + Tests/Caster/RdKafkaCasterTest.php | 1 + Tests/Caster/RedisCasterTest.php | 2 ++ 3 files changed, 4 insertions(+) diff --git a/Tests/Caster/MysqliCasterTest.php b/Tests/Caster/MysqliCasterTest.php index e05ae41b..983f541a 100644 --- a/Tests/Caster/MysqliCasterTest.php +++ b/Tests/Caster/MysqliCasterTest.php @@ -16,6 +16,7 @@ /** * @requires extension mysqli + * * @group integration */ class MysqliCasterTest extends TestCase diff --git a/Tests/Caster/RdKafkaCasterTest.php b/Tests/Caster/RdKafkaCasterTest.php index 4cc836f2..65e8ec3b 100644 --- a/Tests/Caster/RdKafkaCasterTest.php +++ b/Tests/Caster/RdKafkaCasterTest.php @@ -20,6 +20,7 @@ /** * @requires extension rdkafka + * * @group integration */ class RdKafkaCasterTest extends TestCase diff --git a/Tests/Caster/RedisCasterTest.php b/Tests/Caster/RedisCasterTest.php index 058b95d0..566de12a 100644 --- a/Tests/Caster/RedisCasterTest.php +++ b/Tests/Caster/RedisCasterTest.php @@ -16,7 +16,9 @@ /** * @author Nicolas Grekas + * * @requires extension redis + * * @group integration */ class RedisCasterTest extends TestCase From a110fcb0d42df7e4589eacf9609e0d412613c08a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 21 Feb 2023 17:34:40 +0100 Subject: [PATCH 06/11] Fix phpdocs in components --- Caster/Caster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Caster/Caster.php b/Caster/Caster.php index 890f5310..81bfd54e 100644 --- a/Caster/Caster.php +++ b/Caster/Caster.php @@ -115,7 +115,7 @@ public static function castObject(object $obj, string $class, bool $hasDebugInfo * @param array $a The array containing the properties to filter * @param int $filter A bit field of Caster::EXCLUDE_* constants specifying which properties to filter out * @param string[] $listedProperties List of properties to exclude when Caster::EXCLUDE_VERBOSE is set, and to preserve when Caster::EXCLUDE_NOT_IMPORTANT is set - * @param int &$count Set to the number of removed properties + * @param int|null &$count Set to the number of removed properties */ public static function filter(array $a, int $filter, array $listedProperties = [], ?int &$count = 0): array { From 6c5ac3a1be8b849d59a1a77877ee110e1b55eb74 Mon Sep 17 00:00:00 2001 From: Kamil Piwowarski <9luty1992@gmail.com> Date: Wed, 8 Feb 2023 10:08:47 +0100 Subject: [PATCH 07/11] [VarDumper] Fix error when reflected class has default Enum parameter in constructor --- Caster/ReflectionCaster.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Caster/ReflectionCaster.php b/Caster/ReflectionCaster.php index 5c644053..ef6a85ef 100644 --- a/Caster/ReflectionCaster.php +++ b/Caster/ReflectionCaster.php @@ -292,7 +292,7 @@ public static function castParameter(\ReflectionParameter $c, array $a, Stub $st if ($c->isOptional()) { try { $a[$prefix.'default'] = $v = $c->getDefaultValue(); - if ($c->isDefaultValueConstant()) { + if ($c->isDefaultValueConstant() && !\is_object($v)) { $a[$prefix.'default'] = new ConstStub($c->getDefaultValueConstantName(), $v); } if (null === $v) { From 2901ca1270df16c599c8ec1862aa7129d99473ec Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Sun, 5 Mar 2023 18:17:42 +0100 Subject: [PATCH 08/11] [VarDumper] Add a bit of test coverage --- Tests/Caster/DoctrineCasterTest.php | 45 ++++++++++ Tests/Caster/ExceptionCasterTest.php | 89 +++++++++++++++++++ Tests/Caster/FiberCasterTest.php | 85 ++++++++++++++++++ .../RequestContextProviderTest.php | 49 ++++++++++ 4 files changed, 268 insertions(+) create mode 100644 Tests/Caster/DoctrineCasterTest.php create mode 100644 Tests/Caster/FiberCasterTest.php create mode 100644 Tests/Dumper/ContextProvider/RequestContextProviderTest.php diff --git a/Tests/Caster/DoctrineCasterTest.php b/Tests/Caster/DoctrineCasterTest.php new file mode 100644 index 00000000..85f6293b --- /dev/null +++ b/Tests/Caster/DoctrineCasterTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Tests\Caster; + +use Doctrine\Common\Collections\ArrayCollection; +use Doctrine\ORM\EntityManagerInterface; +use Doctrine\ORM\Mapping\ClassMetadata; +use Doctrine\ORM\PersistentCollection; +use PHPUnit\Framework\TestCase; +use Symfony\Component\VarDumper\Test\VarDumperTestTrait; + +/** + * @requires function \Doctrine\Common\Collections\ArrayCollection::__construct + */ +class DoctrineCasterTest extends TestCase +{ + use VarDumperTestTrait; + + public function testCastPersistentCollection() + { + $classMetadata = new ClassMetadata(__CLASS__); + + $collection = new PersistentCollection($this->createMock(EntityManagerInterface::class), $classMetadata, new ArrayCollection(['test'])); + + $expected = <<assertDumpMatchesFormat($expected, $collection); + } +} diff --git a/Tests/Caster/ExceptionCasterTest.php b/Tests/Caster/ExceptionCasterTest.php index 47cac850..157dc99c 100644 --- a/Tests/Caster/ExceptionCasterTest.php +++ b/Tests/Caster/ExceptionCasterTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\VarDumper\Tests\Caster; use PHPUnit\Framework\TestCase; +use Symfony\Component\ErrorHandler\Exception\SilencedErrorContext; use Symfony\Component\VarDumper\Caster\Caster; use Symfony\Component\VarDumper\Caster\ExceptionCaster; use Symfony\Component\VarDumper\Caster\FrameStub; @@ -29,6 +30,21 @@ private function getTestException($msg, &$ref = null) return new \Exception(''.$msg); } + private function getTestError($msg): \Error + { + return new \Error(''.$msg); + } + + private function getTestErrorException($msg): \ErrorException + { + return new \ErrorException(''.$msg); + } + + private function getTestSilencedErrorContext(): SilencedErrorContext + { + return new SilencedErrorContext(\E_ERROR, __FILE__, __LINE__); + } + protected function tearDown(): void { ExceptionCaster::$srcContext = 1; @@ -61,6 +77,79 @@ public function testDefaultSettings() $this->assertSame(['foo'], $ref); } + public function testDefaultSettingsOnError() + { + $e = $this->getTestError('foo'); + + $expectedDump = <<<'EODUMP' +Error { + #message: "foo" + #code: 0 + #file: "%sExceptionCasterTest.php" + #line: %d + trace: { + %s%eTests%eCaster%eExceptionCasterTest.php:%d { + Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestError($msg): Error + › { + › return new \Error(''.$msg); + › } + } + %s%eTests%eCaster%eExceptionCasterTest.php:%d { …} +%A +EODUMP; + + $this->assertDumpMatchesFormat($expectedDump, $e); + } + + public function testDefaultSettingsOnErrorException() + { + $e = $this->getTestErrorException('foo'); + + $expectedDump = <<<'EODUMP' +ErrorException { + #message: "foo" + #code: 0 + #file: "%sExceptionCasterTest.php" + #line: %d + #severity: E_ERROR + trace: { + %s%eTests%eCaster%eExceptionCasterTest.php:%d { + Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->getTestErrorException($msg): ErrorException + › { + › return new \ErrorException(''.$msg); + › } + } + %s%eTests%eCaster%eExceptionCasterTest.php:%d { …} +%A +EODUMP; + + $this->assertDumpMatchesFormat($expectedDump, $e); + } + + /** + * @requires function \Symfony\Component\ErrorHandler\Exception\SilencedErrorContext::__construct + */ + public function testCastSilencedErrorContext() + { + $e = $this->getTestSilencedErrorContext(); + + $expectedDump = <<<'EODUMP' +Symfony\Component\ErrorHandler\Exception\SilencedErrorContext { + +count: 1 + -severity: E_ERROR + trace: { + %s%eTests%eCaster%eExceptionCasterTest.php:%d { + › { + › return new SilencedErrorContext(\E_ERROR, __FILE__, __LINE__); + › } + } + } +} +EODUMP; + + $this->assertDumpMatchesFormat($expectedDump, $e); + } + public function testSeek() { $e = $this->getTestException(2); diff --git a/Tests/Caster/FiberCasterTest.php b/Tests/Caster/FiberCasterTest.php new file mode 100644 index 00000000..ff501db0 --- /dev/null +++ b/Tests/Caster/FiberCasterTest.php @@ -0,0 +1,85 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\VarDumper\Tests\Caster; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\VarDumper\Test\VarDumperTestTrait; + +/** + * @requires PHP 8.1 + */ +class FiberCasterTest extends TestCase +{ + use VarDumperTestTrait; + + public function testCastFiberNotStarted() + { + $fiber = new \Fiber(static function () { + return true; + }); + + $expected = <<assertDumpEquals($expected, $fiber); + } + + public function testCastFiberTerminated() + { + $fiber = new \Fiber(static function () { + return true; + }); + $fiber->start(); + + $expected = <<assertDumpEquals($expected, $fiber); + } + + public function testCastFiberSuspended() + { + $fiber = new \Fiber(static function () { + \Fiber::suspend(); + }); + $fiber->start(); + + $expected = <<assertDumpEquals($expected, $fiber); + } + + public function testCastFiberRunning() + { + $fiber = new \Fiber(function () { + $expected = <<assertDumpEquals($expected, \Fiber::getCurrent()); + }); + + $fiber->start(); + } +} diff --git a/Tests/Dumper/ContextProvider/RequestContextProviderTest.php b/Tests/Dumper/ContextProvider/RequestContextProviderTest.php new file mode 100644 index 00000000..5c141595 --- /dev/null +++ b/Tests/Dumper/ContextProvider/RequestContextProviderTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Dumper\ContextProvider; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\Component\VarDumper\Cloner\Data; +use Symfony\Component\VarDumper\Dumper\ContextProvider\RequestContextProvider; + +/** + * @requires function \Symfony\Component\HttpFoundation\RequestStack::__construct + */ +class RequestContextProviderTest extends TestCase +{ + public function testGetContextOnNullRequest() + { + $requestStack = new RequestStack(); + $provider = new RequestContextProvider($requestStack); + + $this->assertNull($provider->getContext()); + } + + public function testGetContextOnRequest() + { + $request = Request::create('https://example.org/', 'POST'); + $request->attributes->set('_controller', 'MyControllerClass'); + + $requestStack = new RequestStack(); + $requestStack->push($request); + + $context = (new RequestContextProvider($requestStack))->getContext(); + $this->assertSame('https://example.org/', $context['uri']); + $this->assertSame('POST', $context['method']); + $this->assertInstanceOf(Data::class, $context['controller']); + $this->assertSame('MyControllerClass', $context['controller']->getValue()); + $this->assertSame('https://example.org/', $context['uri']); + $this->assertArrayHasKey('identifier', $context); + } +} From 15715d4b7d0a45a93a4e0c3ddbf06b0d55404475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Mon, 13 Mar 2023 12:37:03 +0100 Subject: [PATCH 09/11] [VarDumper] Fixed dumping of CutStub --- Dumper/CliDumper.php | 3 +++ Tests/Dumper/CliDumperTest.php | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Dumper/CliDumper.php b/Dumper/CliDumper.php index 94dc8ee9..e061c8d7 100644 --- a/Dumper/CliDumper.php +++ b/Dumper/CliDumper.php @@ -198,6 +198,9 @@ public function dumpString(Cursor $cursor, string $str, bool $bin, int $cut) } if ('' === $str) { $this->line .= '""'; + if ($cut) { + $this->line .= '…'.$cut; + } $this->endValue($cursor); } else { $attr += [ diff --git a/Tests/Dumper/CliDumperTest.php b/Tests/Dumper/CliDumperTest.php index d94b15ff..968b4874 100644 --- a/Tests/Dumper/CliDumperTest.php +++ b/Tests/Dumper/CliDumperTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\VarDumper\Tests\Dumper; use PHPUnit\Framework\TestCase; +use Symfony\Component\VarDumper\Caster\CutStub; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\AbstractDumper; use Symfony\Component\VarDumper\Dumper\CliDumper; @@ -37,6 +38,11 @@ public function testGet() ':stream' => function ($res, $a) { unset($a['uri'], $a['wrapper_data']); + return $a; + }, + 'Symfony\Component\VarDumper\Tests\Fixture\DumbFoo' => function ($foo, $a) { + $a['foo'] = new CutStub($a['foo']); + return $a; }, ]); @@ -76,7 +82,7 @@ public function testGet() %A options: [] } "obj" => Symfony\Component\VarDumper\Tests\Fixture\DumbFoo {#%d - +foo: "foo" + +foo: ""…3 +"bar": "bar" } "closure" => Closure(\$a, PDO &\$b = null) {#%d From e2edac9ce47e6df07e38143c7cfa6bdbc1a6dcc4 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 3 Feb 2023 10:25:44 +0100 Subject: [PATCH 10/11] [VarDumper] Disable links for IntelliJ platform --- Dumper/CliDumper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dumper/CliDumper.php b/Dumper/CliDumper.php index e061c8d7..b5d9ac33 100644 --- a/Dumper/CliDumper.php +++ b/Dumper/CliDumper.php @@ -448,7 +448,8 @@ protected function style(string $style, string $value, array $attr = []) if (null === $this->handlesHrefGracefully) { $this->handlesHrefGracefully = 'JetBrains-JediTerm' !== getenv('TERMINAL_EMULATOR') - && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100); + && (!getenv('KONSOLE_VERSION') || (int) getenv('KONSOLE_VERSION') > 201100) + && !isset($_SERVER['IDEA_INITIAL_DIRECTORY']); } if (isset($attr['ellipsis'], $attr['ellipsis-type'])) { From 9a8a5b6d6508928174ded2109e29328a55342a42 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Tue, 18 Apr 2023 11:04:07 +0200 Subject: [PATCH 11/11] [VarDumper] Make the server TCP connection sync --- Server/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Server/Connection.php b/Server/Connection.php index d0611a1f..ebfc6506 100644 --- a/Server/Connection.php +++ b/Server/Connection.php @@ -91,7 +91,7 @@ private function createSocket() { set_error_handler([self::class, 'nullErrorHandler']); try { - return stream_socket_client($this->host, $errno, $errstr, 3, \STREAM_CLIENT_CONNECT | \STREAM_CLIENT_ASYNC_CONNECT); + return stream_socket_client($this->host, $errno, $errstr, 3); } finally { restore_error_handler(); }