Skip to content

Commit cd12afe

Browse files
committed
Merge branch '5.3' into 5.4
2 parents 6aa60fa + 858bc28 commit cd12afe

File tree

19 files changed

+82
-57
lines changed

19 files changed

+82
-57
lines changed

src/Symfony/Component/Config/Definition/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function getDefaultValue()
184184
public function addChild(NodeInterface $node)
185185
{
186186
$name = $node->getName();
187-
if (!\strlen($name)) {
187+
if ('' === $name) {
188188
throw new \InvalidArgumentException('Child nodes must be named.');
189189
}
190190
if (isset($this->children[$name])) {

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ private function mostRecentlyEnteredValue(string $entered): string
379379
}
380380

381381
$choices = explode(',', $entered);
382-
if (\strlen($lastChoice = trim($choices[\count($choices) - 1])) > 0) {
382+
if ('' !== $lastChoice = trim($choices[\count($choices) - 1])) {
383383
return $lastChoice;
384384
}
385385

src/Symfony/Component/Console/Input/StringInput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ private function tokenize(string $input): array
5050
while ($cursor < $length) {
5151
if (preg_match('/\s+/A', $input, $match, 0, $cursor)) {
5252
} elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, 0, $cursor)) {
53-
$tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, \strlen($match[3]) - 2)));
53+
$tokens[] = $match[1].$match[2].stripcslashes(str_replace(['"\'', '\'"', '\'\'', '""'], '', substr($match[3], 1, -1)));
5454
} elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, 0, $cursor)) {
55-
$tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
55+
$tokens[] = stripcslashes(substr($match[0], 1, -1));
5656
} elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, 0, $cursor)) {
5757
$tokens[] = stripcslashes($match[1]);
5858
} else {

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ public function appendToFile(string $filename, $content)
714714

715715
private function toIterable($files): iterable
716716
{
717-
return \is_array($files) || $files instanceof \Traversable ? $files : [$files];
717+
return is_iterable($files) ? $files : [$files];
718718
}
719719

720720
/**

src/Symfony/Component/Finder/Finder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ public function append(iterable $iterator)
654654
$this->iterators[] = $iterator->getIterator();
655655
} elseif ($iterator instanceof \Iterator) {
656656
$this->iterators[] = $iterator;
657-
} elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
657+
} elseif (is_iterable($iterator)) {
658658
$it = new \ArrayIterator();
659659
foreach ($iterator as $file) {
660660
$file = $file instanceof \SplFileInfo ? $file : new \SplFileInfo($file);

src/Symfony/Component/Finder/Tests/Comparator/ComparatorTest.php

Lines changed: 47 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,20 @@ class ComparatorTest extends TestCase
1818
{
1919
public function testGetSetOperator()
2020
{
21-
$comparator = new Comparator();
22-
try {
23-
$comparator->setOperator('foo');
24-
$this->fail('->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
25-
} catch (\Exception $e) {
26-
$this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setOperator() throws an \InvalidArgumentException if the operator is not valid.');
27-
}
28-
2921
$comparator = new Comparator();
3022
$comparator->setOperator('>');
3123
$this->assertEquals('>', $comparator->getOperator(), '->getOperator() returns the current operator');
3224
}
3325

26+
public function testInvalidOperator()
27+
{
28+
$comparator = new Comparator();
29+
30+
$this->expectException(\InvalidArgumentException::class);
31+
$this->expectExceptionMessage('Invalid operator "foo".');
32+
$comparator->setOperator('foo');
33+
}
34+
3435
public function testGetSetTarget()
3536
{
3637
$comparator = new Comparator();
@@ -39,27 +40,55 @@ public function testGetSetTarget()
3940
}
4041

4142
/**
42-
* @dataProvider getTestData
43+
* @dataProvider provideMatches
4344
*/
44-
public function testTest($operator, $target, $match, $noMatch)
45+
public function testTestSucceeds(string $operator, string $target, string $testedValue)
4546
{
4647
$c = new Comparator();
4748
$c->setOperator($operator);
4849
$c->setTarget($target);
4950

50-
foreach ($match as $m) {
51-
$this->assertTrue($c->test($m), '->test() tests a string against the expression');
52-
}
51+
$this->assertTrue($c->test($testedValue));
52+
}
53+
54+
public function provideMatches(): array
55+
{
56+
return [
57+
['<', '1000', '500'],
58+
['<', '1000', '999'],
59+
['<=', '1000', '999'],
60+
['!=', '1000', '999'],
61+
['<=', '1000', '1000'],
62+
['==', '1000', '1000'],
63+
['>=', '1000', '1000'],
64+
['>=', '1000', '1001'],
65+
['>', '1000', '1001'],
66+
['>', '1000', '5000'],
67+
];
68+
}
69+
70+
/**
71+
* @dataProvider provideNonMatches
72+
*/
73+
public function testTestFails(string $operator, string $target, string $testedValue)
74+
{
75+
$c = new Comparator();
76+
$c->setOperator($operator);
77+
$c->setTarget($target);
5378

54-
foreach ($noMatch as $m) {
55-
$this->assertFalse($c->test($m), '->test() tests a string against the expression');
56-
}
79+
$this->assertFalse($c->test($testedValue));
5780
}
5881

59-
public function getTestData()
82+
public function provideNonMatches(): array
6083
{
6184
return [
62-
['<', '1000', ['500', '999'], ['1000', '1500']],
85+
['>', '1000', '500'],
86+
['>=', '1000', '500'],
87+
['>', '1000', '1000'],
88+
['!=', '1000', '1000'],
89+
['<', '1000', '1000'],
90+
['<', '1000', '1500'],
91+
['<=', '1000', '1500'],
6392
];
6493
}
6594
}

