Skip to content

Commit 8ed561b

Browse files
wouterjnicolas-grekas
authored andcommitted
[Components] Convert to native return types
1 parent 754445c commit 8ed561b

18 files changed

+66
-238
lines changed

Annotation/Route.php

+19-76
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,17 @@ public function __construct(
7676
}
7777
}
7878

79-
/**
80-
* @return void
81-
*/
82-
public function setPath(string $path)
79+
public function setPath(string $path): void
8380
{
8481
$this->path = $path;
8582
}
8683

87-
/**
88-
* @return string|null
89-
*/
90-
public function getPath()
84+
public function getPath(): ?string
9185
{
9286
return $this->path;
9387
}
9488

95-
/**
96-
* @return void
97-
*/
98-
public function setLocalizedPaths(array $localizedPaths)
89+
public function setLocalizedPaths(array $localizedPaths): void
9990
{
10091
$this->localizedPaths = $localizedPaths;
10192
}
@@ -105,130 +96,82 @@ public function getLocalizedPaths(): array
10596
return $this->localizedPaths;
10697
}
10798

108-
/**
109-
* @return void
110-
*/
111-
public function setHost(string $pattern)
99+
public function setHost(string $pattern): void
112100
{
113101
$this->host = $pattern;
114102
}
115103

116-
/**
117-
* @return string|null
118-
*/
119-
public function getHost()
104+
public function getHost(): ?string
120105
{
121106
return $this->host;
122107
}
123108

124-
/**
125-
* @return void
126-
*/
127-
public function setName(string $name)
109+
public function setName(string $name): void
128110
{
129111
$this->name = $name;
130112
}
131113

132-
/**
133-
* @return string|null
134-
*/
135-
public function getName()
114+
public function getName(): ?string
136115
{
137116
return $this->name;
138117
}
139118

140-
/**
141-
* @return void
142-
*/
143-
public function setRequirements(array $requirements)
119+
public function setRequirements(array $requirements): void
144120
{
145121
$this->requirements = $requirements;
146122
}
147123

148-
/**
149-
* @return array
150-
*/
151-
public function getRequirements()
124+
public function getRequirements(): array
152125
{
153126
return $this->requirements;
154127
}
155128

156-
/**
157-
* @return void
158-
*/
159-
public function setOptions(array $options)
129+
public function setOptions(array $options): void
160130
{
161131
$this->options = $options;
162132
}
163133

164-
/**
165-
* @return array
166-
*/
167-
public function getOptions()
134+
public function getOptions(): array
168135
{
169136
return $this->options;
170137
}
171138

172-
/**
173-
* @return void
174-
*/
175-
public function setDefaults(array $defaults)
139+
public function setDefaults(array $defaults): void
176140
{
177141
$this->defaults = $defaults;
178142
}
179143

180-
/**
181-
* @return array
182-
*/
183-
public function getDefaults()
144+
public function getDefaults(): array
184145
{
185146
return $this->defaults;
186147
}
187148

188-
/**
189-
* @return void
190-
*/
191-
public function setSchemes(array|string $schemes)
149+
public function setSchemes(array|string $schemes): void
192150
{
193151
$this->schemes = (array) $schemes;
194152
}
195153

196-
/**
197-
* @return array
198-
*/
199-
public function getSchemes()
154+
public function getSchemes(): array
200155
{
201156
return $this->schemes;
202157
}
203158

204-
/**
205-
* @return void
206-
*/
207-
public function setMethods(array|string $methods)
159+
public function setMethods(array|string $methods): void
208160
{
209161
$this->methods = (array) $methods;
210162
}
211163

212-
/**
213-
* @return array
214-
*/
215-
public function getMethods()
164+
public function getMethods(): array
216165
{
217166
return $this->methods;
218167
}
219168

220-
/**
221-
* @return void
222-
*/
223-
public function setCondition(?string $condition)
169+
public function setCondition(?string $condition): void
224170
{
225171
$this->condition = $condition;
226172
}
227173

