hoaproject / Core

The Hoa\Core library.

Home Page:https://hoa-project.net

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does Hoa Core need the "files" load approach in Composer?

halfer opened this issue · comments

commented

I'm using Propel 1 together with PhpMetrics in a project. The latter requires Hoa, which recently introduced an \EngineException class to emulate a class of the same name in PHP 7. Unfortunately this conflicts with a class of the same name in Propel, and a fatal error results.

What was strange for me was that the code that causes Hoa to load should have no reason to do so - PhpMetrics is a stand-alone project for code analysis, and only that should be loading Hoa. I asked a question about this and someone pointed out that Hoa Core hooks into the "file" load approach in Composer, which means it is always loaded.

For now I have locked to an earlier version of Hoa/Core, and if this no longer works at some point, I can always move PhpMetrics to another repo. However, would it be possible for Hoa to only use an autoloader? I worry that the various functions/classes it creates is dependent on it "force" loading.

Hello :-),

We need to load Hoa for at least the hoa:// protocol, which is used by several projects to ensure consistency along migrations of their project, so I am not likely to remove the files property of the composer.json file. However, since PHP7 has introduced the Throwable interface, we can remove the code retro-implementing PHP7 features. I will do that right now, it's going to be easy without no risk.

However, this answer is also correct: http://stackoverflow.com/a/31265607. We should have check the presence of the class.
Nevertheless, Propel will have a serious issue with PHP7. You might open another issue to Propel to prepare them to PHP7.

commented

Thanks @Hywan, that's splendid.

Yes, Propel 1 is quite old, and is shortly to be superceded by Propel 2, which is in alpha5 status presently. This will resolve the problem, since it will be fully namespaced.

@halfer Please, could you retry with hoa/core: 2.*@dev? If the problem is solved for you, then I will create a new snapshot.

commented

Great, works for me @Hywan! Thanks for your speedy assistance.

commented

Will switch to that. 😸

@halfer: hoa/dev: ~2.0 will do the trick naturally.

Sorry for this bug with Propel :-(.

commented

Thanks for coming over to Stack Overflow to report the fix. I've added an extra bounty to your answer, to get you started if you fancy asking/answering more questions.

However, this answer is also correct: http://stackoverflow.com/a/31265607. We should have check the presence of the class.

So why not add && false === interface_exists('Throwable', false) on https://github.com/hoaproject/Core/blob/master/Consistency.php#L944 ?

Because it forces other projects to be compatible with incoming PHP7 versions?

But if an other project do the same as you did it will result a conflict, since both only check the PHP version.

@Metalaka Correct 😉. Who want to make a PR?