Skip to content

Commit faffea9

Browse files
Replace more docblocks by type-hints
1 parent 9d31989 commit faffea9

14 files changed

+21
-72
lines changed

CompiledRoute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ class CompiledRoute implements \Serializable
3737
* @param array $hostVariables An array of host variables
3838
* @param array $variables An array of variables (variables defined in the path and in the host patterns)
3939
*/
40-
public function __construct($staticPrefix, $regex, array $tokens, array $pathVariables, $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
40+
public function __construct(string $staticPrefix, string $regex, array $tokens, array $pathVariables, string $hostRegex = null, array $hostTokens = array(), array $hostVariables = array(), array $variables = array())
4141
{
42-
$this->staticPrefix = (string) $staticPrefix;
42+
$this->staticPrefix = $staticPrefix;
4343
$this->regex = $regex;
4444
$this->tokens = $tokens;
4545
$this->pathVariables = $pathVariables;

DependencyInjection/RoutingResolverPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RoutingResolverPass implements CompilerPassInterface
2828
private $resolverServiceId;
2929
private $loaderTag;
3030

31-
public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader')
31+
public function __construct(string $resolverServiceId = 'routing.resolver', string $loaderTag = 'routing.loader')
3232
{
3333
$this->resolverServiceId = $resolverServiceId;
3434
$this->loaderTag = $loaderTag;

Exception/MethodNotAllowedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn
2222
{
2323
protected $allowedMethods = array();
2424

25-
public function __construct(array $allowedMethods, $message = null, $code = 0, \Exception $previous = null)
25+
public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Exception $previous = null)
2626
{
2727
$this->allowedMethods = array_map('strtoupper', $allowedMethods);
2828

Loader/Configurator/CollectionConfigurator.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CollectionConfigurator
2424

2525
private $parent;
2626

27-
public function __construct(RouteCollection $parent, $name)
27+
public function __construct(RouteCollection $parent, string $name)
2828
{
2929
$this->parent = $parent;
3030
$this->name = $name;
@@ -40,13 +40,8 @@ public function __destruct()
4040

4141
/**
4242
* Adds a route.
43-
*
44-
* @param string $name
45-
* @param string $path
46-
*
47-
* @return RouteConfigurator
4843
*/
49-
final public function add($name, $path)
44+
final public function add(string $name, string $path): RouteConfigurator
5045
{
5146
$this->collection->add($this->name.$name, $route = clone $this->route);
5247

@@ -66,11 +61,9 @@ final public function collection($name = '')
6661
/**
6762
* Sets the prefix to add to the path of all child routes.
6863
*
69-
* @param string $prefix
70-
*
7164
* @return $this
7265
*/
73-
final public function prefix($prefix)
66+
final public function prefix(string $prefix)
7467
{
7568
$this->route->setPath($prefix);
7669

Loader/Configurator/ImportConfigurator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ public function __destruct()
3636
/**
3737
* Sets the prefix to add to the path of all child routes.
3838
*
39-
* @param string $prefix
40-
*
4139
* @return $this
4240
*/
43-
final public function prefix($prefix)
41+
final public function prefix(string $prefix)
4442
{
4543
$this->route->addPrefix($prefix);
4644

Loader/Configurator/RouteConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class RouteConfigurator
2222
use Traits\AddTrait;
2323
use Traits\RouteTrait;
2424

25-
public function __construct(RouteCollection $collection, Route $route, $name = '')
25+
public function __construct(RouteCollection $collection, Route $route, string $name = '')
2626
{
2727
$this->collection = $collection;
2828
$this->route = $route;

Loader/Configurator/RoutingConfigurator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RoutingConfigurator
2525
private $path;
2626
private $file;
2727

28-
public function __construct(RouteCollection $collection, PhpFileLoader $loader, $path, $file)
28+
public function __construct(RouteCollection $collection, PhpFileLoader $loader, string $path, string $file)
2929
{
3030
$this->collection = $collection;
3131
$this->loader = $loader;

Loader/Configurator/Traits/AddTrait.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@ trait AddTrait
2626

2727
/**
2828
* Adds a route.
29-
*
30-
* @param string $name
31-
* @param string $path
32-
*
33-
* @return RouteConfigurator
3429
*/
35-
final public function add($name, $path)
30+
final public function add(string $name, string $path): RouteConfigurator
3631
{
3732
$this->collection->add($this->name.$name, $route = new Route($path));
3833

@@ -41,13 +36,8 @@ final public function add($name, $path)
4136

4237
/**
4338
* Adds a route.
44-
*
45-
* @param string $name
46-
* @param string $path
47-
*
48-
* @return RouteConfigurator
4939
*/
50-
final public function __invoke($name, $path)
40+
final public function __invoke(string $name, string $path): RouteConfigurator
5141
{
5242
return $this->add($name, $path);
5343
}

Loader/Configurator/Traits/RouteTrait.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ final public function options(array $options)
6060
/**
6161
* Sets the condition.
6262
*
63-
* @param string $condition
64-
*
6563
* @return $this
6664
*/
67-
final public function condition($condition)
65+
final public function condition(string $condition)
6866
{
6967
$this->route->setCondition($condition);
7068

@@ -74,11 +72,9 @@ final public function condition($condition)
7472
/**
7573
* Sets the pattern for the host.
7674
*
77-
* @param string $pattern
78-
*
7975
* @return $this
8076
*/
81-
final public function host($pattern)
77+
final public function host(string $pattern)
8278
{
8379
$this->route->setHost($pattern);
8480

Matcher/Dumper/StaticPrefixCollection.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ private function groupWithItem($item, string $prefix, $route)
132132

133133
/**
134134
* Checks whether a prefix can be contained within the group.
135-
*
136-
* @param string $prefix
137-
*
138-
* @return bool Whether a prefix could belong in a given group
139135
*/
140136
private function accepts(string $prefix): bool
141137
{
@@ -145,9 +141,6 @@ private function accepts(string $prefix): bool
145141
/**
146142
* Detects whether there's a common prefix relative to the group prefix and returns it.
147143
*
148-
* @param string $prefix
149-
* @param string $anotherPrefix
150-
*
151144
* @return false|string A common prefix, longer than the base/group prefix, or false when none available
152145
*/
153146
private function detectCommonPrefix(string $prefix, string $anotherPrefix)
@@ -223,8 +216,6 @@ private function shouldBeInlined(): bool
223216
/**
224217
* Guards against adding incompatible prefixes in a group.
225218
*
226-
* @param string $prefix
227-
*
228219
* @throws \LogicException when a prefix does not belong in a group
229220
*/
230221
private function guardAgainstAddingNotAcceptedRoutes(string $prefix)

0 commit comments

Comments
 (0)