diff --git a/.github/patch-types.php b/.github/patch-types.php index 949b858c0f1a..d9b1ed98f2bf 100644 --- a/.github/patch-types.php +++ b/.github/patch-types.php @@ -18,6 +18,8 @@ case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'): case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'): case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'): + case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'): + case false !== strpos($file, '/src/Symfony/Component/Debug/Tests/Fixtures/'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'): case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'): diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index c5dcb2b0433a..05e886506d38 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -211,6 +211,10 @@ public function startTest($test) } } + if (!$test->getTestResultObject()) { + return; + } + $annotations = Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false)); if (isset($annotations['class']['expectedDeprecation'])) { diff --git a/src/Symfony/Bridge/PhpUnit/Tests/OnlyExpectingDeprecationSkippedTest.php b/src/Symfony/Bridge/PhpUnit/Tests/OnlyExpectingDeprecationSkippedTest.php new file mode 100644 index 000000000000..593e0b4e1434 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/OnlyExpectingDeprecationSkippedTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bridge\PhpUnit\Tests; + +use PHPUnit\Framework\TestCase; + +/** + * This test is meant to be skipped. + * + * @requires extension ext-dummy + */ +final class OnlyExpectingDeprecationSkippedTest extends TestCase +{ + /** + * Do not remove this test in the next major versions. + * + * @group legacy + * + * @expectedDeprecation unreachable + */ + public function testExpectingOnlyDeprecations() + { + $this->fail('should never be ran.'); + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 0fff40bac58e..fded9ced6294 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -50,13 +50,13 @@ public function templateAction(string $template, int $maxAge = null, int $shared $response->setMaxAge($maxAge); } - if ($sharedAge) { + if (null !== $sharedAge) { $response->setSharedMaxAge($sharedAge); } if ($private) { $response->setPrivate(); - } elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) { + } elseif (false === $private || (null === $private && (null !== $maxAge || null !== $sharedAge))) { $response->setPublic(); } diff --git a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php index a547fb461236..cce387ccfe3c 100644 --- a/src/Symfony/Component/Config/Resource/ClassExistenceResource.php +++ b/src/Symfony/Component/Config/Resource/ClassExistenceResource.php @@ -94,6 +94,8 @@ public function isFresh(int $timestamp): bool } } catch (\Throwable $e) { $exists[1] = $e->getMessage(); + + throw $e; } finally { self::$autoloadedClass = $autoloadedClass; if (!--self::$autoloadLevel) { diff --git a/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php b/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php new file mode 100644 index 000000000000..6bb221382483 --- /dev/null +++ b/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php @@ -0,0 +1,7 @@ +assertFalse($res->isFresh(0)); } + + public function testParseError() + { + $this->expectException('ParseError'); + + $res = new ClassExistenceResource(ParseError::class, false); + $res->isFresh(0); + } } diff --git a/src/Symfony/Component/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index eea624e05da1..271752f1444e 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -290,7 +290,7 @@ public function choice(string $question, array $choices, $default = null) { if (null !== $default) { $values = array_flip($choices); - $default = $values[$default]; + $default = isset($values[$default]) ? $values[$default] : $default; } return $this->askQuestion(new ChoiceQuestion($question, $choices, $default)); diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index e8a63a24782f..5a3cd6c7e4d0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -1097,7 +1097,7 @@ public function testThrowsExceptionWhenSetServiceOnACompiledContainer() $container->set('a', new \stdClass()); } - public function testThrowsExceptionWhenAddServiceOnACompiledContainer() + public function testNoExceptionWhenAddServiceOnACompiledContainer() { $container = new ContainerBuilder(); $container->compile(); diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 8205923b76f1..6d8cced74fa4 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -89,10 +89,6 @@ public function getValues() { $values = []; foreach ($this->fields->all() as $name => $field) { - if ($field->isDisabled()) { - continue; - } - if (!$field instanceof Field\FileFormField && $field->hasValue()) { $values[$name] = $field->getValue(); } @@ -115,10 +111,6 @@ public function getFiles() $files = []; foreach ($this->fields->all() as $name => $field) { - if ($field->isDisabled()) { - continue; - } - if ($field instanceof Field\FileFormField) { $files[$name] = $field->getValue(); } @@ -467,7 +459,7 @@ private function initialize() private function addField(\DOMElement $node) { - if (!$node->hasAttribute('name') || !$node->getAttribute('name')) { + if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) { return; } diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index e02c8f911373..9975b91afe42 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -158,12 +158,12 @@ public function testConstructorHandlesFormValues() public function testMultiValuedFields() { $form = $this->createForm('
- - - - - - + + + + + +
'); @@ -226,10 +226,10 @@ public function provideInitializeValues() [], ], [ - 'takes into account disabled input fields', + 'skips disabled input fields', ' ', - ['foo' => ['InputFormField', 'foo']], + [], ], [ 'appends the submitted button value', diff --git a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php index fb9228b10610..3c3a548b3057 100644 --- a/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php +++ b/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php @@ -114,7 +114,7 @@ private function collectOnClient(TraceableHttpClient $client): array unset($info['filetime'], $info['http_code'], $info['ssl_verify_result'], $info['content_type']); - if ($trace['method'] === $info['http_method']) { + if (($info['http_method'] ?? null) === $trace['method']) { unset($info['http_method']); } diff --git a/src/Symfony/Component/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index e5e0f2a4bd5b..de153c34f4bc 100644 --- a/src/Symfony/Component/Yaml/Inline.php +++ b/src/Symfony/Component/Yaml/Inline.php @@ -589,6 +589,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere return substr($scalar, 2); case 0 === strpos($scalar, '!php/object'): if (self::$objectSupport) { + if (!isset($scalar[12])) { + return false; + } + return unserialize(self::parseScalar(substr($scalar, 12))); } @@ -599,6 +603,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere return null; case 0 === strpos($scalar, '!php/const'): if (self::$constantSupport) { + if (!isset($scalar[11])) { + return ''; + } + $i = 0; if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) { return \constant($const); diff --git a/src/Symfony/Component/Yaml/Tests/InlineTest.php b/src/Symfony/Component/Yaml/Tests/InlineTest.php index 0f46f75ee72a..79c1df6d7614 100644 --- a/src/Symfony/Component/Yaml/Tests/InlineTest.php +++ b/src/Symfony/Component/Yaml/Tests/InlineTest.php @@ -738,6 +738,49 @@ public function getTestsForOctalNumbers() ]; } + /** + * @dataProvider phpObjectTagWithEmptyValueProvider + */ + public function testPhpObjectWithEmptyValue($expected, $value) + { + $this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT)); + } + + public function phpObjectTagWithEmptyValueProvider() + { + return [ + [false, '!php/object'], + [false, '!php/object '], + [false, '!php/object '], + [[false], '[!php/object]'], + [[false], '[!php/object ]'], + [[false, 'foo'], '[!php/object , foo]'], + ]; + } + + /** + * @dataProvider phpConstTagWithEmptyValueProvider + */ + public function testPhpConstTagWithEmptyValue($expected, $value) + { + $this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT)); + } + + public function phpConstTagWithEmptyValueProvider() + { + return [ + ['', '!php/const'], + ['', '!php/const '], + ['', '!php/const '], + [[''], '[!php/const]'], + [[''], '[!php/const ]'], + [['', 'foo'], '[!php/const , foo]'], + [['' => 'foo'], '{!php/const: foo}'], + [['' => 'foo'], '{!php/const : foo}'], + [['' => 'foo', 'bar' => 'ccc'], '{!php/const : foo, bar: ccc}'], + ]; + } + /** * @dataProvider unquotedExclamationMarkThrowsProvider */