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 8e359569f8ce..8a0ff91e8abc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -55,17 +55,17 @@ public function templateAction(string $template, int $maxAge = null, int $shared throw new \LogicException('You can not use the TemplateController if the Templating Component or the Twig Bundle are not available.'); } - if ($maxAge) { + if (null !== $maxAge) { $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/Console/Style/SymfonyStyle.php b/src/Symfony/Component/Console/Style/SymfonyStyle.php index 4f11b207401e..5efe2d4b142e 100644 --- a/src/Symfony/Component/Console/Style/SymfonyStyle.php +++ b/src/Symfony/Component/Console/Style/SymfonyStyle.php @@ -295,7 +295,7 @@ public function choice($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 13d3bc70a8a8..b11fa38f99d6 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(); } @@ -473,7 +465,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/Yaml/Inline.php b/src/Symfony/Component/Yaml/Inline.php index dbec60f9551c..02f48882d803 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 */