Skip to content
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

Using __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list #2376

Closed
Billz95 opened this issue Jan 22, 2019 · 0 comments

Comments

2 participants
@Billz95
Copy link

commented Jan 22, 2019

Currently, the ForbiddenFunctionsSniff get all tokens for forbidden functions by concatenating their names together to a string, then tokenize it using token_get_all.
However, token_get_all does not work properly if __halt_compiler is one of the forbidden function and is not last element of forbiddenFunctions array.

This would cause bug in the following situation:
Consider file:

<?php
foo();

and forbiddenFunctions is set to ['__halt_compiler' => null, 'foo' => 'bar'].
When ForbiddenFunctionsSniff is trying to get tokens for each forbidden function by tokenize the joined string, any function after __halt_compiler will not be considered. Therefore usage of foo(); won't be detected in this case.

@Billz95 Billz95 changed the title Avoid __halt_compiler() from breaking Forbidden Funcitons __halt_compiler() breaks Forbidden Functions Jan 22, 2019

@gsherwood gsherwood added this to Backlog in PHPCS v3 Development via automation Jan 22, 2019

@gsherwood gsherwood added this to the 3.4.1 milestone Jan 22, 2019

@gsherwood gsherwood changed the title __halt_compiler() breaks Forbidden Functions Forbidding __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it is the last item in the function list Jan 22, 2019

@gsherwood gsherwood added the Bug label Jan 22, 2019

@gsherwood gsherwood changed the title Forbidding __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it is the last item in the function list Using __halt_compiler() breaks Generic.PHP.ForbiddenFunctions unless it's last in the function list Jan 22, 2019

PHPCS v3 Development automation moved this from Backlog to Ready for Release Jan 22, 2019

gsherwood added a commit that referenced this issue Jan 22, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.