8000 Merge branch '3.2' · symfony/symfony@4d48b58 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d48b58

Browse files
Merge branch '3.2'
* 3.2: [Yaml] CS [DI] Fix PhpDumper generated doc block #20411 fix Yaml parsing for very long quoted strings [Workflow] add Phpdoc for better IDE support fix package name in conflict rule improve message when workflows are missing [Doctrine Bridge] fix priority for doctrine event listeners Use PHP functions as array_map callbacks when possible [Validator] revert wrong Phpdoc change Use proper line endings
2 parents e41064f + ab08fd6 commit 4d48b58

File tree

14 files changed

+96
-67
lines changed

14 files changed

+96
-67
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ private function registerWorkflowConfiguration(array $workflows, ContainerBuilde
423423
return;
424424
}
425425

426+
if (!class_exists(Workflow\Workflow::class)) {
427+
throw new LogicException('Workflow support cannot be enabled as the Workflow component is not installed.');
428+
}
429+
426430
$loader->load('workflow.xml');
427431

428432
$registryDefinition = $container->getDefinition('workflow.registry');

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ public function testTranslator()
419419
$this->assertEquals('translator.default', (string) $container->getAlias('translator'), '->registerTranslatorConfiguration() redefines translator service from identity to real translator');
420420
$options = $container->getDefinition('translator.default')->getArgument(3);
421421

422-
$files = array_map(function ($resource) { return realpath($resource); }, $options['resource_files']['en']);
422+
$files = array_map('realpath', $options['resource_files']['en']);
423423
$ref = new \ReflectionClass('Symfony\Component\Validator\Validation');
424424
$this->assertContains(
425425
strtr(dirname($ref->getFileName()).'/Resources/translations/validators.en.xlf', '/', DIRECTORY_SEPARATOR),

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"symfony/translation": "~3.2",
5151
"symfony/templating": "~2.8|~3.0",
5252
"symfony/validator": "~3.3",
53+
"symfony/workflow": "~3.3",
5354
"symfony/yaml": "~3.2",
5455
"symfony/property-info": "~3.3",
5556
"doctrine/annotations": "~1.0",
@@ -66,7 +67,7 @@
6667
"symfony/form": "<3.3",
6768
"symfony/property-info": "<3.3",
6869
"symfony/serializer": "<3.3",
69-
"symfony/translations": "<3.2",
70+
"symfony/translation": "<3.2",
7071
"symfony/validator": "<3.3",
7172
"symfony/workflow": "<3.3"
7273
},

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testFirewalls()
7272
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
7373
$contextDef = $container->getDefinition($contextId);
7474
$arguments = $contextDef->getArguments();
75-
$listeners[] = array_map(function ($ref) { return (string) $ref; }, $arguments['index_0']);
75+
$listeners[] = array_map('strval', $arguments['index_0']);
7676

7777
$configDef = $container->getDefinition((string) $arguments['index_2']);
7878
$configs[] = array_values($configDef->getArguments());

src/Symfony/Component/Console/Output/BufferedOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ protected function doWrite($message, $newline)
4242
$this->buffer .= $message;
4343

4444
if ($newline) {
45-
$this->buffer .= "\n";
45+
$this->buffer .= PHP_EOL;
4646
}
4747
}
4848
}

src/Symfony/Component/Console/Tests/Fixtures/DummyOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DummyOutput extends BufferedOutput
2626
public function getLogs()
2727
{
2828
$logs = array();
29-
foreach (explode("\n", trim($this->fetch())) as $message) {
29+
foreach (explode(PHP_EOL, trim($this->fetch())) as $message) {
3030
preg_match('/^\[(.*)\] (.*)/', $message, $matches);
3131
$logs[] = sprintf('%s %s', $matches[1], $matches[2]);
3232
}

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ private function addService($id, Definition $definition)
734734
}
735735

736736
if ($definition->isAutowired()) {
737-
$doc = <<<EOF
737+
$doc .= <<<EOF
738738
739739
*
740740
* This service is autowired.

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ public function isFrozen()
5858
/**
5959
* Gets the 'foo' service.
6060
*
61+
* This service is shared.
62+
* This method always returns the same instance of the service.
63+
*
6164
* This service is autowired.
6265
*
6366
* @return \Foo A Foo instance

src/Symfony/Component/Finder/Tests/FinderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ public function testGetIterator()
312312

313313
$finder = $this->buildFinder();
314314
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
315-
$a = array_values(array_map(function ($a) { return (string) $a; }, $a));
315+
$a = array_values(array_map('strval', $a));
316316
sort($a);
317317
$this->assertEquals($expected, $a, 'implements the \IteratorAggregate interface');
318318
}

src/Symfony/Component/Validator/Mapping/ClassMetadata.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,8 @@ public function addPropertyConstraints($property, array $constraints)
257257
* The name of the getter is assumed to be the name of the property with an
258258
* uppercased first letter and either the prefix "get" or "is".
259259
*
260-
* @param string $property The name of the property
261-
* @param Constraint $constraint The constraint
262-
* @param string|null $method The method that is called to retrieve the value being validated (null for auto-detection)
260+
* @param string $property The name of the property
261+
* @param Constraint $constraint The constraint
263262
*
264263
* @return $this
265264
*/

src/Symfony/Component/Workflow/DefinitionBuilder.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function reset()
5959
}
6060

6161
/**
62+
* @param string $place
63+
*
6264
* @return $this
6365
*/
6466
public function setInitialPlace($place)
@@ -69,6 +71,8 @@ public function setInitialPlace($place)
6971
}
7072

