Skip to content

Commit dc3a9a0

Browse files
Narrow existing return types on private/internal/final/test methods
1 parent 9400562 commit dc3a9a0

File tree

5 files changed

+19
-58
lines changed

5 files changed

+19
-58
lines changed

Loader/Configurator/CollectionConfigurator.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ final public function collection(string $name = ''): self
7575
* Sets the prefix to add to the path of all child routes.
7676
*
7777
* @param string|array $prefix the prefix, or the localized prefixes
78-
*
79-
* @return $this
8078
*/
81-
final public function prefix(string|array $prefix): self
79+
final public function prefix(string|array $prefix): static
8280
{
8381
if (\is_array($prefix)) {
8482
if (null === $this->parentPrefixes) {
@@ -108,10 +106,8 @@ final public function prefix(string|array $prefix): self
108106
* Sets the host to use for all child routes.
109107
*
110108
* @param string|array $host the host, or the localized hosts
111-
*
112-
* @return $this
113109
*/
114-
final public function host(string|array $host): self
110+
final public function host(string|array $host): static
115111
{
116112
$this->host = $host;
117113

Loader/Configurator/ImportConfigurator.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ public function __destruct()
5252
* Sets the prefix to add to the path of all child routes.
5353
*
5454
* @param string|array $prefix the prefix, or the localized prefixes
55-
*
56-
* @return $this
5755
*/
58-
final public function prefix(string|array $prefix, bool $trailingSlashOnRoot = true): self
56+
final public function prefix(string|array $prefix, bool $trailingSlashOnRoot = true): static
5957
{
6058
$this->addPrefix($this->route, $prefix, $trailingSlashOnRoot);
6159

@@ -64,10 +62,8 @@ final public function prefix(string|array $prefix, bool $trailingSlashOnRoot = t
6462

6563
/**
6664
* Sets the prefix to add to the name of all child routes.
67-
*
68-
* @return $this
6965
*/
70-
final public function namePrefix(string $namePrefix): self
66+
final public function namePrefix(string $namePrefix): static
7167
{
7268
$this->route->addNamePrefix($namePrefix);
7369

@@ -78,10 +74,8 @@ final public function namePrefix(string $namePrefix): self
7874
* Sets the host to use for all child routes.
7975
*
8076
* @param string|array $host the host, or the localized hosts
81-
*
82-
* @return $this
8377
*/
84-
final public function host(string|array $host): self
78+
final public function host(string|array $host): static
8579
{
8680
$this->addHost($this->route, $host);
8781

Loader/Configurator/RouteConfigurator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ public function __construct(RouteCollection $collection, RouteCollection $route,
3737
* Sets the host to use for all child routes.
3838
*
3939
* @param string|array $host the host, or the localized hosts
40-
*
41-
* @return $this
4240
*/
43-
final public function host(string|array $host): self
41+
final public function host(string|array $host): static
4442
{
4543
$this->addHost($this->route, $host);
4644

Loader/Configurator/RoutingConfigurator.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ final public function env(): ?string
6868
return $this->env;
6969
}
7070

71-
/**
72-
* @return static
73-
*/
74-
final public function withPath(string $path): self
71+
final public function withPath(string $path): static
7572
{
7673
$clone = clone $this;
7774
$clone->path = $clone->file = $path;

Loader/Configurator/Traits/RouteTrait.php

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ trait RouteTrait
2323

2424
/**
2525
* Adds defaults.
26-
*
27-
* @return $this
2826
*/
29-
final public function defaults(array $defaults): self
27+
final public function defaults(array $defaults): static
3028
{
3129
$this->route->addDefaults($defaults);
3230

@@ -35,10 +33,8 @@ final public function defaults(array $defaults): self
3533

3634
/**
3735
* Adds requirements.
38-
*
39-
* @return $this
4036
*/
41-
final public function requirements(array $requirements): self
37+
final public function requirements(array $requirements): static
4238
{
4339
$this->route->addRequirements($requirements);
4440

@@ -47,10 +43,8 @@ final public function requirements(array $requirements): self
4743

4844
/**
4945
* Adds options.
50-
*
51-
* @return $this
5246
*/
53-
final public function options(array $options): self
47+
final public function options(array $options): static
5448
{
5549
$this->route->addOptions($options);
5650

@@ -59,10 +53,8 @@ final public function options(array $options): self
5953

6054
/**
6155
* Whether paths should accept utf8 encoding.
62-
*
63-
* @return $this
6456
*/
65-
final public function utf8(bool $utf8 = true): self
57+
final public function utf8(bool $utf8 = true): static
6658
{
6759
$this->route->addOptions(['utf8' => $utf8]);
6860

@@ -71,10 +63,8 @@ final public function utf8(bool $utf8 = true): self
7163

7264
/**
7365
* Sets the condition.
74-
*
75-
* @return $this
7666
*/
77-
final public function condition(string $condition): self
67+
final public function condition(string $condition): static
7868
{
7969
$this->route->setCondition($condition);
8070

@@ -83,10 +73,8 @@ final public function condition(string $condition): self
8373

8474
/**
8575
* Sets the pattern for the host.
86-
*
87-
* @return $this
8876
*/
89-
final public function host(string $pattern): self
77+
final public function host(string $pattern): static
9078
{
9179
$this->route->setHost($pattern);
9280

@@ -98,10 +86,8 @@ final public function host(string $pattern): self
9886
* So an empty array means that any scheme is allowed.
9987
*
10088
* @param string[] $schemes
101-
*
102-
* @return $this
10389
*/
104-
final public function schemes(array $schemes): self
90+
final public function schemes(array $schemes): static
10591
{
10692
$this->route->setSchemes($schemes);
10793

@@ -113,10 +99,8 @@ final public function schemes(array $schemes): self
11399
* So an empty array means that any method is allowed.
114100
*
115101
* @param string[] $methods
116-
*
117-
* @return $this
118102
*/
119-
final public function methods(array $methods): self
103+
final public function methods(array $methods): static
120104
{
121105
$this->route->setMethods($methods);
122106

@@ -127,10 +111,8 @@ final public function methods(array $methods): self
127111
* Adds the "_controller" entry to defaults.
128112
*
129113
* @param callable|string|array $controller a callable or parseable pseudo-callable
130-
*
131-
* @return $this
132114
*/
133-
final public function controller(callable|string|array $controller): self
115+
final public function controller(callable|string|array $controller): static
134116
{
135117
$this->route->addDefaults(['_controller' => $controller]);
136118

@@ -139,10 +121,8 @@ final public function controller(callable|string|array $controller): self
139121

140122
/**
141123
* Adds the "_locale" entry to defaults.
142-
*
143-
* @return $this
144124
*/
145-
final public function locale(string $locale): self
125+
final public function locale(string $locale): static
146126
{
147127
$this->route->addDefaults(['_locale' => $locale]);
148128

@@ -151,10 +131,8 @@ final public function locale(string $locale): self
151131

152132
/**
153133
* Adds the "_format" entry to defaults.
154-
*
155-
* @return $this
156134
*/
157-
final public function format(string $format): self
135+
final public function format(string $format): static
158136
{
159137
$this->route->addDefaults(['_format' => $format]);
160138

@@ -163,10 +141,8 @@ final public function format(string $format): self
163141

164142
/**
165143
* Adds the "_stateless" entry to defaults.
166-
*
167-
* @return $this
168144
*/
169-
final public function stateless(bool $stateless = true): self
145+
final public function stateless(bool $stateless = true): static
170146
{
171147
$this->route->addDefaults(['_stateless' => $stateless]);
172148

0 commit comments

Comments
 (0)