From c2c41c28f012da670a28bad15c50fa8549e08eae Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 10 Mar 2020 21:12:12 +0100 Subject: [PATCH] Route, SimpleRouter: flags is deprecated --- src/Application/Routers/Route.php | 9 ++++++--- src/Application/Routers/SimpleRouter.php | 7 ++++--- tests/Routers/Route.oneWay.phpt | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Application/Routers/Route.php b/src/Application/Routers/Route.php index 8c19839be..d6171ff13 100644 --- a/src/Application/Routers/Route.php +++ b/src/Application/Routers/Route.php @@ -66,6 +66,10 @@ public function __construct(string $mask, $metadata = [], int $flags = 0) ]; } + if ($flags) { + trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::add(..., $flags) instead.', E_USER_DEPRECATED); + } + $this->defaultMeta = $this->defaultMeta + self::UI_META; $this->flags = $flags; parent::__construct($mask, $metadata); @@ -141,11 +145,10 @@ public function getConstantParameters(): array } - /** - * Returns flags. - */ + /** @deprecated */ public function getFlags(): int { + trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED); return $this->flags; } diff --git a/src/Application/Routers/SimpleRouter.php b/src/Application/Routers/SimpleRouter.php index f4f298bc1..3dde8b6f0 100644 --- a/src/Application/Routers/SimpleRouter.php +++ b/src/Application/Routers/SimpleRouter.php @@ -41,6 +41,8 @@ public function __construct($defaults = [], int $flags = 0) if (isset($defaults[self::MODULE_KEY])) { throw new Nette\DeprecatedException(__METHOD__ . '() parameter module is deprecated, use RouteList::withModule() instead.'); + } elseif ($flags) { + trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::add(..., $flags) instead.', E_USER_DEPRECATED); } $this->flags = $flags; @@ -60,11 +62,10 @@ public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?stri } - /** - * Returns flags. - */ + /** @deprecated */ public function getFlags(): int { + trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED); return $this->flags; } } diff --git a/tests/Routers/Route.oneWay.phpt b/tests/Routers/Route.oneWay.phpt index 2203ea080..c9578d790 100644 --- a/tests/Routers/Route.oneWay.phpt +++ b/tests/Routers/Route.oneWay.phpt @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php'; require __DIR__ . '/Route.php'; -$route = new Route('/', [ +@$route = new Route('/', [ // @ is deprecated 'presenter' => 'Default', 'action' => 'default', ], Route::ONE_WAY);