Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token when using PHP7’s null coalesce operator #347

Closed
jonnybarnes opened this issue Feb 9, 2016 · 25 comments
Closed

Unexpected token when using PHP7’s null coalesce operator #347

jonnybarnes opened this issue Feb 9, 2016 · 25 comments
Milestone

Comments

@jonnybarnes
Copy link

$var = $otherVar ?? 'default'; gives Unexpected token: ??.

@ravage84 ravage84 added the Bug label Feb 9, 2016
@ravage84 ravage84 added this to the 2.3.3 milestone Feb 9, 2016
@ravage84
Copy link
Member

ravage84 commented Feb 9, 2016

This should probably be fixed in PDepend.

@torkiljohnsen
Copy link

👍 Ran into this too.

@ravage84 ravage84 modified the milestones: 2.4.3, 2.4.4 Apr 25, 2016
@MarcFRICOU
Copy link

same problem

@zachrattner
Copy link

Confirmed for me too.

@tyler36
Copy link

tyler36 commented May 27, 2016

Confirmed for me too.

Edit:
OS: Win7
PHP: 7.0.3
PHPMD: 2.4.3

@JeroenDeDauw
Copy link
Contributor

Confirmed with PHPMD 2.4.3

@fgm
Copy link

fgm commented Jul 5, 2016

Still present in today's dev head.

@marcusesa
Copy link

😞

@lgoral
Copy link

lgoral commented Jul 25, 2016

I think problem is with missing TOKEN_PARSE for token_get_all in https://github.com/pdepend/pdepend/blob/master/src/main/php/PDepend/Source/Language/PHP/PHPTokenizerInternal.php#L651

if (version_compare(phpversion(), '5.3.0alpha3') < 0) {
            $tokens = PHPTokenizerHelperVersion52::tokenize($source);
        } elseif (version_compare(phpversion(), '7.0') > 0) {
            $tokens = token_get_all($source, TOKEN_PARSE);
        } else {
            $tokens = token_get_all($source);
        }

But it's not a fix it's a beginning of the adventure :)

@MatissJanis
Copy link

This issue has been fixed on PDepend. Can a new PHPMD version be released with this fix?

@wandersonwhcr
Copy link

👍

@torkiljohnsen
Copy link

Still awaiting new PDepend release perhaps?

@MisterGlass
Copy link

Has anyone found an interim fix? I have a new PHP7 codebase and want to turn on PHPMD, but I cant until it support the new operators.

@webaaz
Copy link

webaaz commented Nov 21, 2016

👍

@azzeddinefaik
Copy link

same in here any fix for this ?

@wandersonwhcr
Copy link

Até que enfim!

We have a new PDEPEND tag since March!

Please, update your composers! 😄

@wandersonwhcr
Copy link

@azzeddinefaik
Copy link

$ phpmd ./src xml cleancode --reportfile ./testphp.xml --suffixes php > testphpmd.log
PHP Warning: Module 'mongodb' already loaded in Unknown on line 0
PHP PDepend\Source\Parser\UnexpectedTokenException: Unexpected token: ??, line: 217, col: 42, file: /Users/azzeddinefaik/Workspace/php-test/mongodm/src/Collection.php. in phar:///usr/local/bin/phpmd/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/AbstractPHPParser.php on line 2845
PHP Stack trace:

My issue is with phpmd not PDEPEND.

@wandersonwhcr
Copy link

Please, run: composer outdated | grep pdepend and post results here.

@azzeddinefaik
Copy link

$ pdepend --version
PHP Warning: Module 'mongodb' already loaded in Unknown on line 0

Warning: Module 'mongodb' already loaded in Unknown on line 0
PDepend 2.2.6

@wandersonwhcr
Copy link

wandersonwhcr commented Nov 22, 2016

I think your installation of PHPMD is a phar. Again, I think the phpmd.phar have a pdepend installation internally and still with version 2.2.4.

If you use Composer, you simply need to update your composer.lock with composer update pdepend/pdepend.

@jonnybarnes
Copy link
Author

pdepend v2.2.6 fixes this

@MisterGlass
Copy link

MisterGlass commented Nov 22, 2016

Confirmed. Not sure why I had 2.2.4 (my project is newer than the 2.2.6 release) but I forced an update with composer update pdepend/pdepend and it works now. Thanks!

@azzeddinefaik
Copy link

pdepend fixed thanks @wandersonwhcr , but I got new error

16
PHP OutOfBoundsException: Property "exceptions" does not exist. in /Users/azzeddinefaik/.composer/vendor/phpmd/phpmd/src/main/php/PHPMD/AbstractRule.php on line 380
PHP Stack trace:

@wandersonwhcr
Copy link

@azzeddinefaik I'm sorry, but with this error I can't help you.

Please, search if another issue has your problem or create a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests