ac-php not compatible with PHP 7.3?
gjm opened this issue · comments
Hi.
I'm getting errors with ac-php-remake-tags
similar to this:
PHPParser: A trailing comma is not allowed here on line...
That error refers to a trailing comma in a multi-line function call, something that is supported by PHP 7.3. I've checked ac-php-php-executable
and it point to /usr/bin/php
, a PHP 7.3 executable, so I don't understand why I'm getting the parse errors.
Is there something I'm doing wrong or missing?
I'm using ac-php-core
as a dependency of company-php
. Could this be related?
Thanks in advance.
@gjm I'll try to sort out ASAP. Thank you for the report.
show me test php code.
@xcwen what do you mean by test code?
I'm using ac-php as a backend to company. When it indexes my code I get the errors I posted in the OP.
@sergeyklay @xcwen Yes just like that, except it's multi line:
function (
$a,
$b,
$c,
)
{
//
}
Most likely it is PHP-Parser issue nikic/PHP-Parser#598;
Example:
<?php
use PhpParser\Error;
use PhpParser\NodeDumper;
use PhpParser\ParserFactory;
require __DIR__.'/vendor/autoload.php';
$code = <<<'CODE'
<?php
function test($foo, $bar,) // <- A trailing comma
{
var_dump($foo);
}
CODE;
$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
try {
$ast = $parser->parse($code);
} catch (Error $error) {
echo "Parse error: {$error->getMessage()}\n";
return;
}
$dumper = new NodeDumper;
echo $dumper->dump($ast) . "\n";
$ php -v | head -n 1
PHP 7.3.0 (cli) (built: Jan 8 2019 18:55:14) ( ZTS DEBUG )
$ php parser.php
Parse error: A trailing comma is not allowed here on line 3
@gjm Take a look at https://wiki.php.net/rfc/trailing-comma-function-calls
@sergeyklay seems OK for me!