Skip to content

Commit 331d13a

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Validator] add missing German translations [Serializer] Fix denormalizing abstract part headers in MimeMessageNormalizer [Form] Remove an obsolete phpdoc comment [FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array
2 parents 1dca70a + 37eec23 commit 331d13a

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

DependencyInjection/Configuration.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
454454
->beforeNormalization()
455455
->always()
456456
->then(function ($places) {
457+
if (!\is_array($places)) {
458+
throw new InvalidConfigurationException('The "places" option must be an array in workflow configuration.');
459+
}
460+
457461
// It's an indexed array of shape ['place1', 'place2']
458462
if (isset($places[0]) && \is_string($places[0])) {
459463
return array_map(function (string $place) {
@@ -499,6 +503,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
499503
->beforeNormalization()
500504
->always()
501505
->then(function ($transitions) {
506+
if (!\is_array($transitions)) {
507+
throw new InvalidConfigurationException('The "transitions" option must be an array in workflow configuration.');
508+
}
509+
502510
// It's an indexed array, we let the validation occur
503511
if (isset($transitions[0]) && \is_array($transitions[0])) {
504512
return $transitions;

Tests/DependencyInjection/PhpFrameworkExtensionTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection;
1313

14+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1415
use Symfony\Component\Config\FileLocator;
1516
use Symfony\Component\DependencyInjection\ContainerBuilder;
1617
use Symfony\Component\DependencyInjection\Exception\LogicException;
@@ -58,6 +59,36 @@ public function testAssetPackageCannotHavePathAndUrl()
5859
});
5960
}
6061

62+
public function testWorkflowValidationPlacesIsArray()
63+
{
64+
$this->expectException(InvalidConfigurationException::class);
65+
$this->expectExceptionMessage('The "places" option must be an array in workflow configuration.');
66+
$this->createContainerFromClosure(function ($container) {
67+
$container->loadFromExtension('framework', [
68+
'workflows' => [
69+
'article' => [
70+
'places' => null,
71+
],
72+
],
73+
]);
74+
});
75+
}
76+
77+
public function testWorkflowValidationTransitonsIsArray()
78+
{
79+
$this->expectException(InvalidConfigurationException::class);
80+
$this->expectExceptionMessage('The "transitions" option must be an array in workflow configuration.');
81+
$this->createContainerFromClosure(function ($container) {
82+
$container->loadFromExtension('framework', [
83+
'workflows' => [
84+
'article' => [
85+
'transitions' => null,
86+
],
87+
],
88+
]);
89+
});
90+
}
91+
6192
public function testWorkflowValidationStateMachine()
6293
{
6394
$this->expectException(InvalidDefinitionException::class);

0 commit comments

Comments
 (0)