7173
/**
74+
* @param string $place
75+
*
7276
* @return $this
7377
*/
7478
public function addPlace($place)
@@ -87,6 +91,8 @@ public function addPlace($place)
8791
}
8892

8993
/**
94+
* @param string[] $places
95+
*
9096
* @return $this
9197
*/
9298
public function addPlaces(array $places)

src/Symfony/Component/Yaml/Inline.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ public static function dump($value, $flags = 0)
220220
case Escaper::requiresDoubleQuoting($value):
221221
return Escaper::escapeWithDoubleQuotes($value);
222222
case Escaper::requiresSingleQuoting($value):
223-
case preg_match('{^[0-9]+[_0-9]*$}', $value):
224-
case preg_match(self::getHexRegex(), $value):
225-
case preg_match(self::getTimestampRegex(), $value):
223+
case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value):
224+
case Parser::preg_match(self::getHexRegex(), $value):
225+
case Parser::preg_match(self::getTimestampRegex(), $value):
226226
return Escaper::escapeWithSingleQuotes($value);
227227
default:
228228
return $value;
@@ -315,10 +315,10 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i
315315
$i += strlen($output);
316316

317317
// remove comments
318-
if (preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
318+
if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
319319
$output = substr($output, 0, $match[0][1]);
320320
}
321-
} elseif (preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
321+
} elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
322322
$output = $match[1];
323323
$i += strlen($output);
324324
} else {
@@ -354,7 +354,7 @@ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i
354354
*/
355355
private static function parseQuotedScalar($scalar, &$i)
356356
{
357-
if (!preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
357+
if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
358358
throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)));
359359
}
360360

@@ -653,7 +653,7 @@ private static function evaluateScalar($scalar, $flags, $references = array())
653653
// Optimize for returning strings.
654654
case $scalar[0] === '+' || $scalar[0] === '-' || $scalar[0] === '.' || is_numeric($scalar[0]):
655655
switch (true) {
656-
case preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar):
656+
case Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar):
657657
$scalar = str_replace('_', '', (string) $scalar);
658658
// omitting the break / return as integers are handled in the next case
659659
case ctype_digit($scalar):
@@ -667,7 +667,7 @@ private static function evaluateScalar($scalar, $flags, $references = array())
667667

668668
return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
669669
case is_numeric($scalar):
670-
case preg_match(self::getHexRegex(), $scalar):
670+
case Parser::preg_match(self::getHexRegex(), $scalar):
671671
$scalar = str_replace('_', '', $scalar);
672672

673673
return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
@@ -676,14 +676,14 @@ private static function evaluateScalar($scalar, $flags, $references = array())
676676
return -log(0);
677677
case '-.inf' === $scalarLower:
678678
return log(0);
679-
case preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar):
680-
case preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
679+
case Parser::preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar):
680+
case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
681681
if (false !== strpos($scalar, ',')) {
682682
@trigger_error('Using the comma as a group separator for floats is deprecated since version 3.2 and will be removed in 4.0.', E_USER_DEPRECATED);
683683
}
684684

685685
return (float) str_replace(array(',', '_'), '', $scalar);
686-
case preg_match(self::getTimestampRegex(), $scalar):
686+
case Parser::preg_match(self::getTimestampRegex(), $scalar):
687687
if (Yaml::PARSE_DATETIME & $flags) {
688688
// When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
689689
return new \DateTime($scalar, new \DateTimeZone('UTC'));
@@ -755,7 +755,7 @@ public static function evaluateBinaryScalar($scalar)
755755
throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', strlen($parsedBinaryData)));
756756
}
757757

758-
if (!preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
758+
if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
759759
throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData));
760760
}
761761

0 commit comments

Comments
 (0)
0