Skip to content

Commit 31329f4

Browse files
author
Sijun Zhu
committed
Make the forbidden function use finer token string to avoid parsing issue when __halt_compiler is used
1 parent 6bed665 commit 31329f4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,15 @@ public function register()
7474

7575
// If we are not pattern matching, we need to work out what
7676
// tokens to listen for.
77-
$string = '<?php ';
77+
$tokens = [];
7878
foreach ($this->forbiddenFunctionNames as $name) {
79-
$string .= $name.'();';
79+
$token = token_get_all(sprintf('<?php %s();', $name));
80+
array_shift($token);
81+
$tokens = array_merge($tokens, $token);
8082
}
8183

8284
$register = [];
8385

84-
$tokens = token_get_all($string);
85-
array_shift($tokens);
8686
foreach ($tokens as $token) {
8787
if (is_array($token) === true) {
8888
$register[] = $token[0];

0 commit comments

Comments
 (0)