-
Notifications
You must be signed in to change notification settings - Fork 20
Router rewrite for PSR-7 #40
base: develop
Are you sure you want to change the base?
Conversation
b19ed4a
to
c5cfea4
Compare
f1ed732
to
1eba2d3
Compare
Small note: |
Routes doing partial match conditionally and depending on the concrete implementation are violating |
f6e49ca
to
bf40d4f
Compare
@@ -18,20 +18,18 @@ | |||
"forum": "https://discourse.zendframework.com/c/questions/components" | |||
}, | |||
"require": { | |||
"php": "^5.6 || ^7.0", | |||
"php": "^7.1", | |||
"container-interop/container-interop": "^1.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use psr/container (PSR-11), or we need first SMv4?
src/Route/Regex.php
Outdated
@@ -54,7 +61,7 @@ class Regex implements RouteInterface | |||
* @param string $spec | |||
* @param array $defaults | |||
*/ | |||
public function __construct($regex, $spec, array $defaults = []) | |||
public function __construct(string $regex, $spec, array $defaults = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also have typehint on $spec
? In PHPDocs I can see "string" only.
src/Route/Scheme.php
Outdated
@@ -51,7 +58,7 @@ public function __construct($scheme, array $defaults = []) | |||
* @return Scheme | |||
* @throws Exception\InvalidArgumentException | |||
*/ | |||
public static function factory($options = []) | |||
public static function factory($options = []) : RouteInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have "iterable" type hint here?
src/Route/Segment.php
Outdated
@@ -121,7 +128,7 @@ public function __construct($route, array $constraints = [], array $defaults = [ | |||
* @return Segment | |||
* @throws Exception\InvalidArgumentException | |||
*/ | |||
public static function factory($options = []) | |||
public static function factory($options = []) : RouteInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"iterable" typehint here?
src/Route/Segment.php
Outdated
@@ -154,7 +161,7 @@ public static function factory($options = []) | |||
* @return array | |||
* @throws Exception\RuntimeException | |||
*/ | |||
protected function parseRouteDefinition($def) | |||
protected function parseRouteDefinition($def) : array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"string" typehint on param
src/Route/Segment.php
Outdated
@@ -229,7 +236,7 @@ protected function parseRouteDefinition($def) | |||
* @param int $groupIndex | |||
* @return string | |||
*/ | |||
protected function buildRegex(array $parts, array $constraints, &$groupIndex = 1) | |||
protected function buildRegex(array $parts, array $constraints, &$groupIndex = 1) : string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add type hint on the last param here, please?
src/SimpleRouteStack.php
Outdated
@@ -64,7 +66,7 @@ public function __construct(RoutePluginManager $routePluginManager = null) | |||
* @return SimpleRouteStack | |||
* @throws Exception\InvalidArgumentException | |||
*/ | |||
public static function factory($options = []) | |||
public static function factory($options = []) : RouteInterface |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... why not "SimpleRouteStack" as return type in signature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not possible
bf40d4f
to
89619be
Compare
b0dea47
to
08f6307
Compare
This repository has been closed and moved to laminas/laminas-router; a new issue has been opened at laminas/laminas-router#6. |
This repository has been moved to laminas/laminas-router. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:
|
Work in progress
Goal of the rewrite is to switch component to the native support of PSR-7.
Console routing and http request routing are too different. Common interface proved to be limiting and of little practical value: routes were not shared between the two and consumers had to accept one and outright reject another in most cases.
Next implementation of zend-mvc will be PSR-7 based as well and zend-mvc-console will be dropped.
For that reason, support for
Zend\Http\RequestInterface
will be dropped as too incompatible with PSR-7 and support for the non-http routing withZend\Stdlib\RequestInterface
will not be retained as impractical.Effectively that will make zend-router a PSR-7 only router.
Also, this PR bumps minimum php to 7.1, introduces strict types, scalar and return typehinting
Note: this PR is a subject for rebases and commit squashes. Ask before using as a basis for your work.