-
Notifications
You must be signed in to change notification settings - Fork 385
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
Registry: Allow using class-strings instead of magic strings #737
Conversation
Not sure if this is worth pursuing, the registry is pretty ugly design pattern. Ideally we would switch to constructor-based dependency injection. But that would probably be a large BC break. |
What do you think about implementing PSR-11 container interface with Inside This way we could get rid of the old Registry in v2 without breaking BC. |
That might standardize the interface but I probably would not bother. My actual beef is with the registry itself as it is an instance of the service locator (anti)pattern. PSR-11 itself warns against that. If SimplePie was part of my project, I would probably remove registry altogether, turn as much classes as possible into plain data objects that could be created directly with
If someone started passing custom
That feels a bit icky to me. Those are independent functions that only need to be in a class because PHP does not support function autoloading. I would probably go with adding constructor to |
Yes, you are right. Maybe we should keep the removal of the
Still, there are places like this one right now:
https://github.com/simplepie/simplepie/blob/1.6.0/library/SimplePie.php#L1441 But I agree. We could move the functionality to a new |
@jtojnar I would like to see this PR merged. Are you interested in finalize it or could I do that? |
2d757d2
to
ad00b5c
Compare
This will make it much simpler to validate typos using static analysis.
Converted using the following command: sed -i -E "s/(registry->(register|get_class|create|call)\\()'([^']+)'/\\1\\3::class/g;s/Content_Type_Sniffer::class/Content\\\\Type\\\\Sniffer::class/g;s/Parse_Date::class/Parse\\\\Date::class/g;s/XML_Declaration_Parser::class/XML\\\\Declaration\\\\Parser::class/g" $(find src -name '*.php')
ad00b5c
to
3f5b721
Compare
@Art4 I have rebased the patchset but probably will not have time to make it mergeable anytime soon. Feel free to take over. |
Thank you very much. 👍 |
@mblaney This PR can be closed. |
Depends on #736
This will make it much simpler to validate typos using static analysis.