Skip to content
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

Support Attributes #194

Closed
wants to merge 15 commits into from
Closed

Support Attributes #194

wants to merge 15 commits into from

Conversation

xepozz
Copy link
Member

@xepozz xepozz commented Mar 21, 2023

Q A
Is bugfix?
New feature? ✔️
Breaks BC? ✔️
Fixed issues #179 #193

@codecov
Copy link

codecov bot commented Mar 21, 2023

Codecov Report

Patch coverage: 87.34% and project coverage change: -2.32 ⚠️

Comparison is base (ee824c0) 97.57% compared to head (f0164db) 95.26%.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #194      +/-   ##
============================================
- Coverage     97.57%   95.26%   -2.32%     
+ Complexity      139      137       -2     
============================================
  Files             9        9              
  Lines           413      422       +9     
============================================
- Hits            403      402       -1     
- Misses           10       20      +10     
Impacted Files Coverage Δ
src/MatchingResult.php 94.73% <81.81%> (-5.27%) ⬇️
src/Route.php 94.52% <87.69%> (-5.48%) ⬇️
src/Group.php 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@samdark samdark added type:enhancement Enhancement status:code review The pull request needs review. labels Mar 22, 2023
@samdark
Copy link
Member

samdark commented Mar 22, 2023

Need docs and additional tests.


Only two properties are required: `methods` and `pattern`. The rest properties are optional.

> Parsing attributes is up to user. The package does not provide a solution for parsing and constructing routes tree.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to link to the guide on how to achieve colleccting attributes or to describe it right here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have any attributes collectors. I'll add it later if we merge this example

src/Route.php Outdated Show resolved Hide resolved
src/Route.php Outdated Show resolved Hide resolved
@samdark
Copy link
Member

samdark commented Mar 28, 2023

Overall I like it 👍

src/Route.php Outdated Show resolved Hide resolved
src/Route.php Show resolved Hide resolved
}

private function buildDispatcher(
?MiddlewareDispatcher $dispatcher,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
?MiddlewareDispatcher $dispatcher,
MiddlewareDispatcher $dispatcher,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dispatcher is nullable

Comment on lines +113 to +116
if ($dispatcher === null) {
throw new RuntimeException(sprintf('There is no dispatcher in the route %s.', $route->getData('name')));
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if ($dispatcher === null) {
throw new RuntimeException(sprintf('There is no dispatcher in the route %s.', $route->getData('name')));
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

if ($this->dispatcher !== null && !$this->route->getData('hasDispatcher')) {
$this->route->injectDispatcher($this->dispatcher);
if ($dispatcher->hasMiddlewares()) {
return $dispatcher;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Router pass middlware dispatcher to MatchingResult and this dispatcher almost always contain middlewares. In this case route middlewares will not work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you are saying

@samdark
Copy link
Member

samdark commented Apr 2, 2023

See #196

@xepozz
Copy link
Member Author

xepozz commented Jun 9, 2023

Closed in favor of #196

@xepozz xepozz closed this Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review. type:enhancement Enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants