Skip to content

Commit

Permalink
Router::$defaultFlags and flag SECURED are deprecated [Closes nette/r…
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 20, 2016
1 parent 81ebb2d commit e04c0e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/Application/Routers/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Route implements Application\IRouter
PATH_OPTIONAL = 1,
CONSTANT = 2;

/** @var int */
/** @deprecated */
public static $defaultFlags = 0;

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

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


Expand Down
3 changes: 3 additions & 0 deletions src/Application/Routers/SimpleRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function __construct($defaults = [], $flags = 0)

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


Expand Down
2 changes: 1 addition & 1 deletion tests/Routers/Route.secured.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/Route.php';


$route = new Route('<param>', [
$route = @new Route('<param>', [ // @ SECURED is deprecated
'presenter' => 'Presenter',
]);

Expand Down
2 changes: 1 addition & 1 deletion tests/Routers/SimpleRouter.secured.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use Tester\Assert;
require __DIR__ . '/../bootstrap.php';


$router = new Application\Routers\SimpleRouter([
$router = @new Application\Routers\SimpleRouter([ // @ SECURED is deprecated
'id' => 12,
'any' => 'anyvalue',
], Application\Routers\SimpleRouter::SECURED);
Expand Down

0 comments on commit e04c0e1

Please sign in to comment.