Skip to content

Commit bf4cc7c

Browse files
committed
Locate and tokenize T_FINALLY tokens in older PHP versions
1 parent 3d598e3 commit bf4cc7c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

CodeSniffer/Tokenizers/PHP.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,15 @@ public function tokenizeString($string, $eolChar='\n')
779779
}
780780
}
781781

782+
// This is a special case when checking PHP 5.5+ code in PHP < 5.5
783+
// where "finally" should be T_FINALLY instead of T_STRING.
784+
if ($newToken['code'] === T_STRING
785+
&& strtolower($newToken['content']) === 'finally'
786+
) {
787+
$newToken['code'] = T_FINALLY;
788+
$newToken['type'] = 'T_FINALLY';
789+
}
790+
782791
// This is a special case for the PHP 5.5 classname::class syntax
783792
// where "class" should be T_STRING instead of T_CLASS.
784793
if ($newToken['code'] === T_CLASS

0 commit comments

Comments
 (0)