Closed LeonB closed 7 years ago
Hello :-),
Sure we will try to do something. Can you give me something to reproduce please?
I had the problem when using valet: https://github.com/jmarcher/valet-linux/issues/36
Here resolve()
is getting defined in valet:
https://github.com/jmarcher/valet-linux/blob/master/cli/includes/helpers.php#L66
I've created a simple test: https://github.com/LeonB/test-issue-18
git clone https://github.com/LeonB/test-issue-18.git
cd test-issue-18/
composer install
php test.php
This outputs:
PHP Warning: Missing argument 1 for resolve(), called in /home/leon/Public/test/test-issue-18/test.php on line 11 and defined in /home/leon/Public/test/test-issue-18/vendor/hoa/protocol/Wrapper.php on line 599
PHP Notice: Undefined variable: path in /home/leon/Public/test/test-issue-18/vendor/hoa/protocol/Wrapper.php on line 601
So you're basically doing the same error than us, and you're complaining 😉? We have 132 direct calls to resolve
in all the libraries. This would require a little bit of work. I am willing to do this change, and gently deprecating the resolve
alias. However, I don't have time to do this before January. Maybe another Hoacker could do that: @hoaproject/hoackers?
If any one volunteers for this, I can create all the issues.
Another alternative is to move resolve
and other global functions to the closest namespace, require PHPÂ 5.6 as the minimum version, and use use function
to import function in the current scope. So it reduces the number of code to migrate.
Should we put the alias into Protocol
namespace ?
This change mean all our libraries will be updated to major version due to BC ?
@Pierozi Why all libraries will have BC?
@LeonB After a short discussion, @vonglasow will take the lead on this issue 😃. Thank you!
@Hywan, I agree my code example is doing the same and isn't the nicest thing to do. But when I've installed hoa/protocol with composer global
Wrapper.php
is always loaded, even when I'm not directly using it. So another option could be to remove Wrapper.php
from the autoload
in composer.json
.
So in my case, I globally installed phpmetrics/phpmetrics
(which has a dependency on hoa/protocol) and another (globally) installed package broke.
If a library is using hoa/protocol
, then it uses Wrapper.php
automatically. So, sorry, we cannot remove this file for the prelude.
However, you can rename your function until we remove our resolve
function from the global scope. Thoughts? Is it possible?
@Hywan Assume your Project use Hoa\Ruler
which depend of Hoa\Protocol
and your project use resolve
if Hoa\Protocol
is up to version 2.0
and Ruler up on 2.16.xxx
that mean next update of Ruler will break your resolve function no ? and guess require us to update Ruler to 3.0
@Pierozi Potentially yes. If the BC break of a dependency emerges in the public API, then yes, we should BC break too. That's correct.
In fact this function resolve cause issue in laravel app. So it's impossible to use laravel and hoa/ruler together ... or any library depending on protocole. For me, we should assume global vars will be conflictual and prefix them or add them inside a namespace.
Hello, I think this issue have to be re-open :/
There is a helper resolve()
in .../laravel/framework/src/Illuminate/Foundation/helpers.php
who conflict with yours even in a namespace :/
I have the hoa/protocol
version "1.17.01.14".
hoa helper: vendor/hoa/protocol/Wrapper.php
illuminate helper: vendor/laravel/framework/src/Illuminate/Foundation/helpers.php
The problem don't come from my code but from the package hyn/multi-tenant
who use the resolve
helper in the Laravel way. You can see it here:
vendor/hyn/multi-tenant/src/Providers/Tenants/QueueProvider.php
What can I do to patch it?
It seems https://github.com/hoaproject/Protocol/pull/22 was merged, was it supposed to fix this?
To give some context this library is used by Bref via hoa/fastcgi and it conflicts with Laravel's resolve()
helper.
Codeception also uses this via hoa/console, please release the new version, @Hywan
As this was "fixed" over a year ago, and isn't released yet, I took liberty to release a forked package with this fix applied:
composer require sanmai/hoa-protocol
Other than that it should be a feature match to 1.17.01.14. Please report any issues.
@Hywan If there isn't an update planned would you be minding tagging this package as abandoned? This can be done at composer.org. And if you could be so kind to recommend my replacement package, that'd be best.
Wrapper.php
is autoloaded by composer and defines aresolve()
function which polutes the global namespace. When running another composer-installed bin which also declaresresolve()
in the global namespace this gives a conflict. Would it be possible to restrictresolve()
to a namespace?