-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring + Tests + MSI 100% #22
Conversation
vjik
commented
Nov 24, 2024
Q | A |
---|---|
Is bugfix? | ✔️ |
New feature? | ❌ |
Breaks BC? | ❌ |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #22 +/- ##
==========================================
Coverage ? 100.00%
Complexity ? 22
==========================================
Files ? 1
Lines ? 91
Branches ? 0
==========================================
Hits ? 91
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. |
src/FileRouter.php
Outdated
return; | ||
} | ||
|
||
$directoryPath = $matches[1]; | ||
$controllerName = $matches[2]; | ||
[$_, $directoryPath, $controllerName] = $matches; |
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.
I'd leave it as it was before
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.
Replaced to [, $directoryPath, $controllerName] = $matches;
src/FileRouter.php
Outdated
$path, | ||
); | ||
|
||
if (!preg_match('#^(.*?)/([^/]+)/?$#', $controllerName, $matches)) { | ||
if (!preg_match('#^/?(.*?)/([^/]+)/?$#', $controllerName, $matches)) { |
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.
Why?
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.
That enables /
prefixing controller name. Use-case for that is interesting.
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.
Here $controllerName
contains path with uppercased first symbols. Renamed it to $pathAsNamespace
.
This regexp should be valid for paths with one and more items (/user
, /user/profile
, /user/profile/view
).
{ | ||
return str_replace( |
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.
As far as I remember there were some Windows cases where such operations are necessary to make the router work correctly
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.
Seems, path always use /
. See https://github.com/php-fig/http-message/blob/402d35bcb92c70c026d1a6a9883f06b2ead23d71/src/UriInterface.php#L135