Skip to content

Commit a00da8f

Browse files
author
Robin Chalas
committed
Add scalar typehints/return types on final/internal/private code
1 parent 81137a0 commit a00da8f

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

Definition.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class Definition
3030
* @param Transition[] $transitions
3131
* @param string|null $initialPlace
3232
*/
33-
public function __construct(array $places, array $transitions, $initialPlace = null)
33+
public function __construct(array $places, array $transitions, string $initialPlace = null)
3434
{
3535
foreach ($places as $place) {
3636
$this->addPlace($place);
@@ -54,20 +54,20 @@ public function getInitialPlace()
5454
/**
5555
* @return string[]
5656
*/
57-
public function getPlaces()
57+
public function getPlaces(): array
5858
{
5959
return $this->places;
6060
}
6161

6262
/**
6363
* @return Transition[]
6464
*/
65-
public function getTransitions()
65+
public function getTransitions(): array
6666
{
6767
return $this->transitions;
6868
}
6969

70-
private function setInitialPlace($place)
70+
private function setInitialPlace(string $place = null)
7171
{
7272
if (null === $place) {
7373
return;
@@ -80,7 +80,7 @@ private function setInitialPlace($place)
8080
$this->initialPlace = $place;
8181
}
8282

83-
private function addPlace($place)
83+
private function addPlace(string $place)
8484
{
8585
if (!preg_match('{^[\w\d_-]+$}', $place)) {
8686
throw new InvalidArgumentException(sprintf('The place "%s" contains invalid characters.', $place));

Dumper/GraphvizDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ protected function dotize($id)
201201
return strtolower(preg_replace('/[^\w]/i', '_', $id));
202202
}
203203

204-
private function addAttributes(array $attributes)
204+
private function addAttributes(array $attributes): string
205205
{
206206
$code = array();
207207

@@ -212,7 +212,7 @@ private function addAttributes(array $attributes)
212212
return $code ? ', '.implode(', ', $code) : '';
213213
}
214214

215-
private function addOptions(array $options)
215+
private function addOptions(array $options): string
216216
{
217217
$code = array();
218218

EventListener/GuardListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function onTransition(GuardEvent $event, $eventName)
5151
}
5252

5353
// code should be sync with Symfony\Component\Security\Core\Authorization\Voter\ExpressionVoter
54-
private function getVariables(GuardEvent $event)
54+
private function getVariables(GuardEvent $event): array
5555
{
5656
$token = $this->tokenStorage->getToken();
5757

Registry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function get($subject, $workflowName = null)
6161
return $matched;
6262
}
6363

64-
private function supports(Workflow $workflow, SupportStrategyInterface $supportStrategy, $subject, $workflowName)
64+
private function supports(Workflow $workflow, SupportStrategyInterface $supportStrategy, $subject, $workflowName): bool
6565
{
6666
if (null !== $workflowName && $workflowName !== $workflow->getName()) {
6767
return false;

SupportStrategy/ClassInstanceSupportStrategy.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ final class ClassInstanceSupportStrategy implements SupportStrategyInterface
1111
{
1212
private $className;
1313

14-
/**
15-
* @param string $className a FQCN
16-
*/
17-
public function __construct($className)
14+
public function __construct(string $className)
1815
{
1916
$this->className = $className;
2017
}

0 commit comments

Comments
 (0)