-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scope "ext" classes if they're installed with composer too #1109
Comments
Correct, if a symbol is internal (i.e. comes from PHP or an extension), it should not be scoped. There is however an exception to the above, and that is when you are dealing stubs. The way PHP-Scoper handles it is keep scoping as usual, but add an alias in the if (!\method_exists('Foo\\Grpc\\ChannelCredentials', 'isDefaultRootsPemSet') || ... If If you can provide a reproducer that I could check out it would be highly appreciated. I can't promise to be able to take a look soon, but that would make it a lot easier to find what is wrong. The |
The issue arises bc grpc and protobuf have a native PHP extension (in C) but the same classes are also available as composer packages.
Use the composer.json provided in the original post and look at Now install grpc + protobuf PHP extensions |
@kkmuffme the problem with just looking at the file is that it is hard to ensure it is enough. PHP-Scoper doesn't operate on the file alone, but also via aliases it declares in the autoload. So one may check it and be under the impression it is not working because it gets prefixed, but it may be expected because you get the alias in the autoload. So whilst I can do the above, it's not guaranteed Ill get it right just from that
Apologies I meant a polyfill there. |
Bug report
default scoper config
On my machine where I run scoper, I have grpc (and protobuf) installed for PHP - since I set it to false for the platform, composer (correctly) installed both packages.
However scoper somehow created a weird mix of exposed and scoped that will lead to fatals.
e.g. vendor\grpc\grpc\src\lib\BaseStub.php has a scoped namespace (correct):
namespace Foo\Grpc;
It also correctly scoped the code in it, e.g.
However in vendor\google\gax\src\Transport\GrpcTransport.php all use statements are correctly scoped, except:
I guess this happens bc scoper sees that these classes are available in PHP natively and treats them as exposed (just like
use Exception;
which is obviously correct)Possible solutions:
I guess 2 is easier?
The text was updated successfully, but these errors were encountered: