Skip to content

Add a guard before loading the whitelisted classes #340

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

Merged
merged 2 commits into from
Jun 9, 2019

Conversation

theofidry
Copy link
Member

Closes #336
Closes #338

@theofidry theofidry merged commit 621e97a into humbug:master Jun 9, 2019
@theofidry theofidry deleted the bugfix/class-alias-guard branch June 9, 2019 17:31
@muglug
Copy link

muglug commented Jun 9, 2019

Does JsonException get whitelisted automatically? I’m not whitelisting it explicitly.

@theofidry
Copy link
Member Author

No it was actually from PHP-Scoper itself. I didn't notice the issue in the CI because there was only a PHP warning being displayed instead of throwing an error (due to the error handler being registered too late to kick in).

The class itself is whitelisted because it comes from a dedicated file, which means it will be scoped (otherwise the autoloading for that package could be broken) hence the only way to expose the original class was to whitelist it (which was done automatically by PHP-Scoper).

TL:DR the only cleaner solution would be for the polyfill to declare the class only if the class is missing with a class_exists(), but I think adding a guard at this level doesn't hurt either and solve that issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Cannot declare class JsonException" when using PHAR of php-scoper 0.12.2 class_alias breaks if class exists
2 participants