Skip to content

Commit 12d577b

Browse files
committed
Router::$defaultFlags and flag SECURED are deprecated [Closes nette/routing#13]
1 parent a1ed037 commit 12d577b

File tree

5 files changed

+12
-4
lines changed

5 files changed

+12
-4
lines changed

src/Application/IRouter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ interface IRouter
1818
/** only matching route */
1919
const ONE_WAY = 0b0001;
2020

21-
/** HTTPS route */
21+
/** @deprecated */
2222
const SECURED = 0b0010;
2323

2424
/**

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 */
@@ -132,6 +132,11 @@ public function __construct($mask, $metadata = [], $flags = 0)
132132
];
133133
}
134134

135+
if (static::$defaultFlags) {
136+
trigger_error('Route::$defaultFlags is deprecated, router by default keeps the used protocol.', E_USER_DEPRECATED);
137+
} elseif ($flags & self::SECURED) {
138+
trigger_error('IRouter::SECURED is deprecated, router by default keeps the used protocol.', E_USER_DEPRECATED);
139+
}
135140
$this->flags = $flags | static::$defaultFlags;
136141
$this->setMask($mask, $metadata);
137142
}

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
@@ -13,7 +13,7 @@ require __DIR__ . '/../bootstrap.php';
1313
require __DIR__ . '/Route.php';
1414

1515

16-
$route = new Route('<param>', [
16+
$route = @new Route('<param>', [ // @ SECURED is deprecated
1717
'presenter' => 'Presenter',
1818
], Route::SECURED);
1919

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)