-
Notifications
You must be signed in to change notification settings - Fork 18
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
| "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
| * @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
| * @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
| * @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
| * @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
| * @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
| * @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\RequestInterfacewill be dropped as too incompatible with PSR-7 and support for the non-http routing withZend\Stdlib\RequestInterfacewill 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.