Closed richardbrinkman closed 5 years ago
Are you sure you don't have two PHP versions installed? PHPMD could be run with an older version of PHP than your code is written in.
Yes I'm sure I run only one PHP version (7.0.22).
Sample PHP file (test.php):
<?php
var_dump($_GET["var"] ?? "default");
?>
Command: phpmd test.php text cleancode
Output:
/tmp/test.php - Unexpected token: ??, line: 2, col: 24, file: /tmp/test.php.
What OS are you running? If you're on linux/OSX, can you post the output of: env php -v
?
phpmd uses the php binary that's in your PATH and the only thing I can think of it's using a different version (pre 7.0).
OS: lubuntu 16.04.03 (LTS)
env php -v:
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
phpmd version: 2.3.2-1build1
running php test.php
dumps the expected "default", so surely php 7.0.22 knows the ?? operator.
What version of Pdepend are you using? If I recall correctly, the newest version of it should fully support PHP 7.0.
pdepend version 2.2.2-1build1
Can you please verify that behavior with Pdepend 2.5.0? It Should have full PHP 7.0 support.
@richardbrinkman can you verify this?
I can't reproduce I use ??
very often with no incompatibility when running PHPMD. I think it has been fixed in PDepend since.
The error does not appear any more.
PHP has introduced the ?? operator. Example usage:
which is roughly equivalent to:
phpmd gives an
Unexpected token: ??
error when these new constructs are used.