Skip to content

Commit ea55e45

Browse files
guillaumeVDPnicolas-grekas
authored andcommitted
[Workflow] Adding more return types
1 parent 1cfc0fe commit ea55e45

15 files changed

+39
-23
lines changed

Event/Event.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public function getWorkflowName()
7575
return $this->workflow->getName();
7676
}
7777

78+
/**
79+
* @return mixed
80+
*/
7881
public function getMetadata(string $key, string|Transition|null $subject)
7982
{
8083
return $this->workflow->getMetadataStore()->getMetadata($key, $subject);

MarkingStore/MarkingStoreInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public function getMarking(object $subject): Marking;
3131

3232
/**
3333
* Sets a Marking to a subject.
34+
*
35+
* @return void
3436
*/
3537
public function setMarking(object $subject, Marking $marking, array $context = []);
3638
}

Metadata/GetMetadataTrait.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
*/
1919
trait GetMetadataTrait
2020
{
21+
/**
22+
* @return mixed
23+
*/
2124
public function getMetadata(string $key, string|Transition $subject = null)
2225
{
2326
if (null === $subject) {

Metadata/MetadataStoreInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public function getTransitionMetadata(Transition $transition): array;
3434
* @param string|Transition|null $subject Use null to get workflow metadata
3535
* Use a string (the place name) to get place metadata
3636
* Use a Transition instance to get transition metadata
37+
*
38+
* @return mixed
3739
*/
3840
public function getMetadata(string $key, string|Transition $subject = null);
3941
}

Tests/Dumper/GraphvizDumperTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testDumpWithMarking($definition, $marking, $expected)
4747
$this->assertEquals($expected, $dump);
4848
}
4949

50-
public static function provideWorkflowDefinitionWithMarking()
50+
public static function provideWorkflowDefinitionWithMarking(): \Generator
5151
{
5252
yield [
5353
self::createComplexWorkflowDefinition(),
@@ -62,13 +62,13 @@ public static function provideWorkflowDefinitionWithMarking()
6262
];
6363
}
6464

65-
public static function provideWorkflowDefinitionWithoutMarking()
65+
public static function provideWorkflowDefinitionWithoutMarking(): \Generator
6666
{
6767
yield [self::createComplexWorkflowDefinition(), self::provideComplexWorkflowDumpWithoutMarking()];
6868
yield [self::createSimpleWorkflowDefinition(), self::provideSimpleWorkflowDumpWithoutMarking()];
6969
}
7070

71-
public static function createComplexWorkflowDefinitionDumpWithMarking()
71+
public static function createComplexWorkflowDefinitionDumpWithMarking(): string
7272
{
7373
return 'digraph workflow {
7474
ratio="compress" rankdir="LR"
@@ -106,7 +106,7 @@ public static function createComplexWorkflowDefinitionDumpWithMarking()
106106
';
107107
}
108108

109-
public static function createSimpleWorkflowDumpWithMarking()
109+
public static function createSimpleWorkflowDumpWithMarking(): string
110110
{
111111
return 'digraph workflow {
112112
ratio="compress" rankdir="LR"
@@ -126,7 +126,7 @@ public static function createSimpleWorkflowDumpWithMarking()
126126
';
127127
}
128128

129-
public static function provideComplexWorkflowDumpWithoutMarking()
129+
public static function provideComplexWorkflowDumpWithoutMarking(): string
130130
{
131131
return 'digraph workflow {
132132
ratio="compress" rankdir="LR"
@@ -164,7 +164,7 @@ public static function provideComplexWorkflowDumpWithoutMarking()
164164
';
165165
}
166166

167-
public static function provideSimpleWorkflowDumpWithoutMarking()
167+
public static function provideSimpleWorkflowDumpWithoutMarking(): string
168168
{
169169
return 'digraph workflow {
170170
ratio="compress" rankdir="LR"

Tests/Dumper/MermaidDumperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public static function provideWorkflowDefinitionWithoutMarking(): array
146146
];
147147
}
148148

149-
public static function provideWorkflowWithReservedWords()
149+
public static function provideWorkflowWithReservedWords(): array
150150
{
151151
$builder = new DefinitionBuilder();
152152

Tests/Dumper/PlantUmlDumperTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testDumpWorkflowWithoutMarking($definition, $marking, $expectedF
3636
$this->assertStringEqualsFile($file, $dump);
3737
}
3838

39-
public static function provideWorkflowDefinitionWithoutMarking()
39+
public static function provideWorkflowDefinitionWithoutMarking(): \Generator
4040
{
4141
yield [self::createSimpleWorkflowDefinition(), null, 'simple-workflow-nomarking', 'SimpleDiagram'];
4242
yield [self::createComplexWorkflowDefinition(), null, 'complex-workflow-nomarking', 'ComplexDiagram'];
@@ -59,7 +59,7 @@ public function testDumpStateMachineWithoutMarking($definition, $marking, $expec
5959
$this->assertStringEqualsFile($file, $dump);
6060
}
6161

62-
public static function provideStateMachineDefinitionWithoutMarking()
62+
public static function provideStateMachineDefinitionWithoutMarking(): \Generator
6363
{
6464
yield [static::createComplexStateMachineDefinition(), null, 'complex-state-machine-nomarking', 'SimpleDiagram'];
6565
$marking = new Marking(['c' => 1, 'e' => 1]);
@@ -94,7 +94,7 @@ public function testDumpWorkflowWithSpacesInTheStateNamesAndDescription()
9494
$this->assertStringEqualsFile($file, $dump);
9595
}
9696

97-
private function getFixturePath($name, $transitionType)
97+
private function getFixturePath($name, $transitionType): string
9898
{
9999
return __DIR__.'/../fixtures/puml/'.$transitionType.'/'.$name.'.puml';
100100
}

Tests/EventListener/GuardListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function testGuardExpressionBlocks()
143143
$this->assertTrue($event->isBlocked());
144144
}
145145

146-
private function createEvent(Transition $transition = null)
146+
private function createEvent(Transition $transition = null): GuardEvent
147147
{
148148
$subject = new Subject();
149149
$transition ??= new Transition('name', 'from', 'to');
@@ -171,7 +171,7 @@ private function configureAuthenticationChecker($isUsed, $granted = true)
171171
;
172172
}
173173

174-
private function configureValidator($isUsed, $valid = true)
174+
private function configureValidator($isUsed, $valid = true): void
175175
{
176176
if (!$isUsed) {
177177
$this->validator

Tests/MarkingStore/MethodMarkingStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testGetMarkingWithUninitializedProperty2()
111111
$markingStore->getMarking($subject);
112112
}
113113

114-
private function createValueObject(string $markingValue)
114+
private function createValueObject(string $markingValue): object
115115
{
116116
return new class($markingValue) {
117117
/** @var string */

Tests/RegistryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Workflow\Tests;
1313

14+
use PHPUnit\Framework\MockObject\MockObject;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Workflow\Definition;
1617
use Symfony\Component\Workflow\Exception\InvalidArgumentException;
@@ -108,7 +109,7 @@ public function testAllWithNoMatch()
108109
$this->assertCount(0, $workflows);
109110
}
110111

111-
private function createWorkflowSupportStrategy($supportedClassName)
112+
private function createWorkflowSupportStrategy($supportedClassName): MockObject&WorkflowSupportStrategyInterface
112113
{
113114
$strategy = $this->createMock(WorkflowSupportStrategyInterface::class);
114115
$strategy->expects($this->any())->method('supports')

0 commit comments

Comments
 (0)