Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6a94b77

Browse filesBrowse files
[Workflow] add types to all arguments
1 parent d9f0467 commit 6a94b77
Copy full SHA for 6a94b77

File tree

7 files changed

+9
-33
lines changed
Filter options

7 files changed

+9
-33
lines changed

‎src/Symfony/Component/Workflow/Definition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Definition.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ final class Definition
3232
* @param Transition[] $transitions
3333
* @param string|string[]|null $initialPlaces
3434
*/
35-
public function __construct(array $places, array $transitions, $initialPlaces = null, MetadataStoreInterface $metadataStore = null)
35+
public function __construct(array $places, array $transitions, string|array|null $initialPlaces = null, MetadataStoreInterface $metadataStore = null)
3636
{
3737
foreach ($places as $place) {
3838
$this->addPlace($place);
@@ -76,7 +76,7 @@ public function getMetadataStore(): MetadataStoreInterface
7676
return $this->metadataStore;
7777
}
7878

79-
private function setInitialPlaces($places = null)
79+
private function setInitialPlaces(string|array|null $places = null)
8080
{
8181
if (!$places) {
8282
return;

‎src/Symfony/Component/Workflow/DefinitionBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/DefinitionBuilder.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function clear()
6565
*
6666
* @return $this
6767
*/
68-
public function setInitialPlaces($initialPlaces)
68+
public function setInitialPlaces(string|array|null $initialPlaces)
6969
{
7070
$this->initialPlaces = $initialPlaces;
7171

‎src/Symfony/Component/Workflow/Event/Event.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Event/Event.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function getWorkflowName()
6363
return $this->workflow->getName();
6464
}
6565

66-
public function getMetadata(string $key, $subject)
66+
public function getMetadata(string $key, string|Transition|null $subject)
6767
{
6868
return $this->workflow->getMetadataStore()->getMetadata($key, $subject);
6969
}

‎src/Symfony/Component/Workflow/Metadata/GetMetadataTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Metadata/GetMetadataTrait.php
+3-20Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,21 @@
1111

1212
namespace Symfony\Component\Workflow\Metadata;
1313

14-
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
1514
use Symfony\Component\Workflow\Transition;
1615

1716
/**
1817
* @author Grégoire Pineau <lyrixx@lyrixx.info>
1918
*/
2019
trait GetMetadataTrait
2120
{
22-
public function getMetadata(string $key, $subject = null)
21+
public function getMetadata(string $key, string|Transition|null $subject = null)
2322
{
2423
if (null === $subject) {
2524
return $this->getWorkflowMetadata()[$key] ?? null;
2625
}
2726

28-
if (\is_string($subject)) {
29-
$metadataBag = $this->getPlaceMetadata($subject);
30-
if (!$metadataBag) {
31-
return null;
32-
}
27+
$metadataBag = \is_string($subject) ? $this->getPlaceMetadata($subject) : $this->getTransitionMetadata($subject);
3328

34-
return $metadataBag[$key] ?? null;
35-
}
36-
37-
if ($subject instanceof Transition) {
38-
$metadataBag = $this->getTransitionMetadata($subject);
39-
if (!$metadataBag) {
40-
return null;
41-
}
42-
43-
return $metadataBag[$key] ?? null;
44-
}
45-
46-
throw new InvalidArgumentException(sprintf('Could not find a MetadataBag for the subject of type "%s".', get_debug_type($subject)));
29+
return $metadataBag[$key] ?? null;
4730
}
4831
}

‎src/Symfony/Component/Workflow/Metadata/MetadataStoreInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Metadata/MetadataStoreInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ public function getTransitionMetadata(Transition $transition): array;
3535
* Use a string (the place name) to get place metadata
3636
* Use a Transition instance to get transition metadata
3737
*/
38-
public function getMetadata(string $key, $subject = null);
38+
public function getMetadata(string $key, string|Transition|null $subject = null);
3939
}

‎src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Tests/Metadata/InMemoryMetadataStoreTest.php
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,4 @@ public function testGetMetadata()
7575
$this->assertNull($this->store->getMetadata('description', $this->transition));
7676
$this->assertNull($this->store->getMetadata('description', new Transition('transition_2', [], [])));
7777
}
78-
79-
public function testGetMetadataWithUnknownType()
80-
{
81-
$this->expectException(InvalidArgumentException::class);
82-
$this->expectExceptionMessage('Could not find a MetadataBag for the subject of type "bool".');
83-
$this->store->getMetadata('title', true);
84-
}
8578
}

‎src/Symfony/Component/Workflow/Transition.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Workflow/Transition.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Transition
2525
* @param string|string[] $froms
2626
* @param string|string[] $tos
2727
*/
28-
public function __construct(string $name, $froms, $tos)
28+
public function __construct(string $name, string|array $froms, string|array $tos)
2929
{
3030
$this->name = $name;
3131
$this->froms = (array) $froms;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.