-
-
Couldn't load subscription status.
- Fork 112
Router: Have a routes collection interface & support in Tracy router panel #94
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
base: master
Are you sure you want to change the base?
Conversation
|
Personally, I like this idea. :) 👍 |
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 not extend Traversable?
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 not extend IRouter?
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.
User-land code can't extend Traversable directly.
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.
Interface can extend, but class can't implement.
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.
This is funny:
this works:
interface A extends Traversable
{}
class B implements IteratorAggregate, A
{
function getIterator() {}
}this triggers Fatal error: Class B must implement interface Traversable as part of either Iterator or IteratorAggregate:
interface A extends Traversable
{}
class B implements A, IteratorAggregate
{
function getIterator() {}
}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 have encountered this (the need to have interfaces in the correct order) when developing the PR and it is exactly the reason I won't implement it using Traversable.
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.
It is documented http://php.net/class.traversable
|
I dislike the |
|
Well, it is required by the Panel. There's not much I can do about it. You could say the same about the RouteList itself where its sole purpose is to be printed by the panel. |
8e097dc to
e4eb640
Compare
7f051bf to
f87df33
Compare
9725b1d to
9869e52
Compare
18f376d to
3fe619f
Compare
20a93ca to
08cbdeb
Compare
7ee10c9 to
39bb092
Compare
8eb9618 to
5d63a8d
Compare
c7531dc to
b7a311f
Compare
12d577b to
e04c0e1
Compare
7b1ec30 to
3adfa43
Compare
c73b255 to
9e7cd60
Compare
ea11e9d to
8ff194f
Compare
|
I like it. Could we merge it, rebase it or close it? |
Currently, the only way to have a collection of routes and have them displayed in the Tracy panel is to use the
RouteListclass.This PR generalizes this logic to allow developers to implement their own route collections maybe with some logic inside (the
RouteListis just a simple hashmap), maybe immutable (RouteListis mutable), etc. It comes from our use case but I believe it could be useful for others, too.IteratorAggregate(which is the easiest way to implement aTraversable) and adds thegetModule()method that is required by the Tracy panel.RouteListis implemented, it can implement this new interface without any changes.instanceoftypecheck in the Panel to display a routes collection.