Skip to content

Commit f585930

Browse files
committed
[FrameworkBundle][Workflow] Throw exception is workflow.xxx.transitions is not an array
1 parent 0bc39e8 commit f585930

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
446446
->beforeNormalization()
447447
->always()
448448
->then(function ($places) {
449+
if (!\is_array($places)) {
450+
throw new InvalidConfigurationException('The "places" option must be an array in workflow configuration.');
451+
}
452+
449453
// It's an indexed array of shape ['place1', 'place2']
450454
if (isset($places[0]) && \is_string($places[0])) {
451455
return array_map(function (string $place) {
@@ -491,6 +495,10 @@ private function addWorkflowSection(ArrayNodeDefinition $rootNode)
491495
->beforeNormalization()
492496
->always()
493497
->then(function ($transitions) {
498+
if (!\is_array($transitions)) {
499+
throw new InvalidConfigurationException('The "transitions" option must be an array in workflow configuration.');
500+
}
501+
494502
// It's an indexed array, we let the validation occur
495503
if (isset($transitions[0]) && \is_array($transitions[0])) {
496504
return $transitions;

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

+31
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;
@@ -56,6 +57,36 @@ public function testAssetPackageCannotHavePathAndUrl()
5657
});
5758
}
5859

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

0 commit comments

Comments
 (0)