codeclimate/codeclimate-duplication

php-parser error with 7.1 syntax

tillkruss opened this issue · 3 comments

We've got the following line in our PHP 7.1 codebase:

[$foo, $bar] = foo::bar($baz);

The duplication engine fails with:

Skipping file ./path/to/File.php due to exception (CC::Engine::Analyzers::ParserError): `php -d 'display_errors = Off' /usr/src/app/vendor/php-parser/parser.php` exited with code 1:
Parse Error: Syntax error, unexpected '=' on line 48

/usr/src/app/lib/cc/engine/analyzers/command_line_runner.rb:24:in `block in run'
/usr/local/lib/ruby/2.3.0/timeout.rb:91:in `block in timeout'
/usr/local/lib/ruby/2.3.0/timeout.rb:33:in `block in catch'
/usr/local/lib/ruby/2.3.0/timeout.rb:33:in `catch'
/usr/local/lib/ruby/2.3.0/timeout.rb:33:in `catch'
/usr/local/lib/ruby/2.3.0/timeout.rb:106:in `timeout'
/usr/src/app/lib/cc/engine/analyzers/command_line_runner.rb:16:in `run'
/usr/src/app/lib/cc/engine/analyzers/php/parser.rb:20:in `parse'
/usr/src/app/lib/cc/engine/analyzers/php/main.rb:28:in `process_file'
/usr/src/app/lib/cc/engine/analyzers/analyzer_base.rb:26:in `run'
/usr/src/app/lib/cc/engine/analyzers/reporter.rb:40:in `block in process_files'
/usr/src/app/lib/cc/engine/analyzers/file_thread_pool.rb:22:in `block (2 levels) in run'

Thanks for the report.

It looks like we need to upgrade our internal php-parser to 3.x. There are some instructions here: https://github.com/nikic/PHP-Parser/blob/master/UPGRADE-3.0.md

Last time we upgraded, it looked like this: #139

PRs are definitely welcome, if you're interested. Otherwise, we should be able to make that upgrade soon.

Cool, no rush. I won't have time for a PR in the next 2 weeks, sorry.

nice work @maxjacobson 🎆