Skip to content

Commit e04c0e1

Browse files
committed
Router::$defaultFlags and flag SECURED are deprecated [Closes nette/routing#13]
1 parent 81ebb2d commit e04c0e1

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/Application/Routers/Route.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Route implements Application\IRouter
4141
PATH_OPTIONAL = 1,
4242
CONSTANT = 2;
4343

44-
/** @var int */
44+
/** @deprecated */
4545
public static $defaultFlags = 0;
4646

4747
/** @var array */
@@ -134,6 +134,11 @@ public function __construct($mask, $metadata = [], $flags = 0)
134134

135135
$this->flags = $flags | static::$defaultFlags;
136136
$this->setMask($mask, $metadata);
137+
if (static::$defaultFlags) {
138+
trigger_error('Route::$defaultFlags is deprecated, router by default keeps the used protocol.', E_USER_DEPRECATED);
139+
} elseif ($this->type !== self::HOST && $flags & self::SECURED) {
140+
trigger_error('Router::SECURED is deprecated for routes without host, router by default keeps the used protocol.', E_USER_DEPRECATED);
141+
}
137142
}
138143

139144

src/Application/Routers/SimpleRouter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ public function __construct($defaults = [], $flags = 0)
5555

5656
$this->defaults = $defaults;
5757
$this->flags = $flags;
58+
if ($flags & self::SECURED) {
59+
trigger_error('IRouter::SECURED is deprecated, router by default keeps the used protocol.', E_USER_DEPRECATED);
60+
}
5861
}
5962

6063

tests/Routers/Route.secured.phpt

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

1717

18-
$route = new Route('<param>', [
18+
$route = @new Route('<param>', [ // @ SECURED is deprecated
1919
'presenter' => 'Presenter',
2020
]);
2121

tests/Routers/SimpleRouter.secured.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use Tester\Assert;
1212
require __DIR__ . '/../bootstrap.php';
1313

1414

15-
$router = new Application\Routers\SimpleRouter([
15+
$router = @new Application\Routers\SimpleRouter([ // @ SECURED is deprecated
1616
'id' => 12,
1717
'any' => 'anyvalue',
1818
], Application\Routers\SimpleRouter::SECURED);

0 commit comments

Comments
 (0)