Skip to content

Commit 00f08e4

Browse files
Add return types - batch 5/n
1 parent 9004e35 commit 00f08e4

File tree

105 files changed

+313
-363
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+313
-363
lines changed

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

+6-14
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ public function removeSubscriber(EventSubscriberInterface $subscriber)
9292
/**
9393
* {@inheritdoc}
9494
*/
95-
public function getListeners(string $eventName = null)
95+
public function getListeners(string $eventName = null): array
9696
{
9797
return $this->dispatcher->getListeners($eventName);
9898
}
9999

100100
/**
101101
* {@inheritdoc}
102102
*/
103-
public function getListenerPriority(string $eventName, callable|array $listener)
103+
public function getListenerPriority(string $eventName, callable|array $listener): ?int
104104
{
105105
// we might have wrapped listeners for the event (if called while dispatching)
106106
// in that case get the priority by wrapper
@@ -118,7 +118,7 @@ public function getListenerPriority(string $eventName, callable|array $listener)
118118
/**
119119
* {@inheritdoc}
120120
*/
121-
public function hasListeners(string $eventName = null)
121+
public function hasListeners(string $eventName = null): bool
122122
{
123123
return $this->dispatcher->hasListeners($eventName);
124124
}
@@ -163,10 +163,7 @@ public function dispatch(object $event, string $eventName = null): object
163163
return $event;
164164
}
165165

