From 95939101e1d7304df03a9566d452c0169fa6c14f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Sun, 30 Jul 2023 12:43:06 +0200 Subject: [PATCH 01/30] [Messenger] Add forward compatibily with php-amqp v2 see https://github.com/php-amqp/php-amqp/issues/424#issuecomment-1656692661 --- .../Component/Messenger/Bridge/Amqp/Transport/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php index ab8d6f980d519..ece0c1716b69b 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php @@ -456,7 +456,7 @@ public function get(string $queueName): ?\AMQPEnvelope public function ack(\AMQPEnvelope $message, string $queueName): bool { - return $this->queue($queueName)->ack($message->getDeliveryTag()); + return $this->queue($queueName)->ack($message->getDeliveryTag()) ?? true; } public function nack(\AMQPEnvelope $message, string $queueName, int $flags = \AMQP_NOPARAM): bool From 2290340a3a061e96aac9713352972573fcbb206b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 31 Jul 2023 12:26:11 +0200 Subject: [PATCH 02/30] Bump Symfony version to 5.4.28 --- src/Symfony/Component/HttpKernel/Kernel.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Kernel.php b/src/Symfony/Component/HttpKernel/Kernel.php index 5decdd57ada05..1d92ef4639f5d 100644 --- a/src/Symfony/Component/HttpKernel/Kernel.php +++ b/src/Symfony/Component/HttpKernel/Kernel.php @@ -78,12 +78,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl */ private static $freshCache = []; - public const VERSION = '5.4.27'; - public const VERSION_ID = 50427; + public const VERSION = '5.4.28-DEV'; + public const VERSION_ID = 50428; public const MAJOR_VERSION = 5; public const MINOR_VERSION = 4; - public const RELEASE_VERSION = 27; - public const EXTRA_VERSION = ''; + public const RELEASE_VERSION = 28; + public const EXTRA_VERSION = 'DEV'; public const END_OF_MAINTENANCE = '11/2024'; public const END_OF_LIFE = '11/2025'; From 8965c0c7f3a4ef1c111e109b9afcfa5a3c73a064 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Fri, 21 Jul 2023 13:15:16 +0200 Subject: [PATCH 03/30] [DoctrineBridge] Bugfix - Allow to remove LazyLoaded listeners by object --- .../Doctrine/ContainerAwareEventManager.php | 23 +++++++++++++++++-- .../Tests/ContainerAwareEventManagerTest.php | 15 ++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php index db5cc920f361f..be31c7218af5b 100644 --- a/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php +++ b/src/Symfony/Bridge/Doctrine/ContainerAwareEventManager.php @@ -32,6 +32,7 @@ class ContainerAwareEventManager extends EventManager private $subscribers; private $initialized = []; private $initializedSubscribers = false; + private $initializedHashMapping = []; private $methods = []; private $container; @@ -138,6 +139,7 @@ public function addEventListener($events, $listener) if (\is_string($listener)) { unset($this->initialized[$event]); + unset($this->initializedHashMapping[$event][$hash]); } else { $this->methods[$event][$hash] = $this->getMethod($listener, $event); } @@ -158,6 +160,11 @@ public function removeEventListener($events, $listener) $hash = $this->getHash($listener); foreach ((array) $events as $event) { + if (isset($this->initializedHashMapping[$event][$hash])) { + $hash = $this->initializedHashMapping[$event][$hash]; + unset($this->initializedHashMapping[$event][$hash]); + } + // Check if we actually have this listener associated if (isset($this->listeners[$event][$hash])) { unset($this->listeners[$event][$hash]); @@ -190,13 +197,25 @@ public function removeEventSubscriber(EventSubscriber $subscriber): void private function initializeListeners(string $eventName) { $this->initialized[$eventName] = true; + + // We'll refill the whole array in order to keep the same order + $listeners = []; foreach ($this->listeners[$eventName] as $hash => $listener) { if (\is_string($listener)) { - $this->listeners[$eventName][$hash] = $listener = $this->container->get($listener); + $listener = $this->container->get($listener); + $newHash = $this->getHash($listener); + + $this->initializedHashMapping[$eventName][$hash] = $newHash; - $this->methods[$eventName][$hash] = $this->getMethod($listener, $eventName); + $listeners[$newHash] = $listener; + + $this->methods[$eventName][$newHash] = $this->getMethod($listener, $eventName); + } else { + $listeners[$hash] = $listener; } } + + $this->listeners[$eventName] = $listeners; } private function initializeSubscribers() diff --git a/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php b/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php index 9d86eeed54ef1..80d6e30a22453 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/ContainerAwareEventManagerTest.php @@ -202,6 +202,21 @@ public function testRemoveEventListener() $this->assertSame([], $this->evm->getListeners('foo')); } + public function testRemoveAllEventListener() + { + $this->container->set('lazy', new MyListener()); + $this->evm->addEventListener('foo', 'lazy'); + $this->evm->addEventListener('foo', new MyListener()); + + foreach ($this->evm->getAllListeners() as $event => $listeners) { + foreach ($listeners as $listener) { + $this->evm->removeEventListener($event, $listener); + } + } + + $this->assertSame([], $this->evm->getListeners('foo')); + } + public function testRemoveEventListenerAfterDispatchEvent() { $this->container->set('lazy', $listener1 = new MyListener()); From 375dd08af5bd446ac77c081723b461556ea26393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Tue, 1 Aug 2023 10:27:53 +0200 Subject: [PATCH 04/30] [Workflow] fix MermaidDumper when place contains special char --- .../Workflow/Dumper/MermaidDumper.php | 8 +- .../Tests/Dumper/MermaidDumperTest.php | 247 +++++++++--------- 2 files changed, 126 insertions(+), 129 deletions(-) diff --git a/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php b/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php index b7f5eae1421fc..9f6a5b5f95a9c 100644 --- a/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php +++ b/src/Symfony/Component/Workflow/Dumper/MermaidDumper.php @@ -77,7 +77,7 @@ public function dump(Definition $definition, Marking $marking = null, array $opt $meta = $definition->getMetadataStore(); foreach ($definition->getPlaces() as $place) { - [$placeNode, $placeStyle] = $this->preparePlace( + [$placeNodeName, $placeNode, $placeStyle] = $this->preparePlace( $placeId, $place, $meta->getPlaceMetadata($place), @@ -91,7 +91,7 @@ public function dump(Definition $definition, Marking $marking = null, array $opt $output[] = $placeStyle; } - $placeNameMap[$place] = $place.$placeId; + $placeNameMap[$place] = $placeNodeName; ++$placeId; } @@ -161,13 +161,13 @@ private function preparePlace(int $placeId, string $placeName, array $meta, bool $labelShape = '([%s])'; } - $placeNodeName = $placeName.$placeId; + $placeNodeName = 'place'.$placeId; $placeNodeFormat = '%s'.$labelShape; $placeNode = sprintf($placeNodeFormat, $placeNodeName, $placeLabel); $placeStyle = $this->styleNode($meta, $placeNodeName, $hasMarking); - return [$placeNode, $placeStyle]; + return [$placeNodeName, $placeNode, $placeStyle]; } private function styleNode(array $meta, string $nodeName, bool $hasMarking = false): string diff --git a/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php b/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php index 93c1e339486ee..5a657ed9c212a 100644 --- a/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php +++ b/src/Symfony/Component/Workflow/Tests/Dumper/MermaidDumperTest.php @@ -48,9 +48,9 @@ public function testDumpWithReservedWordsAsPlacenames(Definition $definition, st } /** - * @dataProvider provideStatemachine + * @dataProvider provideStateMachine */ - public function testDumpAsStatemachine(Definition $definition, string $expected) + public function testDumpAsStateMachine(Definition $definition, string $expected) { $dumper = new MermaidDumper(MermaidDumper::TRANSITION_TYPE_STATEMACHINE); @@ -71,82 +71,82 @@ public function testDumpWorkflowWithMarking(Definition $definition, Marking $mar $this->assertEquals($expected, $dump); } - public static function provideWorkflowDefinitionWithoutMarking(): array + public static function provideWorkflowDefinitionWithoutMarking(): iterable { - return [ - [ - self::createComplexWorkflowDefinition(), - "graph LR\n" - ."a0([\"a\"])\n" - ."b1((\"b\"))\n" - ."c2((\"c\"))\n" - ."d3((\"d\"))\n" - ."e4((\"e\"))\n" - ."f5((\"f\"))\n" - ."g6((\"g\"))\n" - ."transition0[\"t1\"]\n" - ."a0-->transition0\n" - ."transition0-->b1\n" - ."transition0-->c2\n" - ."transition1[\"t2\"]\n" - ."b1-->transition1\n" - ."transition1-->d3\n" - ."c2-->transition1\n" - ."transition2[\"My custom transition label 1\"]\n" - ."d3-->transition2\n" - ."linkStyle 6 stroke:Red\n" - ."transition2-->e4\n" - ."linkStyle 7 stroke:Red\n" - ."transition3[\"t4\"]\n" - ."d3-->transition3\n" - ."transition3-->f5\n" - ."transition4[\"t5\"]\n" - ."e4-->transition4\n" - ."transition4-->g6\n" - ."transition5[\"t6\"]\n" - ."f5-->transition5\n" - .'transition5-->g6', - ], - [ - self::createWorkflowWithSameNameTransition(), - "graph LR\n" - ."a0([\"a\"])\n" - ."b1((\"b\"))\n" - ."c2((\"c\"))\n" - ."transition0[\"a_to_bc\"]\n" - ."a0-->transition0\n" - ."transition0-->b1\n" - ."transition0-->c2\n" - ."transition1[\"b_to_c\"]\n" - ."b1-->transition1\n" - ."transition1-->c2\n" - ."transition2[\"to_a\"]\n" - ."b1-->transition2\n" - ."transition2-->a0\n" - ."transition3[\"to_a\"]\n" - ."c2-->transition3\n" - .'transition3-->a0', - ], - [ - self::createSimpleWorkflowDefinition(), - "graph LR\n" - ."a0([\"a\"])\n" - ."b1((\"b\"))\n" - ."c2((\"c\"))\n" - ."style c2 fill:DeepSkyBlue\n" - ."transition0[\"My custom transition label 2\"]\n" - ."a0-->transition0\n" - ."linkStyle 0 stroke:Grey\n" - ."transition0-->b1\n" - ."linkStyle 1 stroke:Grey\n" - ."transition1[\"t2\"]\n" - ."b1-->transition1\n" - .'transition1-->c2', - ], + yield [ + self::createComplexWorkflowDefinition(), + "graph LR\n" + ."place0([\"a\"])\n" + ."place1((\"b\"))\n" + ."place2((\"c\"))\n" + ."place3((\"d\"))\n" + ."place4((\"e\"))\n" + ."place5((\"f\"))\n" + ."place6((\"g\"))\n" + ."transition0[\"t1\"]\n" + ."place0-->transition0\n" + ."transition0-->place1\n" + ."transition0-->place2\n" + ."transition1[\"t2\"]\n" + ."place1-->transition1\n" + ."transition1-->place3\n" + ."place2-->transition1\n" + ."transition2[\"My custom transition label 1\"]\n" + ."place3-->transition2\n" + ."linkStyle 6 stroke:Red\n" + ."transition2-->place4\n" + ."linkStyle 7 stroke:Red\n" + ."transition3[\"t4\"]\n" + ."place3-->transition3\n" + ."transition3-->place5\n" + ."transition4[\"t5\"]\n" + ."place4-->transition4\n" + ."transition4-->place6\n" + ."transition5[\"t6\"]\n" + ."place5-->transition5\n" + ."transition5-->place6" + + ]; + yield [ + self::createWorkflowWithSameNameTransition(), + "graph LR\n" + ."place0([\"a\"])\n" + ."place1((\"b\"))\n" + ."place2((\"c\"))\n" + ."transition0[\"a_to_bc\"]\n" + ."place0-->transition0\n" + ."transition0-->place1\n" + ."transition0-->place2\n" + ."transition1[\"b_to_c\"]\n" + ."place1-->transition1\n" + ."transition1-->place2\n" + ."transition2[\"to_a\"]\n" + ."place1-->transition2\n" + ."transition2-->place0\n" + ."transition3[\"to_a\"]\n" + ."place2-->transition3\n" + ."transition3-->place0" + + ]; + yield [ + self::createSimpleWorkflowDefinition(), + "graph LR\n" + ."place0([\"a\"])\n" + ."place1((\"b\"))\n" + ."place2((\"c\"))\n" + ."style place2 fill:DeepSkyBlue\n" + ."transition0[\"My custom transition label 2\"]\n" + ."place0-->transition0\n" + ."linkStyle 0 stroke:Grey\n" + ."transition0-->place1\n" + ."linkStyle 1 stroke:Grey\n" + ."transition1[\"t2\"]\n" + ."place1-->transition1\n" + ."transition1-->place2" ]; } - public static function provideWorkflowWithReservedWords() + public static function provideWorkflowWithReservedWords(): iterable { $builder = new DefinitionBuilder(); @@ -158,69 +158,66 @@ public static function provideWorkflowWithReservedWords() $definition = $builder->build(); - return [ - [ - $definition, - "graph LR\n" - ."start0([\"start\"])\n" - ."subgraph1((\"subgraph\"))\n" - ."end2((\"end\"))\n" - ."finis3((\"finis\"))\n" - ."transition0[\"t0\"]\n" - ."start0-->transition0\n" - ."transition0-->end2\n" - ."subgraph1-->transition0\n" - ."transition1[\"t1\"]\n" - ."end2-->transition1\n" - .'transition1-->finis3', - ], + yield [ + $definition, + "graph LR\n" + ."place0([\"start\"])\n" + ."place1((\"subgraph\"))\n" + ."place2((\"end\"))\n" + ."place3((\"finis\"))\n" + ."transition0[\"t0\"]\n" + ."place0-->transition0\n" + ."transition0-->place2\n" + ."place1-->transition0\n" + ."transition1[\"t1\"]\n" + ."place2-->transition1\n" + ."transition1-->place3" + ]; } - public static function provideStatemachine(): array + public static function provideStateMachine(): iterable { - return [ - [ - self::createComplexStateMachineDefinition(), - "graph LR\n" - ."a0([\"a\"])\n" - ."b1((\"b\"))\n" - ."c2((\"c\"))\n" - ."d3((\"d\"))\n" - ."a0-->|\"t1\"|b1\n" - ."d3-->|\"My custom transition label 3\"|b1\n" - ."linkStyle 1 stroke:Grey\n" - ."b1-->|\"t2\"|c2\n" - .'b1-->|"t3"|d3', - ], + yield [ + self::createComplexStateMachineDefinition(), + "graph LR\n" + ."place0([\"a\"])\n" + ."place1((\"b\"))\n" + ."place2((\"c\"))\n" + ."place3((\"d\"))\n" + ."place0-->|\"t1\"|place1\n" + ."place3-->|\"My custom transition label 3\"|place1\n" + ."linkStyle 1 stroke:Grey\n" + ."place1-->|\"t2\"|place2\n" + ."place1-->|\"t3\"|place3" + ]; } - public static function provideWorkflowWithMarking(): array + public static function provideWorkflowWithMarking(): iterable { $marking = new Marking(); $marking->mark('b'); $marking->mark('c'); - return [ - [ - self::createSimpleWorkflowDefinition(), - $marking, - "graph LR\n" - ."a0([\"a\"])\n" - ."b1((\"b\"))\n" - ."style b1 stroke-width:4px\n" - ."c2((\"c\"))\n" - ."style c2 fill:DeepSkyBlue,stroke-width:4px\n" - ."transition0[\"My custom transition label 2\"]\n" - ."a0-->transition0\n" - ."linkStyle 0 stroke:Grey\n" - ."transition0-->b1\n" - ."linkStyle 1 stroke:Grey\n" - ."transition1[\"t2\"]\n" - ."b1-->transition1\n" - .'transition1-->c2', - ], + yield [ + self::createSimpleWorkflowDefinition(), + $marking, + "graph LR\n" + ."place0([\"a\"])\n" + ."place1((\"b\"))\n" + ."style place1 stroke-width:4px\n" + ."place2((\"c\"))\n" + ."style place2 fill:DeepSkyBlue,stroke-width:4px\n" + ."transition0[\"My custom transition label 2\"]\n" + ."place0-->transition0\n" + ."linkStyle 0 stroke:Grey\n" + ."transition0-->place1\n" + ."linkStyle 1 stroke:Grey\n" + ."transition1[\"t2\"]\n" + ."place1-->transition1\n" + ."transition1-->place2" + ]; } } From 05b5648cdfcdbebd9930b4104cfd90da8f1ecc9e Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 1 Aug 2023 15:39:00 +0200 Subject: [PATCH 05/30] [Process] Fix test case --- src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php | 4 ++-- src/Symfony/Component/Process/Tests/ProcessTest.php | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php b/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php index 4c8556acf51c2..541680224d740 100644 --- a/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php +++ b/src/Symfony/Component/Process/Tests/ErrorProcessInitiator.php @@ -14,12 +14,12 @@ use Symfony\Component\Process\Exception\ProcessTimedOutException; use Symfony\Component\Process\Process; -require \dirname(__DIR__).'/vendor/autoload.php'; +require is_file(\dirname(__DIR__).'/vendor/autoload.php') ? \dirname(__DIR__).'/vendor/autoload.php' : \dirname(__DIR__, 5).'/vendor/autoload.php'; ['e' => $php] = getopt('e:') + ['e' => 'php']; try { - $process = new Process("exec $php -r \"echo 'ready'; trigger_error('error', E_USER_ERROR);\""); + $process = new Process([$php, '-r', "echo 'ready'; trigger_error('error', E_USER_ERROR);"]); $process->start(); $process->setTimeout(0.5); while (!str_contains($process->getOutput(), 'ready')) { diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 6e6ee8a41a029..827c723969c76 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1523,6 +1523,10 @@ public function testWaitStoppedDeadProcess() $process->setTimeout(2); $process->wait(); $this->assertFalse($process->isRunning()); + + if ('\\' !== \DIRECTORY_SEPARATOR) { + $this->assertSame(0, $process->getExitCode()); + } } public function testEnvCaseInsensitiveOnWindows() From 56166afcb108ccdaed820e2eccde742045f38dcc Mon Sep 17 00:00:00 2001 From: Antoine Lamirault Date: Tue, 1 Aug 2023 19:52:17 +0200 Subject: [PATCH 06/30] [Notifier] Document Amazon Notifier options --- src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md b/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md index db4759327f502..85cf8f271936d 100644 --- a/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md +++ b/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md @@ -7,9 +7,15 @@ DSN example ----------- ``` -AMAZON_SNS_DSN=sns://ACCESS_ID:ACCESS_KEY@default?region=REGION +AMAZON_SNS_DSN=sns://ACCESS_ID:ACCESS_KEY@default?region=REGION&profile=PROFILE ``` +where: + - `ACCESS_ID` is your AWS access key id + - `ACCESS_KEY` is your AWS access key secret + - `REGION` is the AWS region targeted (optional, default: `us-east-1`) + - `PROFILE` is the name of your AWS configured profile (optional, default: `default`) + Adding Options to a Chat Message -------------------------------- From 269eb100c1192ab483538c254dc9984940919ce3 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 2 Aug 2023 11:26:36 +0200 Subject: [PATCH 07/30] [Notifier][AmazonSns] README update --- src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md b/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md index 85cf8f271936d..9dd4bfdcccaa6 100644 --- a/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md +++ b/src/Symfony/Component/Notifier/Bridge/AmazonSns/README.md @@ -13,7 +13,7 @@ AMAZON_SNS_DSN=sns://ACCESS_ID:ACCESS_KEY@default?region=REGION&profile=PROFILE where: - `ACCESS_ID` is your AWS access key id - `ACCESS_KEY` is your AWS access key secret - - `REGION` is the AWS region targeted (optional, default: `us-east-1`) + - `REGION` is the targeted AWS region (optional, default: `us-east-1`) - `PROFILE` is the name of your AWS configured profile (optional, default: `default`) Adding Options to a Chat Message @@ -43,6 +43,7 @@ $chatter->send($chatMessage); Resources --------- + * [AsyncAws Documentation](https://async-aws.com/configuration.html) * [Contributing](https://symfony.com/doc/current/contributing/index.html) * [Report issues](https://github.com/symfony/symfony/issues) and [send Pull Requests](https://github.com/symfony/symfony/pulls) From 74401f106cc40a687f03c0bdc96061d5695131ec Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 4 Aug 2023 10:05:04 +0200 Subject: [PATCH 08/30] Psalm: Suppress UnusedConstructor errors --- psalm.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/psalm.xml b/psalm.xml index c74733de4e714..4d9f6743bd3b8 100644 --- a/psalm.xml +++ b/psalm.xml @@ -36,5 +36,14 @@ + + + + + + From 98fe0a21b5a8f4d98ab1d55b9e25a309e1e5b8d2 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 5 Aug 2023 10:32:42 +0200 Subject: [PATCH 09/30] harden LockRegistry tests, consider PHP files only --- src/Symfony/Component/Cache/Tests/LockRegistryTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Cache/Tests/LockRegistryTest.php b/src/Symfony/Component/Cache/Tests/LockRegistryTest.php index 30ff6774047a5..7666279b9491e 100644 --- a/src/Symfony/Component/Cache/Tests/LockRegistryTest.php +++ b/src/Symfony/Component/Cache/Tests/LockRegistryTest.php @@ -23,7 +23,7 @@ public function testFiles() } $lockFiles = LockRegistry::setFiles([]); LockRegistry::setFiles($lockFiles); - $expected = array_map('realpath', glob(__DIR__.'/../Adapter/*')); + $expected = array_map('realpath', glob(__DIR__.'/../Adapter/*.php')); $this->assertSame($expected, $lockFiles); } } From fcf86b395bd05590be6312a8bb9ba2bc5e261275 Mon Sep 17 00:00:00 2001 From: Maximilian Beckers Date: Mon, 7 Aug 2023 08:12:30 +0200 Subject: [PATCH 10/30] [Console] Fix linewraps in OutputFormatter --- .../Console/Formatter/OutputFormatter.php | 11 ++- .../Tests/Formatter/OutputFormatterTest.php | 14 ++-- .../Console/Tests/Helper/TableTest.php | 75 ++++++++++--------- 3 files changed, 57 insertions(+), 43 deletions(-) diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 603e5dca0b1dc..4ec600244d656 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -13,6 +13,8 @@ use Symfony\Component\Console\Exception\InvalidArgumentException; +use function Symfony\Component\String\b; + /** * Formatter class for console output. * @@ -258,7 +260,7 @@ private function applyCurrentStyle(string $text, string $current, int $width, in } preg_match('~(\\n)$~', $text, $matches); - $text = $prefix.preg_replace('~([^\\n]{'.$width.'})\\ *~', "\$1\n", $text); + $text = $prefix.$this->addLineBreaks($text, $width); $text = rtrim($text, "\n").($matches[1] ?? ''); if (!$currentLineLength && '' !== $current && "\n" !== substr($current, -1)) { @@ -282,4 +284,11 @@ private function applyCurrentStyle(string $text, string $current, int $width, in return implode("\n", $lines); } + + private function addLineBreaks(string $text, int $width): string + { + $encoding = mb_detect_encoding($text, null, true) ?: 'UTF-8'; + + return b($text)->toCodePointString($encoding)->wordwrap($width, "\n", true)->toByteString($encoding); + } } diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php index 203f5a3caf0ab..0b1772107bbd7 100644 --- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php +++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php @@ -367,10 +367,10 @@ public function testFormatAndWrap() $formatter = new OutputFormatter(true); $this->assertSame("fo\no\e[37;41mb\e[39;49m\n\e[37;41mar\e[39;49m\nba\nz", $formatter->formatAndWrap('foobar baz', 2)); - $this->assertSame("pr\ne \e[37;41m\e[39;49m\n\e[37;41mfo\e[39;49m\n\e[37;41mo \e[39;49m\n\e[37;41mba\e[39;49m\n\e[37;41mr \e[39;49m\n\e[37;41mba\e[39;49m\n\e[37;41mz\e[39;49m \npo\nst", $formatter->formatAndWrap('pre foo bar baz post', 2)); + $this->assertSame("pr\ne \e[37;41m\e[39;49m\n\e[37;41mfo\e[39;49m\n\e[37;41mo\e[39;49m\n\e[37;41mba\e[39;49m\n\e[37;41mr\e[39;49m\n\e[37;41mba\e[39;49m\n\e[37;41mz\e[39;49m \npo\nst", $formatter->formatAndWrap('pre foo bar baz post', 2)); $this->assertSame("pre\e[37;41m\e[39;49m\n\e[37;41mfoo\e[39;49m\n\e[37;41mbar\e[39;49m\n\e[37;41mbaz\e[39;49m\npos\nt", $formatter->formatAndWrap('pre foo bar baz post', 3)); - $this->assertSame("pre \e[37;41m\e[39;49m\n\e[37;41mfoo \e[39;49m\n\e[37;41mbar \e[39;49m\n\e[37;41mbaz\e[39;49m \npost", $formatter->formatAndWrap('pre foo bar baz post', 4)); - $this->assertSame("pre \e[37;41mf\e[39;49m\n\e[37;41moo ba\e[39;49m\n\e[37;41mr baz\e[39;49m\npost", $formatter->formatAndWrap('pre foo bar baz post', 5)); + $this->assertSame("pre \e[37;41m\e[39;49m\n\e[37;41mfoo\e[39;49m\n\e[37;41mbar\e[39;49m\n\e[37;41mbaz\e[39;49m \npost", $formatter->formatAndWrap('pre foo bar baz post', 4)); + $this->assertSame("pre \e[37;41mf\e[39;49m\n\e[37;41moo\e[39;49m\n\e[37;41mbar\e[39;49m\n\e[37;41mbaz\e[39;49m p\nost", $formatter->formatAndWrap('pre foo bar baz post', 5)); $this->assertSame("Lore\nm \e[37;41mip\e[39;49m\n\e[37;41msum\e[39;49m \ndolo\nr \e[32msi\e[39m\n\e[32mt\e[39m am\net", $formatter->formatAndWrap('Lorem ipsum dolor sit amet', 4)); $this->assertSame("Lorem \e[37;41mip\e[39;49m\n\e[37;41msum\e[39;49m dolo\nr \e[32msit\e[39m am\net", $formatter->formatAndWrap('Lorem ipsum dolor sit amet', 8)); $this->assertSame("Lorem \e[37;41mipsum\e[39;49m dolor \e[32m\e[39m\n\e[32msit\e[39m, \e[37;41mamet\e[39;49m et \e[32mlauda\e[39m\n\e[32mntium\e[39m architecto", $formatter->formatAndWrap('Lorem ipsum dolor sit, amet et laudantium architecto', 18)); @@ -378,10 +378,12 @@ public function testFormatAndWrap() $formatter = new OutputFormatter(); $this->assertSame("fo\nob\nar\nba\nz", $formatter->formatAndWrap('foobar baz', 2)); - $this->assertSame("pr\ne \nfo\no \nba\nr \nba\nz \npo\nst", $formatter->formatAndWrap('pre foo bar baz post', 2)); + $this->assertSame("pr\ne \nfo\no\nba\nr\nba\nz \npo\nst", $formatter->formatAndWrap('pre foo bar baz post', 2)); $this->assertSame("pre\nfoo\nbar\nbaz\npos\nt", $formatter->formatAndWrap('pre foo bar baz post', 3)); - $this->assertSame("pre \nfoo \nbar \nbaz \npost", $formatter->formatAndWrap('pre foo bar baz post', 4)); - $this->assertSame("pre f\noo ba\nr baz\npost", $formatter->formatAndWrap('pre foo bar baz post', 5)); + $this->assertSame("pre \nfoo\nbar\nbaz \npost", $formatter->formatAndWrap('pre foo bar baz post', 4)); + $this->assertSame("pre f\noo\nbar\nbaz p\nost", $formatter->formatAndWrap('pre foo bar baz post', 5)); + $this->assertSame("Â rèälly\nlöng tîtlè\nthät cöüld\nnèêd\nmúltîplê\nlínès", $formatter->formatAndWrap('Â rèälly löng tîtlè thät cöüld nèêd múltîplê línès', 10)); + $this->assertSame("Â rèälly\nlöng tîtlè\nthät cöüld\nnèêd\nmúltîplê\n línès", $formatter->formatAndWrap("Â rèälly löng tîtlè thät cöüld nèêd múltîplê\n línès", 10)); $this->assertSame('', $formatter->formatAndWrap(null, 5)); } } diff --git a/src/Symfony/Component/Console/Tests/Helper/TableTest.php b/src/Symfony/Component/Console/Tests/Helper/TableTest.php index e9c94b10780dc..1f313a680f04a 100644 --- a/src/Symfony/Component/Console/Tests/Helper/TableTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/TableTest.php @@ -118,30 +118,30 @@ public static function renderProvider() ['ISBN', 'Title', 'Author'], $books, 'compact', -<<<'TABLE' -ISBN Title Author -99921-58-10-7 Divine Comedy Dante Alighieri -9971-5-0210-0 A Tale of Two Cities Charles Dickens -960-425-059-0 The Lord of the Rings J. R. R. Tolkien -80-902734-1-6 And Then There Were None Agatha Christie - -TABLE + implode("\n", [ + 'ISBN Title Author ', + '99921-58-10-7 Divine Comedy Dante Alighieri ', + '9971-5-0210-0 A Tale of Two Cities Charles Dickens ', + '960-425-059-0 The Lord of the Rings J. R. R. Tolkien ', + '80-902734-1-6 And Then There Were None Agatha Christie ', + '', + ]), ], [ ['ISBN', 'Title', 'Author'], $books, 'borderless', -<<<'TABLE' - =============== ========================== ================== - ISBN Title Author - =============== ========================== ================== - 99921-58-10-7 Divine Comedy Dante Alighieri - 9971-5-0210-0 A Tale of Two Cities Charles Dickens - 960-425-059-0 The Lord of the Rings J. R. R. Tolkien - 80-902734-1-6 And Then There Were None Agatha Christie - =============== ========================== ================== - -TABLE + implode("\n", [ + ' =============== ========================== ================== ', + ' ISBN Title Author ', + ' =============== ========================== ================== ', + ' 99921-58-10-7 Divine Comedy Dante Alighieri ', + ' 9971-5-0210-0 A Tale of Two Cities Charles Dickens ', + ' 960-425-059-0 The Lord of the Rings J. R. R. Tolkien ', + ' 80-902734-1-6 And Then There Were None Agatha Christie ', + ' =============== ========================== ================== ', + '', + ]), ], [ ['ISBN', 'Title', 'Author'], @@ -1378,12 +1378,14 @@ public function testColumnMaxWidths() $expected = << Date: Mon, 7 Aug 2023 11:52:08 +0200 Subject: [PATCH 11/30] [Process] Fix silencing `wait` when using a sigchild-enabled binary --- src/Symfony/Component/Process/Process.php | 2 +- src/Symfony/Component/Process/Tests/ProcessTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 9b19475ac5d78..30ebeb6b58e18 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -331,7 +331,7 @@ public function start(callable $callback = null, array $env = []) // See https://unix.stackexchange.com/questions/71205/background-process-pipe-input $commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;'; - $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code'; + $commandline .= 'pid=$!; echo $pid >&3; wait $pid 2>/dev/null; code=$?; echo $code >&3; exit $code'; // Workaround for the bug, when PTS functionality is enabled. // @see : https://bugs.php.net/69442 diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 827c723969c76..804937999a5f6 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1524,7 +1524,7 @@ public function testWaitStoppedDeadProcess() $process->wait(); $this->assertFalse($process->isRunning()); - if ('\\' !== \DIRECTORY_SEPARATOR) { + if ('\\' !== \DIRECTORY_SEPARATOR && !\Closure::bind(function () { return $this->isSigchildEnabled(); }, $process, $process)()) { $this->assertSame(0, $process->getExitCode()); } } From a6a3faee4d2497a974a17028229ebee3e3940cad Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 7 Aug 2023 16:20:23 +0200 Subject: [PATCH 12/30] add missing default-doctrine-dbal-provider cache pool attribute to XSD --- .../FrameworkBundle/Resources/config/schema/symfony-1.0.xsd | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 3a1a9a6d70a65..857c3c57fb7f2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -290,6 +290,7 @@ + From f42e2c146ed50d708bfc359fd9c2139575b5f2f5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 8 Aug 2023 11:57:41 +0200 Subject: [PATCH 13/30] [DoctrineBridge] Silence ORM deprecation --- .github/deprecations-baseline.json | 147 +++++++++++++++++- .github/workflows/unit-tests.yml | 1 + .../Doctrine/Test/DoctrineTestHelper.php | 5 + 3 files changed, 152 insertions(+), 1 deletion(-) diff --git a/.github/deprecations-baseline.json b/.github/deprecations-baseline.json index bc8adfb354f19..fdd35496c22c2 100644 --- a/.github/deprecations-baseline.json +++ b/.github/deprecations-baseline.json @@ -8,5 +8,150 @@ "location": "Symfony\\Component\\Messenger\\Bridge\\Doctrine\\Tests\\Transport\\DoctrinePostgreSqlIntegrationTest::setUp", "message": "Connection::query() is deprecated, use Connection::executeQuery() instead. (Connection.php:1436 called by AbstractPostgreSQLDriver.php:149, https://github.com/doctrine/dbal/pull/4163, package doctrine/dbal)", "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\ChoiceList\\ORMQueryBuilderLoaderTest::testIdentifierTypeIsStringArray", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\ChoiceList\\ORMQueryBuilderLoaderTest::testIdentifierTypeIsIntegerArray", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\ChoiceList\\ORMQueryBuilderLoaderTest::testFilterNonIntegerValues", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\ChoiceList\\ORMQueryBuilderLoaderTest::testFilterEmptyUuids", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 2 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\ChoiceList\\ORMQueryBuilderLoaderTest::testFilterUid", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 2 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\ChoiceList\\ORMQueryBuilderLoaderTest::testUidThrowProperException", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 2 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\ChoiceList\\ORMQueryBuilderLoaderTest::testEmbeddedIdentifierName", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Form\\Type\\EntityTypeTest::setUp", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 83 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testGetProperties", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testTestGetPropertiesWithEmbedded", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testExtract", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 25 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testExtractWithEmbedded", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testExtractEnum", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 5 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testGetPropertiesCatchException", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testGetTypesCatchException", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\PropertyInfo\\DoctrineExtractorTest::testGeneratedValueNotWritable", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Security\\User\\EntityUserProviderTest::testRefreshUserGetsUserByPrimaryKey", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Security\\User\\EntityUserProviderTest::testLoadUserByUsername", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Security\\User\\EntityUserProviderTest::testLoadUserByUsernameWithNonUserLoaderRepositoryAndWithoutProperty", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Security\\User\\EntityUserProviderTest::testRefreshUserRequiresId", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Security\\User\\EntityUserProviderTest::testRefreshInvalidUser", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Security\\User\\EntityUserProviderTest::testSupportProxy", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Security\\User\\EntityUserProviderTest::testRefreshedUserProxyIsLoaded", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Validator\\Constraints\\UniqueEntityValidatorTest::setUp", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 36 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Validator\\DoctrineLoaderTest::testLoadClassMetadata", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Validator\\DoctrineLoaderTest::testExtractEnum", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Validator\\DoctrineLoaderTest::testFieldMappingsConfiguration", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Validator\\DoctrineLoaderTest::testClassValidator", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 4 + }, + { + "location": "Symfony\\Bridge\\Doctrine\\Tests\\Validator\\DoctrineLoaderTest::testClassNoAutoMapping", + "message": "Not enabling lazy ghost objects is deprecated and will not be supported in Doctrine ORM 3.0. Ensure Doctrine\\ORM\\Configuration::setLazyGhostObjectEnabled(true) is called to enable them. (ProxyFactory.php:166 called by EntityManager.php:178, https://github.com/doctrine/orm/pull/10837/, package doctrine/orm)", + "count": 1 } -] \ No newline at end of file +] diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 7846507f86101..199887754e036 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -66,6 +66,7 @@ jobs: echo COLUMNS=120 >> $GITHUB_ENV echo PHPUNIT="$(pwd)/phpunit --exclude-group tty,benchmark,intl-data,integration" >> $GITHUB_ENV echo COMPOSER_UP='composer update --no-progress --ansi'$([[ "${{ matrix.mode }}" != low-deps ]] && echo ' --ignore-platform-req=php+') >> $GITHUB_ENV + echo SYMFONY_DEPRECATIONS_HELPER="baselineFile=$(pwd)/.github/deprecations-baseline.json" >> $GITHUB_ENV SYMFONY_VERSIONS=$(git ls-remote -q --heads | cut -f2 | grep -o '/[1-9][0-9]*\.[0-9].*' | sort -V) SYMFONY_VERSION=$(grep ' VERSION = ' src/Symfony/Component/HttpKernel/Kernel.php | cut -d "'" -f2 | cut -d '.' -f 1-2) diff --git a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php index b9597cfaed345..0de248b1efdf0 100644 --- a/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php +++ b/src/Symfony/Bridge/Doctrine/Test/DoctrineTestHelper.php @@ -24,6 +24,7 @@ use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; use Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator; use PHPUnit\Framework\TestCase; +use Symfony\Component\VarExporter\LazyGhostTrait; /** * Provides utility functions needed in tests. @@ -90,6 +91,10 @@ public static function createTestConfiguration() $config->setSchemaManagerFactory(new DefaultSchemaManagerFactory()); } + if (\PHP_VERSION_ID >= 80100 && method_exists(Configuration::class, 'setLazyGhostObjectEnabled') && trait_exists(LazyGhostTrait::class)) { + $config->setLazyGhostObjectEnabled(true); + } + return $config; } From e8a2e862dddd597cdc339d17832947e893e70b33 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 8 Aug 2023 13:21:07 +0200 Subject: [PATCH 14/30] change default doctrine DBAL provider to XML attribute --- .../FrameworkBundle/Resources/config/schema/symfony-1.0.xsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd index 857c3c57fb7f2..29f64dad9bed9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd @@ -290,7 +290,6 @@ - @@ -302,6 +301,7 @@ + From c85892cfac78c6126b09eac65f1b6d94ffec257d Mon Sep 17 00:00:00 2001 From: Bastien THOMAS Date: Mon, 7 Aug 2023 00:46:00 +0200 Subject: [PATCH 15/30] [Mailer] update Brevo SMTP host --- .../Bridge/Sendinblue/Transport/SendinblueSmtpTransport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueSmtpTransport.php b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueSmtpTransport.php index 85c05f49b6a3c..b0e90230a0fb4 100644 --- a/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueSmtpTransport.php +++ b/src/Symfony/Component/Mailer/Bridge/Sendinblue/Transport/SendinblueSmtpTransport.php @@ -22,7 +22,7 @@ final class SendinblueSmtpTransport extends EsmtpTransport { public function __construct(string $username, string $password, EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null) { - parent::__construct('smtp-relay.sendinblue.com', 465, true, $dispatcher, $logger); + parent::__construct('smtp-relay.brevo.com', 465, true, $dispatcher, $logger); $this->setUsername($username); $this->setPassword($password); From 33f515672d7aa578bb82a82c4f75020fea6b07a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Str=C3=B8m?= Date: Wed, 9 Aug 2023 19:16:27 +0200 Subject: [PATCH 16/30] Always return bool from messenger amqp conncetion nack --- .../Component/Messenger/Bridge/Amqp/Transport/Connection.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php index ece0c1716b69b..166031b3aea90 100644 --- a/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php +++ b/src/Symfony/Component/Messenger/Bridge/Amqp/Transport/Connection.php @@ -461,7 +461,7 @@ public function ack(\AMQPEnvelope $message, string $queueName): bool public function nack(\AMQPEnvelope $message, string $queueName, int $flags = \AMQP_NOPARAM): bool { - return $this->queue($queueName)->nack($message->getDeliveryTag(), $flags); + return $this->queue($queueName)->nack($message->getDeliveryTag(), $flags) ?? true; } public function setup(): void From 55d7e227cf430d51ae2801c5dec7d78ca9036074 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Thu, 10 Aug 2023 15:09:58 +0200 Subject: [PATCH 17/30] Remove me from CODEOWNERS Imho, this created more noise than being useful in GitHub notification management. --- .github/CODEOWNERS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 19e868793ac36..b9e28a90c6196 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -38,10 +38,10 @@ # Serializer /src/Symfony/Component/Serializer/ @dunglas # Security -/src/Symfony/Bridge/Doctrine/Security/ @wouterj @chalasr -/src/Symfony/Bundle/SecurityBundle/ @wouterj @chalasr -/src/Symfony/Component/Security/ @wouterj @chalasr -/src/Symfony/Component/Ldap/Security/ @wouterj @chalasr +/src/Symfony/Bridge/Doctrine/Security/ @chalasr +/src/Symfony/Bundle/SecurityBundle/ @chalasr +/src/Symfony/Component/Security/ @chalasr +/src/Symfony/Component/Ldap/Security/ @chalasr # TwigBundle /src/Symfony/Bundle/TwigBundle/ @yceruto # WebLink From d571a07662f8b5462ec1f895f6185752b5e3ea75 Mon Sep 17 00:00:00 2001 From: Zbigniew Malcherczyk <124783578+zbigniew-malcherczyk-tg@users.noreply.github.com> Date: Fri, 11 Aug 2023 16:45:12 +0200 Subject: [PATCH 18/30] [Messenger] BatchHandlerTrait - fix phpdoc typo --- src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php b/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php index be7124dd38893..539956ec8da6b 100644 --- a/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php +++ b/src/Symfony/Component/Messenger/Handler/BatchHandlerTrait.php @@ -66,7 +66,7 @@ private function shouldFlush(): bool /** * Completes the jobs in the list. * - * @list $jobs A list of pairs of messages and their corresponding acknowledgers + * @param list $jobs A list of pairs of messages and their corresponding acknowledgers */ private function process(array $jobs): void { From 28451b2951c04b74245470ffcb733ab7337317d8 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 12 Aug 2023 18:38:40 +0200 Subject: [PATCH 19/30] [HttpFoundation] Add a slightly more verbose comment about a warning on UploadedFile --- src/Symfony/Component/HttpFoundation/File/UploadedFile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php index fcc6299138eb7..1161556c4fea7 100644 --- a/src/Symfony/Component/HttpFoundation/File/UploadedFile.php +++ b/src/Symfony/Component/HttpFoundation/File/UploadedFile.php @@ -74,7 +74,7 @@ public function __construct(string $path, string $originalName, string $mimeType * Returns the original file name. * * It is extracted from the request from which the file has been uploaded. - * Then it should not be considered as a safe value. + * This should not be considered as a safe value to use for a file name on your servers. * * @return string */ @@ -87,7 +87,7 @@ public function getClientOriginalName() * Returns the original file extension. * * It is extracted from the original file name that was uploaded. - * Then it should not be considered as a safe value. + * This should not be considered as a safe value to use for a file name on your servers. * * @return string */ From ddc699a41292ce3dfb91fa790e9ad85060c836a0 Mon Sep 17 00:00:00 2001 From: "hubert.lenoir" Date: Tue, 8 Aug 2023 10:16:09 +0200 Subject: [PATCH 20/30] [DependencyInjection] fix dump xml with array/object/enum default value --- .../Compiler/AutowirePass.php | 7 ++-- .../Tests/Dumper/XmlDumperTest.php | 32 +++++++++++++++++++ .../Tests/Dumper/YamlDumperTest.php | 32 +++++++++++++++++++ .../FooClassWithDefaultArrayAttribute.php | 12 +++++++ .../FooClassWithDefaultEnumAttribute.php | 12 +++++++ .../FooClassWithDefaultObjectAttribute.php | 12 +++++++ .../xml/services_with_default_array.xml | 15 +++++++++ .../xml/services_with_default_enumeration.xml | 15 +++++++++ .../xml/services_with_default_object.xml | 15 +++++++++ .../yaml/services_with_default_array.yml | 23 +++++++++++++ .../services_with_default_enumeration.yml | 23 +++++++++++++ .../yaml/services_with_default_object.yml | 23 +++++++++++++ 12 files changed, 219 insertions(+), 2 deletions(-) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/FooClassWithDefaultArrayAttribute.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/FooClassWithDefaultEnumAttribute.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/FooClassWithDefaultObjectAttribute.php create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_array.xml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_enumeration.xml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_object.xml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_array.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_enumeration.yml create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_object.yml diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php index 845f09c116fe1..0e679d21826ed 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AutowirePass.php @@ -212,13 +212,16 @@ private function autowireCalls(\ReflectionClass $reflectionClass, bool $isRoot, unset($arguments[$j]); $arguments[$namedArguments[$j]] = $value; } - if ($namedArguments || !$value instanceof $this->defaultArgument) { + if (!$value instanceof $this->defaultArgument) { continue; } if (\PHP_VERSION_ID >= 80100 && (\is_array($value->value) ? $value->value : \is_object($value->value))) { - unset($arguments[$j]); $namedArguments = $value->names; + } + + if ($namedArguments) { + unset($arguments[$j]); } else { $arguments[$j] = $value->value; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 9e2547cc244e6..3011444f757e9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -17,11 +17,15 @@ use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; +use Symfony\Component\DependencyInjection\Compiler\AutowirePass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Dumper\XmlDumper; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultArrayAttribute; +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultEnumAttribute; +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultObjectAttribute; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithEnumAttribute; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument; @@ -287,6 +291,34 @@ public function testDumpHandlesEnumeration() $this->assertEquals(file_get_contents(self::$fixturesPath.'/xml/services_with_enumeration.xml'), $dumper->dump()); } + /** + * @requires PHP 8.1 + * + * @dataProvider provideDefaultClasses + */ + public function testDumpHandlesDefaultAttribute($class, $expectedFile) + { + $container = new ContainerBuilder(); + $container + ->register('foo', $class) + ->setPublic(true) + ->setAutowired(true) + ->setArguments([2 => true]); + + (new AutowirePass())->process($container); + + $dumper = new XmlDumper($container); + + $this->assertSame(file_get_contents(self::$fixturesPath.'/xml/'.$expectedFile), $dumper->dump()); + } + + public static function provideDefaultClasses() + { + yield [FooClassWithDefaultArrayAttribute::class, 'services_with_default_array.xml']; + yield [FooClassWithDefaultObjectAttribute::class, 'services_with_default_object.xml']; + yield [FooClassWithDefaultEnumAttribute::class, 'services_with_default_enumeration.xml']; + } + public function testDumpServiceWithAbstractArgument() { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php index 1bfd222ed1ac1..90376c15f1842 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php @@ -17,12 +17,16 @@ use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument; use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; +use Symfony\Component\DependencyInjection\Compiler\AutowirePass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Dumper\YamlDumper; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultArrayAttribute; +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultEnumAttribute; +use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultObjectAttribute; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithEnumAttribute; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooUnitEnum; use Symfony\Component\DependencyInjection\Tests\Fixtures\FooWithAbstractArgument; @@ -153,6 +157,34 @@ public function testDumpHandlesEnumeration() $this->assertEquals(file_get_contents(self::$fixturesPath.'/yaml/services_with_enumeration.yml'), $dumper->dump()); } + /** + * @requires PHP 8.1 + * + * @dataProvider provideDefaultClasses + */ + public function testDumpHandlesDefaultAttribute($class, $expectedFile) + { + $container = new ContainerBuilder(); + $container + ->register('foo', $class) + ->setPublic(true) + ->setAutowired(true) + ->setArguments([2 => true]); + + (new AutowirePass())->process($container); + + $dumper = new YamlDumper($container); + + $this->assertSame(file_get_contents(self::$fixturesPath.'/yaml/'.$expectedFile), $dumper->dump()); + } + + public static function provideDefaultClasses() + { + yield [FooClassWithDefaultArrayAttribute::class, 'services_with_default_array.yml']; + yield [FooClassWithDefaultObjectAttribute::class, 'services_with_default_object.yml']; + yield [FooClassWithDefaultEnumAttribute::class, 'services_with_default_enumeration.yml']; + } + public function testDumpServiceWithAbstractArgument() { $container = new ContainerBuilder(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/FooClassWithDefaultArrayAttribute.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/FooClassWithDefaultArrayAttribute.php new file mode 100644 index 0000000000000..49275212281f1 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/FooClassWithDefaultArrayAttribute.php @@ -0,0 +1,12 @@ + + + + + + true + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_enumeration.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_enumeration.xml new file mode 100644 index 0000000000000..5fc112c8bf5d4 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_enumeration.xml @@ -0,0 +1,15 @@ + + + + + + true + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_object.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_object.xml new file mode 100644 index 0000000000000..09dad58c36425 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_with_default_object.xml @@ -0,0 +1,15 @@ + + + + + + true + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_array.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_array.yml new file mode 100644 index 0000000000000..3349a92673f05 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_array.yml @@ -0,0 +1,23 @@ + +services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + public: true + synthetic: true + foo: + class: Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultArrayAttribute + public: true + autowire: true + arguments: { secondOptional: true } + Psr\Container\ContainerInterface: + alias: service_container + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + Symfony\Component\DependencyInjection\ContainerInterface: + alias: service_container + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_enumeration.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_enumeration.yml new file mode 100644 index 0000000000000..66113708ad2c8 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_enumeration.yml @@ -0,0 +1,23 @@ + +services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + public: true + synthetic: true + foo: + class: Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultEnumAttribute + public: true + autowire: true + arguments: { secondOptional: true } + Psr\Container\ContainerInterface: + alias: service_container + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + Symfony\Component\DependencyInjection\ContainerInterface: + alias: service_container + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_object.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_object.yml new file mode 100644 index 0000000000000..547f6919ff26c --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_with_default_object.yml @@ -0,0 +1,23 @@ + +services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + public: true + synthetic: true + foo: + class: Symfony\Component\DependencyInjection\Tests\Fixtures\FooClassWithDefaultObjectAttribute + public: true + autowire: true + arguments: { secondOptional: true } + Psr\Container\ContainerInterface: + alias: service_container + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. + Symfony\Component\DependencyInjection\ContainerInterface: + alias: service_container + deprecated: + package: symfony/dependency-injection + version: 5.1 + message: The "%alias_id%" autowiring alias is deprecated. Define it explicitly in your app if you want to keep using it. From a99b70741543e1db51044a4726b4cc8daaf5deb0 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Nahan <814683+macintoshplus@users.noreply.github.com> Date: Sat, 31 Dec 2022 21:26:59 +0100 Subject: [PATCH 21/30] Dump Valid constaints on debug command #46544 --- .../Validator/Command/DebugCommand.php | 29 +++ .../Tests/Command/DebugCommandTest.php | 177 +++++++++++------- .../Validator/Tests/Dummy/DummyClassOne.php | 7 + .../Validator/Tests/Dummy/DummyClassTwo.php | 7 + 4 files changed, 154 insertions(+), 66 deletions(-) diff --git a/src/Symfony/Component/Validator/Command/DebugCommand.php b/src/Symfony/Component/Validator/Command/DebugCommand.php index be2c3fe96337e..bd892c5ecb323 100644 --- a/src/Symfony/Component/Validator/Command/DebugCommand.php +++ b/src/Symfony/Component/Validator/Command/DebugCommand.php @@ -22,8 +22,12 @@ use Symfony\Component\Finder\Exception\DirectoryNotFoundException; use Symfony\Component\Finder\Finder; use Symfony\Component\Validator\Constraint; +use Symfony\Component\Validator\Mapping\AutoMappingStrategy; +use Symfony\Component\Validator\Mapping\CascadingStrategy; use Symfony\Component\Validator\Mapping\ClassMetadataInterface; use Symfony\Component\Validator\Mapping\Factory\MetadataFactoryInterface; +use Symfony\Component\Validator\Mapping\GenericMetadata; +use Symfony\Component\Validator\Mapping\TraversalStrategy; /** * A console command to debug Validators information. @@ -161,6 +165,31 @@ private function getPropertyData(ClassMetadataInterface $classMetadata, string $ $propertyMetadata = $classMetadata->getPropertyMetadata($constrainedProperty); foreach ($propertyMetadata as $metadata) { + $autoMapingStrategy = 'Not supported'; + if ($metadata instanceof GenericMetadata) { + switch ($metadata->getAutoMappingStrategy()) { + case AutoMappingStrategy::ENABLED: $autoMapingStrategy = 'Enabled'; break; + case AutoMappingStrategy::DISABLED: $autoMapingStrategy = 'Disabled'; break; + case AutoMappingStrategy::NONE: $autoMapingStrategy = 'None'; break; + } + } + $traversalStrategy = 'None'; + if (TraversalStrategy::TRAVERSE === $metadata->getTraversalStrategy()) { + $traversalStrategy = 'Traverse'; + } + if (TraversalStrategy::IMPLICIT === $metadata->getTraversalStrategy()) { + $traversalStrategy = 'Implicit'; + } + + $data[] = [ + 'class' => 'property options', + 'groups' => [], + 'options' => [ + 'cascadeStrategy' => CascadingStrategy::CASCADE === $metadata->getCascadingStrategy() ? 'Cascade' : 'None', + 'autoMappingStrategy' => $autoMapingStrategy, + 'traversalStrategy' => $traversalStrategy, + ], + ]; foreach ($metadata->getConstraints() as $constraint) { $data[] = [ 'class' => \get_class($constraint), diff --git a/src/Symfony/Component/Validator/Tests/Command/DebugCommandTest.php b/src/Symfony/Component/Validator/Tests/Command/DebugCommandTest.php index 87cfc68b89995..54dcb07cb08b0 100644 --- a/src/Symfony/Component/Validator/Tests/Command/DebugCommandTest.php +++ b/src/Symfony/Component/Validator/Tests/Command/DebugCommandTest.php @@ -37,28 +37,43 @@ public function testOutputWithClassArgument() Symfony\Component\Validator\Tests\Dummy\DummyClassOne ----------------------------------------------------- -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ -| Property | Name | Groups | Options | -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ -| - | Symfony\Component\Validator\Constraints\Expression | Default, DummyClassOne | [ | -| | | | "expression" => "1 + 1 = 2", | -| | | | "message" => "This value is not valid.", | -| | | | "payload" => null, | -| | | | "values" => [] | -| | | | ] | -| code | Symfony\Component\Validator\Constraints\NotBlank | Default, DummyClassOne | [ | -| | | | "allowNull" => false, | -| | | | "message" => "This value should not be blank.", | -| | | | "normalizer" => null, | -| | | | "payload" => null | -| | | | ] | -| email | Symfony\Component\Validator\Constraints\Email | Default, DummyClassOne | [ | -| | | | "message" => "This value is not a valid email address.", | -| | | | "mode" => null, | -| | | | "normalizer" => null, | -| | | | "payload" => null | -| | | | ] | -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ +| Property | Name | Groups | Options | ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ +| - | Symfony\Component\Validator\Constraints\Expression | Default, DummyClassOne | [ | +| | | | "expression" => "1 + 1 = 2", | +| | | | "message" => "This value is not valid.", | +| | | | "payload" => null, | +| | | | "values" => [] | +| | | | ] | +| code | property options | | [ | +| | | | "cascadeStrategy" => "None", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "None" | +| | | | ] | +| code | Symfony\Component\Validator\Constraints\NotBlank | Default, DummyClassOne | [ | +| | | | "allowNull" => false, | +| | | | "message" => "This value should not be blank.", | +| | | | "normalizer" => null, | +| | | | "payload" => null | +| | | | ] | +| email | property options | | [ | +| | | | "cascadeStrategy" => "None", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "None" | +| | | | ] | +| email | Symfony\Component\Validator\Constraints\Email | Default, DummyClassOne | [ | +| | | | "message" => "This value is not a valid email address.", | +| | | | "mode" => null, | +| | | | "normalizer" => null, | +| | | | "payload" => null | +| | | | ] | +| dummyClassTwo | property options | | [ | +| | | | "cascadeStrategy" => "Cascade", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "Implicit" | +| | | | ] | ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ TXT , $tester->getDisplay(true) @@ -77,54 +92,84 @@ public function testOutputWithPathArgument() Symfony\Component\Validator\Tests\Dummy\DummyClassOne ----------------------------------------------------- -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ -| Property | Name | Groups | Options | -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ -| - | Symfony\Component\Validator\Constraints\Expression | Default, DummyClassOne | [ | -| | | | "expression" => "1 + 1 = 2", | -| | | | "message" => "This value is not valid.", | -| | | | "payload" => null, | -| | | | "values" => [] | -| | | | ] | -| code | Symfony\Component\Validator\Constraints\NotBlank | Default, DummyClassOne | [ | -| | | | "allowNull" => false, | -| | | | "message" => "This value should not be blank.", | -| | | | "normalizer" => null, | -| | | | "payload" => null | -| | | | ] | -| email | Symfony\Component\Validator\Constraints\Email | Default, DummyClassOne | [ | -| | | | "message" => "This value is not a valid email address.", | -| | | | "mode" => null, | -| | | | "normalizer" => null, | -| | | | "payload" => null | -| | | | ] | -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ +| Property | Name | Groups | Options | ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ +| - | Symfony\Component\Validator\Constraints\Expression | Default, DummyClassOne | [ | +| | | | "expression" => "1 + 1 = 2", | +| | | | "message" => "This value is not valid.", | +| | | | "payload" => null, | +| | | | "values" => [] | +| | | | ] | +| code | property options | | [ | +| | | | "cascadeStrategy" => "None", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "None" | +| | | | ] | +| code | Symfony\Component\Validator\Constraints\NotBlank | Default, DummyClassOne | [ | +| | | | "allowNull" => false, | +| | | | "message" => "This value should not be blank.", | +| | | | "normalizer" => null, | +| | | | "payload" => null | +| | | | ] | +| email | property options | | [ | +| | | | "cascadeStrategy" => "None", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "None" | +| | | | ] | +| email | Symfony\Component\Validator\Constraints\Email | Default, DummyClassOne | [ | +| | | | "message" => "This value is not a valid email address.", | +| | | | "mode" => null, | +| | | | "normalizer" => null, | +| | | | "payload" => null | +| | | | ] | +| dummyClassTwo | property options | | [ | +| | | | "cascadeStrategy" => "Cascade", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "Implicit" | +| | | | ] | ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ Symfony\Component\Validator\Tests\Dummy\DummyClassTwo ----------------------------------------------------- -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ -| Property | Name | Groups | Options | -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ -| - | Symfony\Component\Validator\Constraints\Expression | Default, DummyClassTwo | [ | -| | | | "expression" => "1 + 1 = 2", | -| | | | "message" => "This value is not valid.", | -| | | | "payload" => null, | -| | | | "values" => [] | -| | | | ] | -| code | Symfony\Component\Validator\Constraints\NotBlank | Default, DummyClassTwo | [ | -| | | | "allowNull" => false, | -| | | | "message" => "This value should not be blank.", | -| | | | "normalizer" => null, | -| | | | "payload" => null | -| | | | ] | -| email | Symfony\Component\Validator\Constraints\Email | Default, DummyClassTwo | [ | -| | | | "message" => "This value is not a valid email address.", | -| | | | "mode" => null, | -| | | | "normalizer" => null, | -| | | | "payload" => null | -| | | | ] | -+----------+----------------------------------------------------+------------------------+------------------------------------------------------------+ ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ +| Property | Name | Groups | Options | ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ +| - | Symfony\Component\Validator\Constraints\Expression | Default, DummyClassTwo | [ | +| | | | "expression" => "1 + 1 = 2", | +| | | | "message" => "This value is not valid.", | +| | | | "payload" => null, | +| | | | "values" => [] | +| | | | ] | +| code | property options | | [ | +| | | | "cascadeStrategy" => "None", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "None" | +| | | | ] | +| code | Symfony\Component\Validator\Constraints\NotBlank | Default, DummyClassTwo | [ | +| | | | "allowNull" => false, | +| | | | "message" => "This value should not be blank.", | +| | | | "normalizer" => null, | +| | | | "payload" => null | +| | | | ] | +| email | property options | | [ | +| | | | "cascadeStrategy" => "None", | +| | | | "autoMappingStrategy" => "None", | +| | | | "traversalStrategy" => "None" | +| | | | ] | +| email | Symfony\Component\Validator\Constraints\Email | Default, DummyClassTwo | [ | +| | | | "message" => "This value is not a valid email address.", | +| | | | "mode" => null, | +| | | | "normalizer" => null, | +| | | | "payload" => null | +| | | | ] | +| dummyClassOne | property options | | [ | +| | | | "cascadeStrategy" => "None", | +| | | | "autoMappingStrategy" => "Disabled", | +| | | | "traversalStrategy" => "None" | +| | | | ] | ++---------------+----------------------------------------------------+------------------------+------------------------------------------------------------+ TXT , $tester->getDisplay(true) diff --git a/src/Symfony/Component/Validator/Tests/Dummy/DummyClassOne.php b/src/Symfony/Component/Validator/Tests/Dummy/DummyClassOne.php index 92def37e0e9fe..169034fefceb0 100644 --- a/src/Symfony/Component/Validator/Tests/Dummy/DummyClassOne.php +++ b/src/Symfony/Component/Validator/Tests/Dummy/DummyClassOne.php @@ -31,4 +31,11 @@ class DummyClassOne * @Assert\Email */ public $email; + + /** + * @var DummyClassTwo|null + * + * @Assert\Valid() + */ + public $dummyClassTwo; } diff --git a/src/Symfony/Component/Validator/Tests/Dummy/DummyClassTwo.php b/src/Symfony/Component/Validator/Tests/Dummy/DummyClassTwo.php index cd136a9dd301e..01bc5fed873ec 100644 --- a/src/Symfony/Component/Validator/Tests/Dummy/DummyClassTwo.php +++ b/src/Symfony/Component/Validator/Tests/Dummy/DummyClassTwo.php @@ -31,4 +31,11 @@ class DummyClassTwo * @Assert\Email */ public $email; + + /** + * @var DummyClassOne|null + * + * @Assert\DisableAutoMapping() + */ + public $dummyClassOne; } From 9c90ac8d5d4aa3a921bc9327b6c6821ccadfad28 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 14 Aug 2023 18:40:48 +0200 Subject: [PATCH 22/30] [GHA] Disable composer cache-vcs-dir --- .github/composer-config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/composer-config.json b/.github/composer-config.json index 2bdec1a826251..8fa24e783b4e7 100644 --- a/.github/composer-config.json +++ b/.github/composer-config.json @@ -1,5 +1,6 @@ { "config": { + "cache-vcs-dir": "/dev/null", "platform-check": false, "preferred-install": { "symfony/form": "source", From 12beb97513ce1ed2d5060b97bccfe5e008c20bfc Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 16 Aug 2023 09:35:26 +0200 Subject: [PATCH 23/30] Psalm: Ignore UnusedClass errors --- psalm.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/psalm.xml b/psalm.xml index 4d9f6743bd3b8..0f04bcf070170 100644 --- a/psalm.xml +++ b/psalm.xml @@ -36,6 +36,15 @@ + + + + + +