Skip to content

Commit b69f31b

Browse files
committed
[Workflow] Add types to private properties
Signed-off-by: Alexander M. Turek <[email protected]>
1 parent b32680d commit b69f31b

21 files changed

+55
-64
lines changed

Definition.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
*/
2323
final class Definition
2424
{
25-
private $places = [];
26-
private $transitions = [];
27-
private $initialPlaces = [];
28-
private $metadataStore;
25+
private array $places = [];
26+
private array $transitions = [];
27+
private array $initialPlaces = [];
28+
private MetadataStoreInterface $metadataStore;
2929

3030
/**
3131
* @param string[] $places

DefinitionBuilder.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
*/
2323
class DefinitionBuilder
2424
{
25-
private $places = [];
26-
private $transitions = [];
27-
private $initialPlaces;
28-
private $metadataStore;
25+
private array $places = [];
26+
private array $transitions = [];
27+
private string|array|null $initialPlaces = null;
28+
private ?MetadataStoreInterface $metadataStore = null;
2929

3030
/**
3131
* @param string[] $places

Dumper/MermaidDumper.php

+3-12
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,14 @@ class MermaidDumper implements DumperInterface
3939
self::TRANSITION_TYPE_WORKFLOW,
4040
];
4141

42-
/**
43-
* @var string
44-
*/
45-
private $direction;
46-
47-
/**
48-
* @var string
49-
*/
50-
private $transitionType;
42+
private string $direction;
43+
private string $transitionType;
5144

5245
/**
5346
* Just tracking the transition id is in some cases inaccurate to
5447
* get the link's number for styling purposes.
55-
*
56-
* @var int
5748
*/
58-
private $linkCount;
49+
private int $linkCount = 0;
5950

6051
public function __construct(string $transitionType, string $direction = self::DIRECTION_LEFT_TO_RIGHT)
6152
{

Dumper/PlantUmlDumper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class PlantUmlDumper implements DumperInterface
5252
],
5353
];
5454

55-
private $transitionType = self::STATEMACHINE_TRANSITION;
55+
private string $transitionType = self::STATEMACHINE_TRANSITION;
5656

57-
public function __construct(string $transitionType = null)
57+
public function __construct(string $transitionType)
5858
{
5959
if (!\in_array($transitionType, self::TRANSITION_TYPES, true)) {
6060
throw new InvalidArgumentException("Transition type '$transitionType' does not exist.");

Event/Event.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
class Event extends BaseEvent
2525
{
2626
protected $context;
27-
private $subject;
28-
private $marking;
29-
private $transition;
30-
private $workflow;
27+
private object $subject;
28+
private Marking $marking;
29+
private ?Transition $transition;
30+
private ?WorkflowInterface $workflow;
3131

3232
public function __construct(object $subject, Marking $marking, Transition $transition = null, WorkflowInterface $workflow = null, array $context = [])
3333
{

Event/GuardEvent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
final class GuardEvent extends Event
2525
{
26-
private $transitionBlockerList;
26+
private TransitionBlockerList $transitionBlockerList;
2727

2828
/**
2929
* {@inheritdoc}

EventListener/AuditTrailListener.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class AuditTrailListener implements EventSubscriberInterface
2222
{
23-
private $logger;
23+
private LoggerInterface $logger;
2424

2525
public function __construct(LoggerInterface $logger)
2626
{

EventListener/GuardExpression.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
class GuardExpression
1717
{
18-
private $transition;
19-
private $expression;
18+
private Transition $transition;
19+
private string $expression;
2020

2121
public function __construct(Transition $transition, string $expression)
2222
{

EventListener/GuardListener.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
*/
2525
class GuardListener
2626
{
27-
private $configuration;
28-
private $expressionLanguage;
29-
private $tokenStorage;
30-
private $authorizationChecker;
31-
private $trustResolver;
32-
private $roleHierarchy;
33-
private $validator;
27+
private array $configuration;
28+
private ExpressionLanguage $expressionLanguage;
29+
private TokenStorageInterface $tokenStorage;
30+
private AuthorizationCheckerInterface $authorizationChecker;
31+
private AuthenticationTrustResolverInterface $trustResolver;
32+
private ?RoleHierarchyInterface $roleHierarchy;
33+
private ?ValidatorInterface $validator;
3434

3535
public function __construct(array $configuration, ExpressionLanguage $expressionLanguage, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authorizationChecker, AuthenticationTrustResolverInterface $trustResolver, RoleHierarchyInterface $roleHierarchy = null, ValidatorInterface $validator = null)
3636
{

Exception/NotEnabledTransitionException.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
class NotEnabledTransitionException extends TransitionException
2323
{
24-
private $transitionBlockerList;
24+
private TransitionBlockerList $transitionBlockerList;
2525

2626
public function __construct(object $subject, string $transitionName, WorkflowInterface $workflow, TransitionBlockerList $transitionBlockerList, array $context = [])
2727
{

Exception/TransitionException.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
*/
2020
class TransitionException extends LogicException
2121
{
22-
private $subject;
23-
private $transitionName;
24-
private $workflow;
25-
private $context;
22+
private object $subject;
23+
private string $transitionName;
24+
private WorkflowInterface $workflow;
25+
private array $context;
2626

2727
public function __construct(object $subject, string $transitionName, WorkflowInterface $workflow, string $message, array $context = [])
2828
{

Marking.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
*/
1919
class Marking
2020
{
21-
private $places = [];
22-
private $context = null;
21+
private array $places = [];
22+
private ?array $context = null;
2323

2424
/**
2525
* @param int[] $representation Keys are the place name and values should be 1

MarkingStore/MethodMarkingStore.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
*/
3030
final class MethodMarkingStore implements MarkingStoreInterface
3131
{
32-
private $singleState;
33-
private $property;
32+
private bool $singleState;
33+
private string $property;
3434

3535
/**
3636
* @param string $property Used to determine methods to call

Metadata/InMemoryMetadataStore.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ final class InMemoryMetadataStore implements MetadataStoreInterface
2020
{
2121
use GetMetadataTrait;
2222

23-
private $workflowMetadata;
24-
private $placesMetadata;
25-
private $transitionsMetadata;
23+
private array $workflowMetadata;
24+
private array $placesMetadata;
25+
private \SplObjectStorage $transitionsMetadata;
2626

2727
public function __construct(array $workflowMetadata = [], array $placesMetadata = [], \SplObjectStorage $transitionsMetadata = null)
2828
{

Registry.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class Registry
2222
{
23-
private $workflows = [];
23+
private array $workflows = [];
2424

2525
public function addWorkflow(WorkflowInterface $workflow, WorkflowSupportStrategyInterface $supportStrategy)
2626
{

SupportStrategy/InstanceOfSupportStrategy.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
final class InstanceOfSupportStrategy implements WorkflowSupportStrategyInterface
2121
{
22-
private $className;
22+
private string $className;
2323

2424
public function __construct(string $className)
2525
{

Transition.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
*/
1818
class Transition
1919
{
20-
private $name;
21-
private $froms;
22-
private $tos;
20+
private string $name;
21+
private array $froms;
22+
private array $tos;
2323

2424
/**
2525
* @param string|string[] $froms

TransitionBlocker.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ final class TransitionBlocker
2020
public const BLOCKED_BY_EXPRESSION_GUARD_LISTENER = '326a1e9c-0c12-11e8-ba89-0ed5f89f718b';
2121
public const UNKNOWN = 'e8b5bbb9-5913-4b98-bfa6-65dbd228a82a';
2222

23-
private $message;
24-
private $code;
25-
private $parameters;
23+
private string $message;
24+
private string $code;
25+
private array $parameters;
2626

2727
/**
2828
* @param string $code Code is a machine-readable string, usually an UUID

TransitionBlockerList.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
final class TransitionBlockerList implements \IteratorAggregate, \Countable
2020
{
21-
private $blockers;
21+
private array $blockers;
2222

2323
/**
2424
* @param TransitionBlocker[] $blockers

Validator/WorkflowValidator.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
class WorkflowValidator implements DefinitionValidatorInterface
2222
{
23-
private $singlePlace;
23+
private bool $singlePlace;
2424

2525
public function __construct(bool $singlePlace = false)
2626
{

Workflow.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ class Workflow implements WorkflowInterface
5252
WorkflowEvents::ANNOUNCE => self::DISABLE_ANNOUNCE_EVENT,
5353
];
5454

55-
private $definition;
56-
private $markingStore;
57-
private $dispatcher;
58-
private $name;
55+
private Definition $definition;
56+
private MarkingStoreInterface $markingStore;
57+
private ?EventDispatcherInterface $dispatcher;
58+
private string $name;
5959

6060
/**
6161
* When `null` fire all events (the default behaviour).
@@ -65,7 +65,7 @@ class Workflow implements WorkflowInterface
6565
*
6666
* @var array|string[]|null
6767
*/
68-
private $eventsToDispatch = null;
68+
private ?array $eventsToDispatch = null;
6969

7070
public function __construct(Definition $definition, MarkingStoreInterface $markingStore = null, EventDispatcherInterface $dispatcher = null, string $name = 'unnamed', array $eventsToDispatch = null)
7171
{

0 commit comments

Comments
 (0)