166-
/**
167-
* @return array
168-
*/
169-
public function getCalledListeners(Request $request = null)
166+
public function getCalledListeners(Request $request = null): array
170167
{
171168
if (null === $this->callStack) {
172169
return [];
@@ -184,10 +181,7 @@ public function getCalledListeners(Request $request = null)
184181
return $called;
185182
}
186183

187-
/**
188-
* @return array
189-
*/
190-
public function getNotCalledListeners(Request $request = null)
184+
public function getNotCalledListeners(Request $request = null): array
191185
{
192186
try {
193187
$allListeners = $this->getListeners();
@@ -255,10 +249,8 @@ public function reset()
255249
*
256250
* @param string $method The method name
257251
* @param array $arguments The method arguments
258-
*
259-
* @return mixed
260252
*/
261-
public function __call(string $method, array $arguments)
253+
public function __call(string $method, array $arguments): mixed
262254
{
263255
return $this->dispatcher->{$method}(...$arguments);
264256
}

src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class RegisterListenersPass implements CompilerPassInterface
3131
/**
3232
* @return $this
3333
*/
34-
public function setHotPathEvents(array $hotPathEvents)
34+
public function setHotPathEvents(array $hotPathEvents): static
3535
{
3636
$this->hotPathEvents = array_flip($hotPathEvents);
3737

@@ -41,7 +41,7 @@ public function setHotPathEvents(array $hotPathEvents)
4141
/**
4242
* @return $this
4343
*/
44-
public function setNoPreloadEvents(array $noPreloadEvents): self
44+
public function setNoPreloadEvents(array $noPreloadEvents): static
4545
{
4646
$this->noPreloadEvents = array_flip($noPreloadEvents);
4747

src/Symfony/Component/EventDispatcher/EventDispatcher.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function dispatch(object $event, string $eventName = null): object
6565
/**
6666
* {@inheritdoc}
6767
*/
68-
public function getListeners(string $eventName = null)
68+
public function getListeners(string $eventName = null): array
6969
{
7070
if (null !== $eventName) {
7171
if (empty($this->listeners[$eventName])) {
@@ -91,7 +91,7 @@ public function getListeners(string $eventName = null)
9191
/**
9292
* {@inheritdoc}
9393
*/
94-
public function getListenerPriority(string $eventName, callable|array $listener)
94+
public function getListenerPriority(string $eventName, callable|array $listener): ?int
9595
{
9696
if (empty($this->listeners[$eventName])) {
9797
return null;
@@ -120,7 +120,7 @@ public function getListenerPriority(string $eventName, callable|array $listener)
120120
/**
121121
* {@inheritdoc}
122122
*/
123-
public function hasListeners(string $eventName = null)
123+
public function hasListeners(string $eventName = null): bool
124124
{
125125
if (null !== $eventName) {
126126
return !empty($this->listeners[$eventName]);

src/Symfony/Component/EventDispatcher/EventDispatcherInterface.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function removeSubscriber(EventSubscriberInterface $subscriber);
5050
*
5151
* @return array The event listeners for the specified event, or all event listeners by event name
5252
*/
53-
public function getListeners(string $eventName = null);
53+
public function getListeners(string $eventName = null): array;
5454

5555
/**
5656
* Gets the listener priority for a specific event.
@@ -59,12 +59,12 @@ public function getListeners(string $eventName = null);
5959
*
6060
* @return int|null The event listener priority
6161
*/
62-
public function getListenerPriority(string $eventName, callable $listener);
62+
public function getListenerPriority(string $eventName, callable $listener): ?int;
6363

6464
/**
6565
* Checks whether an event has any registered listeners.
6666
*
6767
* @return bool true if the specified event has any listeners, false otherwise
6868
*/
69-
public function hasListeners(string $eventName = null);
69+
public function hasListeners(string $eventName = null): bool;
7070
}

src/Symfony/Component/EventDispatcher/GenericEvent.php

+6-10
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(mixed $subject = null, array $arguments = [])
4242
*
4343
* @return mixed The observer subject
4444
*/
45-
public function getSubject()
45+
public function getSubject(): mixed
4646
{
4747
return $this->subject;
4848
}
@@ -54,7 +54,7 @@ public function getSubject()
5454
*
5555
* @throws \InvalidArgumentException if key is not found
5656
*/
57-
public function getArgument(string $key)
57+
public function getArgument(string $key): mixed
5858
{
5959
if ($this->hasArgument($key)) {
6060
return $this->arguments[$key];
@@ -68,7 +68,7 @@ public function getArgument(string $key)
6868
*
6969
* @return $this
7070
*/
71-
public function setArgument(string $key, mixed $value)
71+
public function setArgument(string $key, mixed $value): static
7272
{
7373
$this->arguments[$key] = $value;
7474

@@ -77,10 +77,8 @@ public function setArgument(string $key, mixed $value)
7777

7878
/**
7979
* Getter for all arguments.
80-
*
81-
* @return array
8280
*/
83-
public function getArguments()
81+
public function getArguments(): array
8482
{
8583
return $this->arguments;
8684
}
@@ -90,7 +88,7 @@ public function getArguments()
9088
*
9189
* @return $this
9290
*/
93-
public function setArguments(array $args = [])
91+
public function setArguments(array $args = []): static
9492
{
9593
$this->arguments = $args;
9694

@@ -99,10 +97,8 @@ public function setArguments(array $args = [])
9997

10098
/**
10199
* Has argument.
102-
*
103-
* @return bool
104100
*/
105-
public function hasArgument(string $key)
101+
public function hasArgument(string $key): bool
106102
{
107103
return \array_key_exists($key, $this->arguments);
108104
}

src/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@ public function removeSubscriber(EventSubscriberInterface $subscriber)
6868
/**
6969
* {@inheritdoc}
7070
*/
71-
public function getListeners(string $eventName = null)
71+
public function getListeners(string $eventName = null): array
7272
{
7373
return $this->dispatcher->getListeners($eventName);
7474
}
7575

7676
/**
7777
* {@inheritdoc}
7878
*/
79-
public function getListenerPriority(string $eventName, callable|array $listener)
79+
public function getListenerPriority(string $eventName, callable|array $listener): ?int
8080
{
8181
return $this->dispatcher->getListenerPriority($eventName, $listener);
8282
}
8383

8484
/**
8585
* {@inheritdoc}
8686
*/
87-
public function hasListeners(string $eventName = null)
87+
public function hasListeners(string $eventName = null): bool
8888
{
8989
return $this->dispatcher->hasListeners($eventName);
9090
}

src/Symfony/Component/ExpressionLanguage/Compiler.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getFunction(string $name)
3838
*
3939
* @return string The PHP code
4040
*/
41-
public function getSource()
41+
public function getSource(): string
4242
{
4343
return $this->source;
4444
}
@@ -55,7 +55,7 @@ public function reset()
5555
*
5656
* @return $this
5757
*/
58-
public function compile(Node\Node $node)
58+
public function compile(Node\Node $node): static
5959
{
6060
$node->compile($this);
6161

@@ -80,7 +80,7 @@ public function subcompile(Node\Node $node)
8080
*
8181
* @return $this
8282
*/
83-
public function raw(string $string)
83+
public function raw(string $string): static
8484
{
8585
$this->source .= $string;
8686

@@ -92,7 +92,7 @@ public function raw(string $string)
9292
*
9393
* @return $this
9494
*/
95-
public function string(string $value)
95+
public function string(string $value): static
9696
{
9797
$this->source .= sprintf('"%s"', addcslashes($value, "\0\t\"\$\\"));
9898

@@ -104,7 +104,7 @@ public function string(string $value)
104104
*
105105
* @return $this
106106
*/
107-
public function repr(mixed $value)
107+
public function repr(mixed $value): static
108108
{
109109
if (\is_int($value) || \is_float($value)) {
110110
if (false !== $locale = setlocale(\LC_NUMERIC, 0)) {

src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php

+4-15
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,17 @@ public function __construct(string $name, callable $compiler, callable $evaluato
4646
$this->evaluator = $evaluator instanceof \Closure ? $evaluator : \Closure::fromCallable($evaluator);
4747
}
4848

49-
/**
50-
* @return string
51-
*/
52-
public function getName()
49+
public function getName(): string
5350
{
5451
return $this->name;
5552
}
5653

57-
/**
58-
* @return \Closure
59-
*/
60-
public function getCompiler()
54+
public function getCompiler(): \Closure
6155
{
6256
return $this->compiler;
6357
}
6458

65-
/**
66-
* @return \Closure
67-
*/
68-
public function getEvaluator()
59+
public function getEvaluator(): \Closure
6960
{
7061
return $this->evaluator;
7162
}
@@ -75,13 +66,11 @@ public function getEvaluator()
7566
*
7667
* @param string|null $expressionFunctionName The expression function name (default: same than the PHP function name)
7768
*
78-
* @return self
79-
*
8069
* @throws \InvalidArgumentException if given PHP function name does not exist
8170
* @throws \InvalidArgumentException if given PHP function name is in namespace
8271
* and expression function name is not defined
8372
*/
84-
public static function fromPhp(string $phpFunctionName, string $expressionFunctionName = null)
73+
public static function fromPhp(string $phpFunctionName, string $expressionFunctionName = null): self
8574
{
8675
$phpFunctionName = ltrim($phpFunctionName, '\\');
8776
if (!\function_exists($phpFunctionName)) {

src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct(CacheItemPoolInterface $cache = null, array $provide
4848
*
4949
* @return string The compiled PHP source code
5050
*/
51-
public function compile(Expression|string $expression, array $names = [])
51+
public function compile(Expression|string $expression, array $names = []): string
5252
{
5353
return $this->getCompiler()->compile($this->parse($expression, $names)->getNodes())->getSource();
5454
}
@@ -58,17 +58,15 @@ public function compile(Expression|string $expression, array $names = [])
5858
*
5959
* @return mixed The result of the evaluation of the expression
6060
*/
61-
public function evaluate(Expression|string $expression, array $values = [])
61+
public function evaluate(Expression|string $expression, array $values = []): mixed
6262
{
6363
return $this->parse($expression, array_keys($values))->getNodes()->evaluate($this->functions, $values);
6464
}
6565

6666
/**
6767
* Parses an expression.
68-
*
69-
* @return ParsedExpression
7068
*/
71-
public function parse(Expression|string $expression, array $names)
69+
public function parse(Expression|string $expression, array $names): ParsedExpression
7270
{
7371
if ($expression instanceof ParsedExpression) {
7472
return $expression;

src/Symfony/Component/ExpressionLanguage/Lexer.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ class Lexer
2121
/**
2222
* Tokenizes an expression.
2323
*
24-
* @return TokenStream
25-
*
2624
* @throws SyntaxError
2725
*/
28-
public function tokenize(string $expression)
26+
public function tokenize(string $expression): TokenStream
2927
{
3028
$expression = str_replace(["\r", "\n", "\t", "\v", "\f"], ' ', $expression);
3129
$cursor = 0;

src/Symfony/Component/ExpressionLanguage/Parser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(array $functions)
9090
*
9191
* @throws SyntaxError
9292
*/
93-
public function parse(TokenStream $stream, array $names = [])
93+
public function parse(TokenStream $stream, array $names = []): Node\Node
9494
{
9595
$this->lint = false;
9696

src/Symfony/Component/ExpressionLanguage/Token.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,8 @@ public function __toString(): string
5050

5151
/**
5252
* Tests the current token for a type and/or a value.
53-
*
54-
* @return bool
5553
*/
56-
public function test(string $type, string $value = null)
54+
public function test(string $type, string $value = null): bool
5755
{
5856
return $this->type === $type && (null === $value || $this->value == $value);
5957
}

src/Symfony/Component/ExpressionLanguage/TokenStream.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ public function expect(string $type, string $value = null, string $message = nul
6767

6868
/**
6969
* Checks if end of stream was reached.
70-
*
71-
* @return bool
7270
*/
73-
public function isEOF()
71+
public function isEOF(): bool
7472
{
7573
return Token::EOF_TYPE === $this->current->type;
7674
}

0 commit comments

Comments
 (0)