Comments (17)
Hoa's autoloader runs if Composer's one failed. Can you confirm that?
from core.
@Hywan I think the fail here is that when Hoa fails to load a class, it forwards the autoloader call to composer but it does not forward it the same way it received it. Taking a look at the stack trace:
- We got a call to
spl_autoload_call('HTMLPurifier_Bootstrap')
- This call gets handled by Hoa:
Consistency::autoload('HTMLPurifier_Bootstrap')
- Hoa tries to load
HTMLPurifier.Bootstrap
:Consistency->_import('HTMLPurifier.Bootstrap', true)
(Hoa/Core/Consistency.php:335
) - Hoa does not find the class and it forwards the SPL autoloader:
spl_autoload_call('HTMLPurifier\Bootstrap')
(Hoa/Core/Consistency.php:288
)
The last forward shows that the original class name has been modified from HTMLPurifier_Bootstrap
to HTMLPurifier\Bootstrap
from core.
When I remove the first entry of my autoload_files.php
the class will be loaded correctly:
return array(
$vendorDir . '/hoa/core/Hoa/Core/Core.php',
$vendorDir . '/swiftmailer/swiftmailer/lib/swift_required.php',
$vendorDir . '/symfony/symfony/src/Symfony/Component/Intl/Resources/stubs/functions.php',
$vendorDir . '/kriswallsmith/assetic/src/functions.php',
$vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
$vendorDir . '/beberlei/assert/lib/Assert/functions.php',
);
Otherwise the error appears. Unfortunately I can't provide a minimal example in a quick way, but I'll investigate time in the next days.
from core.
This PSR-0 vs. PSR-4. Hoa's autoloader is PSR-0 so it transforms _
into \
as the recommandation asks. In PSR-4, it has changed: _
has no longer any meaning.
from core.
No sorry, Hoa's autoloader is PSR-4 but for _
, it works like PSR-0. So, what do we do? We propose a patch to be fully PSR-4 and remove everything from PSR-0?
from core.
Also, @UFOMelkor, why Composer does not handle your class?
from core.
@Hywan you can't blindly replace _
by \
because the class with \
does not exist. To handle this, composer will likely use a classmap strategy.
from core.
@jubianchi I replaced _
by \
because this is what PSR-0 required!
Each
_
character in theCLASS NAME
is converted to aDIRECTORY_SEPARATOR
. The_
character has no special meaning in the namespace.
This is why we have added the 436f30f commit.
Also, Hoa's autoloader runs if and only if Composer has dropped. So, why Hoa's autoloader runs? Why Composer drops?
from core.
@Hywan PSR-0 never said that autoloader should replace _
with NS_SEPARATOR : if it did, it's a fail as this can not work.
The only thinkg I see is the following:
$fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
Which is OK. DIRECTORY_SEPARATOR
is different from \
which is NS_SEPARATOR
and this is not Hoa's responsibility to do that: the only component allowed to do that is the one which knows how to resolve the path from the classname.
from core.
@jubianchi _
is converted into DIRECTORY_SEPARATOR
, which is equivalent to say that: _
is converted into NAMESPACE_SEPARATOR
and then (because this is PSR-0 or 4), NAMESPACE_SEPARATOR
is converted into DIRECTORY_SEPARATOR
. This is strictly identical, no?
from core.
@Hywan no it's not : when your replace character in class name, you create a bug : classes using _
notation won't always use PSR-0 directory structure.
I think that you should not do such assumption and just forward the autoloader call as you received it when you can't handle it.
from core.
The issue is still open. Why Composer does not handle that class?
from core.
I created a minimal example using symfony2. Perhaps anyone might have a look, I want have much time the next days.
What I did: I created a simple bundle and I added the Exercise/HTMLPurifierBundle and PhpMetrics to composer and activated the first one.
from core.
@Hywan autoloader files (which is how hoa/core
works with composer) are called first, before the composer PSR autoloaders that's why this is not working: hoa is called first, does not find the requested class (HTMLPurifier_Bootstrap
), changes its name (HTMLPurifier\Bootstrap
), forwards the call to composer with the wrong classname.
from core.
@jubianchi So a solution is to remove this piece of code and everything will be ok. We assume that Hoa's autoloader is PSR-4 and voilà?
from core.
@UFOMelkor Could you test with #52 please?
from core.
Looks good 👍
from core.
Related Issues (20)
- I'm getting this error *"Hoa main file (Core.php) must be included once."* HOT 7
- mark as deprecated HOT 1
- Support \U, \u, \L, \l, \E and \e in the zFormat HOT 1
- Do we need to cache `extension_loaded` result? HOT 3
- Use a trait for Hoa\Core\Event
- Hoa\Core should NEVER edit php configuration. HOT 12
- Hint IDEs about property. HOT 3
- hoa break when installed globaly HOT 3
- The 'hoa' binary should not be installed with Core HOT 19
- Add a `home` command to open http://hoa-project.net HOT 1
- Setlocal issues in core HOT 4
- PHP7 compatibility
- `Exception::uncaught` can receive a `BaseException` in PHP7.0
- Update `Consistency::isKeyword` for PHP7.0 HOT 1
- Protocol: `stream_stat` is not very verbose when failing
- Does Hoa Core need the "files" load approach in Composer? HOT 14
- Hoa/Core errors when loaded twice HOT 39
- Hoa shouldn't initialize before being used HOT 7
- [meta] Split the core HOT 48
- [meta] Split the core, next HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from core.