Skip to content

Commit e9a0ce3

Browse files
Add return types - batch 5/n
1 parent eff619e commit e9a0ce3

39 files changed

+132
-138
lines changed

CompiledRoute.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ final public function unserialize(string $serialized)
9696
*
9797
* @return string The static prefix
9898
*/
99-
public function getStaticPrefix()
99+
public function getStaticPrefix(): string
100100
{
101101
return $this->staticPrefix;
102102
}
@@ -106,7 +106,7 @@ public function getStaticPrefix()
106106
*
107107
* @return string The regex
108108
*/
109-
public function getRegex()
109+
public function getRegex(): string
110110
{
111111
return $this->regex;
112112
}
@@ -116,7 +116,7 @@ public function getRegex()
116116
*
117117
* @return string|null The host regex or null
118118
*/
119-
public function getHostRegex()
119+
public function getHostRegex(): ?string
120120
{
121121
return $this->hostRegex;
122122
}
@@ -126,7 +126,7 @@ public function getHostRegex()
126126
*
127127
* @return array The tokens
128128
*/
129-
public function getTokens()
129+
public function getTokens(): array
130130
{
131131
return $this->tokens;
132132
}
@@ -136,7 +136,7 @@ public function getTokens()
136136
*
137137
* @return array The tokens
138138
*/
139-
public function getHostTokens()
139+
public function getHostTokens(): array
140140
{
141141
return $this->hostTokens;
142142
}
@@ -146,7 +146,7 @@ public function getHostTokens()
146146
*
147147
* @return array The variables
148148
*/
149-
public function getVariables()
149+
public function getVariables(): array
150150
{
151151
return $this->variables;
152152
}
@@ -156,7 +156,7 @@ public function getVariables()
156156
*
157157
* @return array The variables
158158
*/
159-
public function getPathVariables()
159+
public function getPathVariables(): array
160160
{
161161
return $this->pathVariables;
162162
}
@@ -166,7 +166,7 @@ public function getPathVariables()
166166
*
167167
* @return array The variables
168168
*/
169-
public function getHostVariables()
169+
public function getHostVariables(): array
170170
{
171171
return $this->hostVariables;
172172
}

Exception/MethodNotAllowedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(array $allowedMethods, string $message = '', int $co
3737
*
3838
* @return string[]
3939
*/
40-
public function getAllowedMethods()
40+
public function getAllowedMethods(): array
4141
{
4242
return $this->allowedMethods;
4343
}

Generator/CompiledUrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(array $compiledRoutes, RequestContext $context, Logg
3131
$this->defaultLocale = $defaultLocale;
3232
}
3333

34-
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH)
34+
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
3535
{
3636
$locale = $parameters['_locale']
3737
?? $this->context->getParameter('_locale')

Generator/ConfigurableRequirementsInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ public function setStrictRequirements(?bool $enabled);
4646
/**
4747
* Returns whether to throw an exception on incorrect parameters.
4848
* Null means the requirements check is deactivated completely.
49-
*
50-
* @return bool|null
5149
*/
52-
public function isStrictRequirements();
50+
public function isStrictRequirements(): ?bool;
5351
}

Generator/Dumper/CompiledUrlGeneratorDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function getCompiledRoutes(): array
4444
/**
4545
* {@inheritdoc}
4646
*/
47-
public function dump(array $options = [])
47+
public function dump(array $options = []): string
4848
{
4949
return <<<EOF
5050
<?php

Generator/Dumper/GeneratorDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(RouteCollection $routes)
3030
/**
3131
* {@inheritdoc}
3232
*/
33-
public function getRoutes()
33+
public function getRoutes(): RouteCollection
3434
{
3535
return $this->routes;
3636
}

Generator/Dumper/GeneratorDumperInterface.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ interface GeneratorDumperInterface
2626
*
2727
* @return string Executable code
2828
*/
29-
public function dump(array $options = []);
29+
public function dump(array $options = []): string;
3030

3131
/**
3232
* Gets the routes to dump.
33-
*
34-
* @return RouteCollection
3533
*/
36-
public function getRoutes();
34+
public function getRoutes(): RouteCollection;
3735
}

Generator/UrlGenerator.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function setContext(RequestContext $context)
101101
/**
102102
* {@inheritdoc}
103103
*/
104-
public function getContext()
104+
public function getContext(): RequestContext
105105
{
106106
return $this->context;
107107
}
@@ -117,15 +117,15 @@ public function setStrictRequirements(?bool $enabled)
117117
/**
118118
* {@inheritdoc}
119119
*/
120-
public function isStrictRequirements()
120+
public function isStrictRequirements(): ?bool
121121
{
122122
return $this->strictRequirements;
123123
}
124124

125125
/**
126126
* {@inheritdoc}
127127
*/
128-
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH)
128+
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
129129
{
130130
$route = null;
131131
$locale = $parameters['_locale']
@@ -165,10 +165,8 @@ public function generate(string $name, array $parameters = [], int $referenceTyp
165165
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
166166
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
167167
* it does not match the requirement
168-
*
169-
* @return string
170168
*/
171-
protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = [])
169+
protected function doGenerate(array $variables, array $defaults, array $requirements, array $tokens, array $parameters, string $name, int $referenceType, array $hostTokens, array $requiredSchemes = []): string
172170
{
173171
$variables = array_flip($variables);
174172
$mergedParams = array_replace($defaults, $this->context->getParameters(), $parameters);
@@ -334,7 +332,7 @@ protected function doGenerate(array $variables, array $defaults, array $requirem
334332
*
335333
* @return string The relative target path
336334
*/
337-
public static function getRelativePath(string $basePath, string $targetPath)
335+
public static function getRelativePath(string $basePath, string $targetPath): string
338336
{
339337
if ($basePath === $targetPath) {
340338
return '';

Generator/UrlGeneratorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface
7878
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because
7979
* it does not match the requirement
8080
*/
81-
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH);
81+
public function generate(string $name, array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string;
8282
}

Loader/AnnotationClassLoader.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function setRouteAnnotationClass(string $class)
106106
*
107107
* @throws \InvalidArgumentException When route can't be parsed
108108
*/
109-
public function load(mixed $class, string $type = null)
109+
public function load(mixed $class, string $type = null): RouteCollection
110110
{
111111
if (!class_exists($class)) {
112112
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
@@ -237,7 +237,7 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g
237237
/**
238238
* {@inheritdoc}
239239
*/
240-
public function supports(mixed $resource, string $type = null)
240+
public function supports(mixed $resource, string $type = null): bool
241241
{
242242
return \is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || 'annotation' === $type);
243243
}
@@ -252,7 +252,7 @@ public function setResolver(LoaderResolverInterface $resolver)
252252
/**
253253
* {@inheritdoc}
254254
*/
255-
public function getResolver()
255+
public function getResolver(): LoaderResolverInterface
256256
{
257257
}
258258

0 commit comments

Comments
 (0)