śr., 14 sie 2019 o 12:17 Michał Brzuchalski <mic...@brzuchalski.com> napisał(a):
> > > śr., 14 sie 2019 o 12:11 Rowan Collins <rowan.coll...@gmail.com> > napisał(a): > >> On 14/08/2019 11:07, Michał Brzuchalski wrote: >> > Exactly so how would it know from string name either it should load >> class >> > from src/Foo.php or src/__nsmeta.php if there is no information? >> >> >> It wouldn't. It would include src/Foo.php, and that would have the >> definition of something with the name "Foo" - either a class, an >> interface, a trait, or a package. If it wasn't what the engine was >> expecting, it would be an error, just as it is right now if you write >> "implements ClassName", or "new TraitName();" >> > > Following that would introduce unneeded additional directory hierarchy > level in a usual library > which uses PSR-4 which is the most used one, right? > > /composer.json > /src/Foo.php > /src/Foo/ <- all package classes should go here? > Going even further by the example of Doctrine libraries: # doctrine/collections - Composer Package [1] uses PSR-4 autoload with "Doctrine\\Common\\Collections\\" prefix to adopt package concept it would have to change the prefix to "Doctrine\\Common\\" to find Collections.php and all the rest of source code in Collections directory # doctrine/common - Composer Package [2] uses "Doctrine\\Common\\" prefix should change into "Doctrine\\" to be able to load Common.php and the rest of source code in Common directory # ocramius/package-versions - Composer Package [3] uses "PackageVersions\\" prefix and then what? [1] https://github.com/doctrine/collections/blob/master/composer.json [2] https://github.com/doctrine/common/blob/master/composer.json [3] https://github.com/Ocramius/PackageVersions/blob/master/composer.json -- regards / pozdrawiam, -- Michał Brzuchalski about.me/brzuchal brzuchalski.com