Whole file

terryyin/lizard

The author described this change as Fix issue #442: PHP use function statements no longer override function names. It counts as a record because the checks below fail on the code as it stood at ec9ba1ecd and pass on 1700bd91b, with nothing else changed between the two runs.

Fix saved2026-01-16
Sharing licenceMIT · LICENSE.txt
Change size+10 2

What the code was meant to do, written into the code itself as a save note

Fix issue #442: PHP use function statements no longer override function names

The change

2929 self.assignments = []
3030 self.in_match = False
3131 self.match_case_count = 0
32+ self.in_use_statement = False
3233
3334 def _state_global(self, token):
34- if token == 'class':
35+ if token == 'use':
36+ # Enter use statement mode
37+ self.in_use_statement = True
38+ elif token == ';':
39+ # End of use statement or any other statement
40+ self.in_use_statement = False
41+ elif token == 'class':
3542 self._state = self._class_declaration
3643 elif token == 'trait':
3744 self._state = self._trait_declaration
38- elif token == 'function':
45+ elif token == 'function' and not self.in_use_statement:
46+ # Only treat 'function' as function declaration if not in use statement
3947 self.is_function_declaration = True
4048 self._state = self._function_name
4149 elif token == 'fn':

The check that tells the two apart

failpass·test/test_languages/testPHP.py::Test_parser_for_PHP::test_multiple_use_function_statements
failpass·test/test_languages/testPHP.py::Test_parser_for_PHP::test_use_function_statement_does_not_override_function_name

Check file test/test_languages/testPHP.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itec9ba1ecd2bcf35118a3662c939ab5643c6e80db
Broken version dated2026-01-16
Modulelizard_languages.php
Units changedPHPLanguageStates
Fingerprint05504fedcff2c179
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in terryyin/lizard