src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,8 @@ public function getDecoratedFactory()
8484
/**
8585
* {@inheritdoc}
8686
*
87-
* @param callable|Cache\ChoiceValue|null $value The callable or static option for
88-
* generating the choice values
89-
* @param callable|Cache\ChoiceFilter|null $filter The callable or static option for
90-
* filtering the choices
87+
* @param mixed $value
88+
* @param mixed $filter
9189
*/
9290
public function createListFromChoices(iterable $choices, $value = null/*, $filter = null*/)
9391
{
@@ -127,12 +125,8 @@ public function createListFromChoices(iterable $choices, $value = null/*, $filte
127125
/**
128126
* {@inheritdoc}
129127
*
130-
* @param ChoiceLoaderInterface|Cache\ChoiceLoader $loader The loader or static loader to load
131-
* the choices lazily
132-
* @param callable|Cache\ChoiceValue|null $value The callable or static option for
133-
* generating the choice values
134-
* @param callable|Cache\ChoiceFilter|null $filter The callable or static option for
135-
* filtering the choices
128+
* @param mixed $value
129+
* @param mixed $filter
136130
*/
137131
public function createListFromLoader(ChoiceLoaderInterface $loader, $value = null/*, $filter = null*/)
138132
{
@@ -174,12 +168,12 @@ public function createListFromLoader(ChoiceLoaderInterface $loader, $value = nul
174168
/**
175169
* {@inheritdoc}
176170
*
177-
* @param array|callable|Cache\PreferredChoice|null $preferredChoices The preferred choices
178-
* @param callable|false|Cache\ChoiceLabel|null $label The option or static option generating the choice labels
179-
* @param callable|Cache\ChoiceFieldName|null $index The option or static option generating the view indices
180-
* @param callable|Cache\GroupBy|null $groupBy The option or static option generating the group names
181-
* @param array|callable|Cache\ChoiceAttr|null $attr The option or static option generating the HTML attributes
182-
* @param array|callable|Cache\ChoiceTranslationParameters $labelTranslationParameters The parameters used to translate the choice labels
171+
* @param mixed $preferredChoices
172+
* @param mixed $label
173+
* @param mixed $index
174+
* @param mixed $groupBy
175+
* @param mixed $attr
176+
* @param mixed $labelTranslationParameters
183177
*/
184178
public function createView(ChoiceListInterface $list, $preferredChoices = null, $label = null, $index = null, $groupBy = null, $attr = null/*, $labelTranslationParameters = []*/)
185179
{

src/Symfony/Component/Form/Extension/Core/DataAccessor/PropertyPathAccessor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException;
1919
use Symfony\Component\PropertyAccess\PropertyAccess;
2020
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
21+
use Symfony\Component\PropertyAccess\PropertyPathInterface;
2122

2223
/**
2324
* Writes and reads values to/from an object or array using property path.
@@ -84,7 +85,7 @@ public function isWritable($data, FormInterface $form): bool
8485
return null !== $form->getPropertyPath();
8586
}
8687

87-
private function getPropertyValue($data, $propertyPath)
88+
private function getPropertyValue($data, PropertyPathInterface $propertyPath)
8889
{
8990
try {
9091
return $this->propertyAccessor->getValue($data, $propertyPath);

src/Symfony/Component/Form/Tests/VersionAwareTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ trait VersionAwareTest
1515
{
1616
protected static $supportedFeatureSetVersion = 404;
1717

18-
/**
19-
* @param int $requiredFeatureSetVersion
20-
*/
21-
protected function requiresFeatureSet($requiredFeatureSetVersion)
18+
protected function requiresFeatureSet(int $requiredFeatureSetVersion)
2219
{
2320
if ($requiredFeatureSetVersion > static::$supportedFeatureSetVersion) {
2421
$this->markTestSkipped(sprintf('Test requires features from symfony/form %.2f but only version %.2f is supported.', $requiredFeatureSetVersion / 100, static::$supportedFeatureSetVersion / 100));

src/Symfony/Component/Mime/Header/AbstractHeader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,14 @@ protected function getEncodableWordTokens(string $string): array
164164
if ($this->tokenNeedsEncoding($token)) {
165165
$encodedToken .= $token;
166166
} else {
167-
if (\strlen($encodedToken) > 0) {
167+
if ('' !== $encodedToken) {
168168
$tokens[] = $encodedToken;
169169
$encodedToken = '';
170170
}
171171
$tokens[] = $token;
172172
}
173173
}
174-
if (\strlen($encodedToken)) {
174+
if ('' !== $encodedToken) {
175175
$tokens[] = $encodedToken;
176176
}
177177

0 commit comments

Comments
 (0)