User tests: Successful: Unsuccessful:
As PSR-0 is deprecated, this PR offers to register namespaces also for PSR-4. The plan is to remove support for PSR-0 in J4 probably.
Maintainer review.
Ping @wilsonge
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
You cannot use both PSR-4 and PSR-0 code at the same time. So are we going to be stuck using PSR-0 code for another 5 years until composer removes support?
You can use both. Look at our Framework packages as an example. Are you saying I cannot install joomla/application
and joomla/session
together because the former uses PSR-4 and the latter PSR-0?
What you cannot do is register a path that's designed for PSR-4 support to a PSR-0 autoloader or vice versa. But you can most assuredly have an autoloader for each variant.
No but you must register each namespace with the relevant autoloader. Are we really going to introduce a registerPSR4Namespace
method to register those namespaces differently.
I would suggest for 4.0 that you support both. Otherwise you're making the 4.0 upgrade path more complicated for the sake of it.
Either way I will now update the patch tester to isolate itself from the core autoloader to prevent possible unneeded breakage either now or in the future.
Labels |
Added:
?
Removed: ? |
Travis error:
Merging on review, given this is never going to get tests and we need it to progress in the sprint
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-01-22 11:34:10 |
Closed_By | ⇒ | wilsonge |
Thanks!
Why can't both be supported? True that PSR-0 is deprecated but that doesn't mean it is unusable. When I see a platform like Composer deprecate/drop PSR-0 support I might find this acceptable but for now I don't see any reason to do anything but add a deprecation notice and leave it be until the greater PHP ecosystem drops it in full.
Also, this change will 100% break the patch tester component because it does use the PSR-0 autoloader as I've namespaced the component classes. The only way to therefore create a 3.x/4.x compatible build is to ship my own Composer autoloader since there won't be a path that allows me to load namespaced code in JLoader compatible with both versions.