228-
/**
229-
* @return string|null
230-
*/
231-
public function getCondition()
174+
public function getCondition(): ?string
232175
{
233176
return $this->condition;
234177
}

DependencyInjection/RoutingResolverPass.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ class RoutingResolverPass implements CompilerPassInterface
2525
{
2626
use PriorityTaggedServiceTrait;
2727

28-
/**
29-
* @return void
30-
*/
31-
public function process(ContainerBuilder $container)
28+
public function process(ContainerBuilder $container): void
3229
{
3330
if (false === $container->hasDefinition('routing.resolver')) {
3431
return;

Exception/MissingMandatoryParametersException.php

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class MissingMandatoryParametersException extends \InvalidArgumentException impl
2424

2525
/**
2626
* @param string[] $missingParameters
27-
* @param int $code
2827
*/
2928
public function __construct(string $routeName = '', array $missingParameters = [], int $code = 0, \Throwable $previous = null)
3029
{

Generator/ConfigurableRequirementsInterface.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,8 @@ interface ConfigurableRequirementsInterface
4040
/**
4141
* Enables or disables the exception on incorrect parameters.
4242
* Passing null will deactivate the requirements check completely.
43-
*
44-
* @return void
4543
*/
46-
public function setStrictRequirements(?bool $enabled);
44+
public function setStrictRequirements(?bool $enabled): void;
4745

4846
/**
4947
* Returns whether to throw an exception on incorrect parameters.

Generator/UrlGenerator.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ public function __construct(RouteCollection $routes, RequestContext $context, Lo
9191
$this->defaultLocale = $defaultLocale;
9292
}
9393

94-
/**
95-
* @return void
96-
*/
97-
public function setContext(RequestContext $context)
94+
public function setContext(RequestContext $context): void
9895
{
9996
$this->context = $context;
10097
}
@@ -104,10 +101,7 @@ public function getContext(): RequestContext
104101
return $this->context;
105102
}
106103

107-
/**
108-
* @return void
109-
*/
110-
public function setStrictRequirements(?bool $enabled)
104+
public function setStrictRequirements(?bool $enabled): void
111105
{
112106
$this->strictRequirements = $enabled;
113107
}

Loader/AnnotationClassLoader.php

+7-25
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ public function __construct(Reader $reader = null, string $env = null)
9292

9393
/**
9494
* Sets the annotation class to read route properties from.
95-
*
96-
* @return void
9795
*/
98-
public function setRouteAnnotationClass(string $class)
96+
public function setRouteAnnotationClass(string $class): void
9997
{
10098
$this->routeAnnotationClass = $class;
10199
}
@@ -160,10 +158,8 @@ public function load(mixed $class, string $type = null): RouteCollection
160158

161159
/**
162160
* @param RouteAnnotation $annot or an object that exposes a similar interface
163-
*
164-
* @return void
165161
*/
166-
protected function addRoute(RouteCollection $collection, object $annot, array $globals, \ReflectionClass $class, \ReflectionMethod $method)
162+
protected function addRoute(RouteCollection $collection, object $annot, array $globals, \ReflectionClass $class, \ReflectionMethod $method): void
167163
{
168164
if ($annot->getEnv() && $annot->getEnv() !== $this->env) {
169165
return;
@@ -253,10 +249,7 @@ public function supports(mixed $resource, string $type = null): bool
253249
return \is_string($resource) && preg_match('/^(?:\\\\?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+$/', $resource) && (!$type || \in_array($type, ['annotation', 'attribute'], true));
254250
}
255251

256-
/**
257-
* @return void
258-
*/
259-
public function setResolver(LoaderResolverInterface $resolver)
252+
public function setResolver(LoaderResolverInterface $resolver): void
260253
{
261254
}
262255

@@ -266,10 +259,8 @@ public function getResolver(): LoaderResolverInterface
266259

267260
/**
268261
* Gets the default route name for a class method.
269-
*
270-
* @return string
271262
*/
272-
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method)
263+
protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMethod $method): string
273264
{
274265
$name = str_replace('\\', '_', $class->name).'_'.$method->name;
275266
$name = \function_exists('mb_strtolower') && preg_match('//u', $name) ? mb_strtolower($name, 'UTF-8') : strtolower($name);
@@ -281,10 +272,7 @@ protected function getDefaultRouteName(\ReflectionClass $class, \ReflectionMetho
281272
return $name;
282273
}
283274

284-
/**
285-
* @return array
286-
*/
287-
protected function getGlobals(\ReflectionClass $class)
275+
protected function getGlobals(\ReflectionClass $class): array
288276
{
289277
$globals = $this->resetGlobals();
290278

@@ -366,18 +354,12 @@ private function resetGlobals(): array
366354
];
367355
}
368356

369-
/**
370-
* @return Route
371-
*/
372-
protected function createRoute(string $path, array $defaults, array $requirements, array $options, ?string $host, array $schemes, array $methods, ?string $condition)
357+
protected function createRoute(string $path, array $defaults, array $requirements, array $options, ?string $host, array $schemes, array $methods, ?string $condition): Route
373358
{
374359
return new Route($path, $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
375360
}
376361

377-
/**
378-
* @return void
379-
*/
380-
abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot);
362+
abstract protected function configureRoute(Route $route, \ReflectionClass $class, \ReflectionMethod $method, object $annot): void;
381363

382364
/**
383365
* @param \ReflectionClass|\ReflectionMethod $reflection

Loader/Configurator/CollectionConfigurator.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ public function __sleep(): array
4343
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
4444
}
4545

46-
/**
47-
* @return void
48-
*/
49-
public function __wakeup()
46+
public function __wakeup(): void
5047
{
5148
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
5249
}

Loader/Configurator/ImportConfigurator.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ public function __sleep(): array
3535
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
3636
}
3737

38-
/**
39-
* @return void
40-
*/
41-
public function __wakeup()
38+
public function __wakeup(): void
4239
{
4340
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
4441
}

Loader/XmlFileLoader.php

+3-9
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,9 @@ public function load(mixed $file, string $type = null): RouteCollection
6262
/**
6363
* Parses a node from a loaded XML file.
6464
*
65-
* @return void
66-
*
6765
* @throws \InvalidArgumentException When the XML is invalid
6866
*/
69-
protected function parseNode(RouteCollection $collection, \DOMElement $node, string $path, string $file)
67+
protected function parseNode(RouteCollection $collection, \DOMElement $node, string $path, string $file): void
7068
{
7169
if (self::NAMESPACE_URI !== $node->namespaceURI) {
7270
return;
@@ -102,11 +100,9 @@ public function supports(mixed $resource, string $type = null): bool
102100
/**
103101
* Parses a route and adds it to the RouteCollection.
104102
*
105-
* @return void
106-
*
107103
* @throws \InvalidArgumentException When the XML is invalid
108104
*/
109-
protected function parseRoute(RouteCollection $collection, \DOMElement $node, string $path)
105+
protected function parseRoute(RouteCollection $collection, \DOMElement $node, string $path): void
110106
{
111107
if ('' === $id = $node->getAttribute('id')) {
112108
throw new \InvalidArgumentException(sprintf('The <route> element in file "%s" must have an "id" attribute.', $path));
@@ -151,11 +147,9 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, st
151147
/**
152148
* Parses an import and adds the routes in the resource to the RouteCollection.
153149
*
154-
* @return void
155-
*
156150
* @throws \InvalidArgumentException When the XML is invalid
157151
*/
158-
protected function parseImport(RouteCollection $collection, \DOMElement $node, string $path, string $file)
152+
protected function parseImport(RouteCollection $collection, \DOMElement $node, string $path, string $file): void
159153
{
160154
/** @var \DOMElement $resourceElement */
161155
if (!($resource = $node->getAttribute('resource') ?: null) && $resourceElement = $node->getElementsByTagName('resource')[0] ?? null) {

0 commit comments

Comments
 (0)