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 54e44e4

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

File tree

6 files changed

+9
-27
lines changed
Filter options

6 files changed

+9
-27
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-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ public function clear()
6161
}
6262

6363
/**
64-
* @param string|string[]|null $initialPlaces
65-
*
6664
* @return $this
6765
*/
68-
public function setInitialPlaces($initialPlaces)
66+
public function setInitialPlaces(string|array|null $initialPlaces)
6967
{
7068
$this->initialPlaces = $initialPlaces;
7169

‎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-19Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,14 @@
1919
*/
2020
trait GetMetadataTrait
2121
{
22-
public function getMetadata(string $key, $subject = null)
22+
public function getMetadata(string $key, string|Transition|null $subject = null)
2323
{
2424
if (null === $subject) {
2525
return $this->getWorkflowMetadata()[$key] ?? null;
2626
}
2727

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

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)));
30+
return $metadataBag[$key] ?? null;
4731
}
4832
}

‎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/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.