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

Comments

Projects
None yet
@jonnybarnes

jonnybarnes commented Feb 9, 2016

$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 ravage84 added the PDepend label Feb 9, 2016

@ravage84

This comment has been minimized.

Member

ravage84 commented Feb 9, 2016

This should probably be fixed in PDepend.

@torkiljohnsen

This comment has been minimized.

torkiljohnsen commented Apr 18, 2016

👍 Ran into this too.

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

@MarcFRICOU

This comment has been minimized.

MarcFRICOU commented May 19, 2016

same problem

@zachrattner

This comment has been minimized.

zachrattner commented May 23, 2016

Confirmed for me too.

@tyler36

This comment has been minimized.

tyler36 commented May 27, 2016

Confirmed for me too.

Edit:
OS: Win7
PHP: 7.0.3
PHPMD: 2.4.3

@JeroenDeDauw

This comment has been minimized.

JeroenDeDauw commented May 29, 2016

Confirmed with PHPMD 2.4.3

@fgm

This comment has been minimized.

fgm commented Jul 5, 2016

Still present in today's dev head.

@marcusesa

This comment has been minimized.

marcusesa commented Jul 9, 2016

😞

@lgoral

This comment has been minimized.

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

This comment has been minimized.

MatissJanis commented Sep 20, 2016

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

@wandersonwhcr

This comment has been minimized.

wandersonwhcr commented Oct 1, 2016

👍

@torkiljohnsen

This comment has been minimized.

torkiljohnsen commented Oct 13, 2016

Still awaiting new PDepend release perhaps?

@MisterGlass

This comment has been minimized.

MisterGlass commented Nov 11, 2016

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

This comment has been minimized.

webaaz commented Nov 21, 2016

👍

@azzeddinefaik

This comment has been minimized.

azzeddinefaik commented Nov 22, 2016

same in here any fix for this ?

@wandersonwhcr

This comment has been minimized.

wandersonwhcr commented Nov 22, 2016

Até que enfim!

We have a new PDEPEND tag since March!

Please, update your composers! 😄

@wandersonwhcr

This comment has been minimized.

@azzeddinefaik

This comment has been minimized.

azzeddinefaik commented Nov 22, 2016

$ 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

This comment has been minimized.

wandersonwhcr commented Nov 22, 2016

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

@azzeddinefaik

This comment has been minimized.

azzeddinefaik commented Nov 22, 2016

$ 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

This comment has been minimized.

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

This comment has been minimized.

jonnybarnes commented Nov 22, 2016

pdepend v2.2.6 fixes this

manuelpichler added a commit that referenced this issue Nov 22, 2016

@MisterGlass

This comment has been minimized.

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

This comment has been minimized.

azzeddinefaik commented Nov 22, 2016

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

This comment has been minimized.

wandersonwhcr commented Nov 22, 2016

@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.

@ravage84 ravage84 modified the milestones: 2.4.4, 2.5.1 Nov 23, 2016

@zdenekdrahos zdenekdrahos referenced this issue Nov 23, 2016

Merged

Upgrade robo, pdepend, phpmd #35

2 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment