8000 Merge branch '5.0' · symfony/symfony@12ca646 · GitHub
[go: up one dir, main page]

Skip to content

Commit 12ca646

Browse files
committed
Merge branch '5.0'
* 5.0: [Phpunit] Fix running skipped tests expecting only deprecations Fix merge [Config] dont catch instances of Error [HttpClient] fix HttpClientDataCollector when handling canceled responses [FrameworkBundle] remove mention of the old Controller class [DependencyInjection] #35505 Fix typo in test name [Yaml][Inline] Fail properly on empty object tag and empty const tag Check non-null type for numeric type Check value isset to avoid PHP notice bug #28179 [DomCrawler] Skip disabled fields processing in Form
2 parents 5da9cf3 + 5da1bcf commit 12ca646

File tree

17 files changed

+125
-29
lines changed

17 files changed

+125
-29
lines changed

.github/patch-types.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
1919
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'):
2020
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
21+
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'):
22+
case false !== strpos($file, '/src/Symfony/Component/Debug/Tests/Fixtures/'):
2123
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
2224
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
2325
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):

src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,10 @@ public function startTest($test)
211211
}
212212
}
213213

214+
if (!$test->getTestResultObject()) {
215+
return;
216+
}
217+
214218
$annotations = Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
215219

216220
if (isset($annotations['class']['expectedDeprecation'])) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Tests;
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* This test is meant to be skipped.
18+
*
19+
* @requires extension ext-dummy
20+
*/
21+
final class OnlyExpectingDeprecationSkippedTest extends TestCase
22+
{
23+
/**
24+
* Do not remove this test in the next major versions.
25+
*
26+
* @group legacy
27+
*
28+
* @expectedDeprecation unreachable
29+
*/
30+
public function testExpectingOnlyDeprecations()
31+
{
32+
$this->fail('should never be ran.');
33+
}
34+
}

src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ public function templateAction(string $template, int $maxAge = null, int $shared
5151
$response->setMaxAge($maxAge);
5252
}
5353

54-
if ($sharedAge) {
54+
if (null !== $sharedAge) {
5555
$response->setSharedMaxAge($sharedAge);
5656
}
5757

5858
if ($private) {
5959
$response->setPrivate();
60-
} elseif (false === $private || (null === $private && ($maxAge || $sharedAge))) {
60+
} elseif (false === $private || (null === $private && (null !== $maxAge || null !== $sharedAge))) {
6161
$response->setPublic();
6262
}
6363

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,6 @@ public function load(array $configs, ContainerBuilder $container)
410410
->addTag('controller.argument_value_resolver');
411411
$container->registerForAutoconfiguration(AbstractController::class)
412412
->addTag('controller.service_arguments');
413-
$container->registerForAutoconfiguration('Symfony\Bundle\FrameworkBundle\Controller\Controller')
414-
->addTag('controller.service_arguments');
415413
$container->registerForAutoconfiguration(DataCollectorInterface::class)
416414
->addTag('data_collector');
417415
$container->registerForAutoconfiguration(FormTypeInterface::class)

src/Symfony/Component/Config/Resource/ClassExistenceResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public function isFresh(int $timestamp): bool
9494
}
9595
} catch (\Throwable $e) {
9696
$exists[1] = $e->getMessage();
97+
98+
throw $e;
9799
} finally {
98100
self::$autoloadedClass = $autoloadedClass;
99101
if (!--self::$autoloadLevel) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
namespace Symfony\Component\Config\Tests\Fixtures;
4+
5+
class ParseError
6+
{
7+
// missing closing bracket

src/Symfony/Component/Config/Tests/Resource/ClassExistenceResourceTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\Config\Resource\ClassExistenceResource;
1616
use Symfony\Component\Config\Tests\Fixtures\BadFileName;
1717
use Symfony\Component\Config\Tests\Fixtures\BadParent;
18+
use Symfony\Component\Config\Tests\Fixtures\ParseError;
1819
use Symfony\Component\Config\Tests\Fixtures\Resource\ConditionalClass;
1920

2021
class ClassExistenceResourceTest extends TestCase
@@ -115,4 +116,12 @@ public function testConditionalClass()
115116

116117
$this->assertFalse($res->isFresh(0));
117118
}
119+
120+
public function testParseError()
121+
{
122+
$this->expectException('ParseError');
123+
124+
$res = new ClassExistenceResource(ParseError::class, false);
125+
$res->isFresh(0);
126+
}
118127
}

src/Symfony/Component/Console/Style/SymfonyStyle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function choice(string $question, array $choices, $default = null)
290290
{
291291
if (null !== $default) {
292292
$values = array_flip($choices);
293-
$default = $values[$default];
293+
$default = isset($values[$default]) ? $values[$default] : $default;
294294
}
295295

296296
return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));

src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ public function testThrowsExceptionWhenSetServiceOnACompiledContainer()
10971097
$container->set('a', new \stdClass());
10981098
}
10991099

1100-
public function testThrowsExceptionWhenAddServiceOnACompiledContainer()
1100+
public function testNoExceptionWhenAddServiceOnACompiledContainer()
11011101
{
11021102
$container = new ContainerBuilder();
11031103
$container->compile();

src/Symfony/Component/DomCrawler/Form.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@ public function getValues()
8989
{
9090
$values = [];
9191
foreach ($this->fields->all() as $name => $field) {
92-
if ($field->isDisabled()) {
93-
continue;
94-
}
95-
9692
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
9793
$values[$name] = $field->getValue();
9894
}
@@ -115,10 +111,6 @@ public function getFiles()
115111
$files = [];
116112

117113
foreach ($this->fields->all() as $name => $field) {
118-
if ($field->isDisabled()) {
119-
continue;
120-
}
121-
122114
if ($field instanceof Field\FileFormField) {
123115
$files[$name] = $field->getValue();
124116
}
@@ -467,7 +459,7 @@ private function initialize()
467459

468460
private function addField(\DOMElement $node)
469461
{
470-
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
462+
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
471463
return;
472464
}
473465

src/Symfony/Component/DomCrawler/Tests/FormTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ public function testConstructorHandlesFormValues()
158158
public function testMultiValuedFields()
159159
{
160160
$form = $this->createForm('<form>
161-
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
162-
<input type="text" name="foo" value="foo" disabled="disabled" />
163-
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
164-
<input type="text" name="foo[]" value="foo" disabled="disabled" />
165-
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
166-
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
161+
<input type="text" name="foo[4]" value="foo" />
162+
<input type="text" name="foo" value="foo" />
163+
<input type="text" name="foo[2]" value="foo" />
164+
<input type="text" name="foo[]" value="foo" />
165+
<input type="text" name="bar[foo][]" value="foo" />
166+
<input type="text" name="bar[foo][foobar]" value="foo" />
167167
<input type="submit" />
168168
</form>
169169
');
@@ -226,10 +226,10 @@ public function provideInitializeValues()
226226
[],
227227
],
228228
[
229-
'takes into account disabled input fields',
229+
'skips disabled input fields',
230230
'<input type="text" name="foo" value="foo" disabled="disabled" />
231231
<input type="submit" />',
232-
['foo' => ['InputFormField', 'foo']],
232+
[],
233233
],
234234
[
235235
'appends the submitted button value',

src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private function collectOnClient(TraceableHttpClient $client): array
115115

116116
unset($info['filetime'], $info['http_code'], $info['ssl_verify_result'], $info['content_type']);
117117

118-
if ($trace['method'] === $info['http_method']) {
118+
if (($info['http_method'] ?? null) === $trace['method']) {
119119
unset($info['http_method']);
120120
}
121121

src/Symfony/Component/HttpKernel/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPass.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ public function process(ContainerBuilder $container)
5151
}
5252
}
5353
if (!$reason) {
54-
// Deprecated since Symfony 4.1. See Symfony\Component\HttpKernel\Controller\ContainerControllerResolver
55-
$controllers[$id.':'.$action] = $argumentRef;
56-
5754
if ('__invoke' === $action) {
5855
$controllers[$id] = $argumentRef;
5956
}

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RemoveEmptyControllerArgumentLocatorsPassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testProcess()
4949

5050
$controllers = $container->getDefinition((string) $resolver->getArgument(0))->getArgument(0);
5151

52-
$this->assertSame(['c1::fooAction', 'c1:fooAction'], array_keys($controllers));
52+
$this->assertSame(['c1::fooAction'], array_keys($controllers));
5353
$this->assertSame(['bar'], array_keys($container->getDefinition((string) $controllers['c1::fooAction']->getValues()[0])->getArgument(0)));
5454

5555
$expectedLog = [
@@ -73,7 +73,7 @@ public function testInvoke()
7373
(new RemoveEmptyControllerArgumentLocatorsPass())->process($container);
7474

7575
$this->assertEquals(
76-
['invokable::__invoke', 10000 'invokable:__invoke', 'invokable'],
76+
['invokable::__invoke', 'invokable'],
7777
array_keys($container->getDefinition((string) $resolver->getArgument(0))->getArgument(0))
7878
);
7979
}

src/Symfony/Component/Yaml/Inline.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
589589
return substr($scalar, 2);
590590
case 0 === strpos($scalar, '!php/object'):
591591
if (self::$objectSupport) {
592+
if (!isset($scalar[12])) {
593+
return false;
594+
}
595+
592596
return unserialize(self::parseScalar(substr($scalar, 12)));
593597
}
594598

@@ -599,6 +603,10 @@ private static function evaluateScalar(string $scalar, int $flags, array $refere
599603
return null;
600604
case 0 === strpos($scalar, '!php/const'):
601605
if (self::$constantSupport) {
606+
if (!isset($scalar[11])) {
607+
return '';
608+
}
609+
602610
$i = 0;
603611
if (\defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
604612
return \constant($const);

src/Symfony/Component/Yaml/Tests/InlineTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,49 @@ public function getTestsForOctalNumbers()
738738
];
739739
}
740740

741+
/**
742+
* @dataProvider phpObjectTagWithEmptyValueProvider
743+
*/
744+
public function testPhpObjectWithEmptyValue($expected, $value)
745+
{
746+
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_OBJECT));
747+
}
748+
749+
public function phpObjectTagWithEmptyValueProvider()
750+
{
751+
return [
752+
[false, '!php/object'],
753+
[false, '!php/object '],
754+
[false, '!php/object '],
755+
[[false], '[!php/object]'],
756+
[[false], '[!php/object ]'],
757+
[[false, 'foo'], '[!php/object , foo]'],
758+
];
759+
}
760+
761+
/**
762+
* @dataProvider phpConstTagWithEmptyValueProvider
763+
*/
764+
public function testPhpConstTagWithEmptyValue($expected, $value)
765+
{
766+
$this->assertSame($expected, Inline::parse($value, Yaml::PARSE_CONSTANT));
767+
}
768+
769+
public function phpConstTagWithEmptyValueProvider()
770+
{
771+
return [
772+
['', '!php/const'],
773+
['', '!php/const '],
774+
['', '!php/const '],
775+
[[''], '[!php/const]'],
776+
[[''], '[!php/const ]'],
777+
[['', 'foo'], '[!php/const , foo]'],
778+
[['' => 'foo'], '{!php/const: foo}'],
779+
[['' => 'foo'], '{!php/const : foo}'],
780+
[['' => 'foo', 'bar' => 'ccc'], '{!php/const : foo, bar: ccc}'],
781+
];
782+
}
783+
741784
/**
742785
* @dataProvider unquotedExclamationMarkThrowsProvider
743786
*/

0 commit comments

Comments
 (0)
0