Skip to content

Commit c2c41c2

Browse files
committed
Route, SimpleRouter: flags is deprecated
1 parent acda0f3 commit c2c41c2

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/Application/Routers/Route.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public function __construct(string $mask, $metadata = [], int $flags = 0)
6666
];
6767
}
6868

69+
if ($flags) {
70+
trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::add(..., $flags) instead.', E_USER_DEPRECATED);
71+
}
72+
6973
$this->defaultMeta = $this->defaultMeta + self::UI_META;
7074
$this->flags = $flags;
7175
parent::__construct($mask, $metadata);
@@ -141,11 +145,10 @@ public function getConstantParameters(): array
141145
}
142146

143147

144-
/**
145-
* Returns flags.
146-
*/
148+
/** @deprecated */
147149
public function getFlags(): int
148150
{
151+
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
149152
return $this->flags;
150153
}
151154

src/Application/Routers/SimpleRouter.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public function __construct($defaults = [], int $flags = 0)
4141

4242
if (isset($defaults[self::MODULE_KEY])) {
4343
throw new Nette\DeprecatedException(__METHOD__ . '() parameter module is deprecated, use RouteList::withModule() instead.');
44+
} elseif ($flags) {
45+
trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::add(..., $flags) instead.', E_USER_DEPRECATED);
4446
}
4547

4648
$this->flags = $flags;
@@ -60,11 +62,10 @@ public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?stri
6062
}
6163

6264

63-
/**
64-
* Returns flags.
65-
*/
65+
/** @deprecated */
6666
public function getFlags(): int
6767
{
68+
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
6869
return $this->flags;
6970
}
7071
}

tests/Routers/Route.oneWay.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php';
1414
require __DIR__ . '/Route.php';
1515

1616

17-
$route = new Route('<presenter>/<action>', [
17+
@$route = new Route('<presenter>/<action>', [ // @ is deprecated
1818
'presenter' => 'Default',
1919
'action' => 'default',
2020
], Route::ONE_WAY);

0 commit comments

Comments
 (0)