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

Cannot create new nodes, when internal state is frozen. #328

Closed
radmen opened this Issue Nov 17, 2015 · 22 comments

Comments

Projects
None yet
@radmen

radmen commented Nov 17, 2015

This is a bit tricky issue.

For start I know that this error is actually triggered by pdepend/pdepend package yet it happens when I'm using PHPMD so I decided to post this issue here.

I'm trying to run PHPMD on my PHP7 project. In most cases it fails with message:

Cannot create new nodes, when internal state is frozen.

I've tried to run PHPMD for some directories located inside my src dir and it worked. Yet again, when I tried to put them together separated by comma the fail message returned.

I'm not sure what's causing this problem. At first I've thought it's a problem of code written in PHP7 yet it seems to be unrelated (for single directories PHPMD works).

I'm using PHPMD in 2.3.2 version.
Tried to run binary in PHP 5.6.15, and 7.0RC7

@ravage84 ravage84 added the Bug label Nov 23, 2015

@ravage84 ravage84 added this to the 2.3.3 milestone Nov 23, 2015

@ravage84

This comment has been minimized.

Member

ravage84 commented Nov 23, 2015

Hi @radmen , thanks for the issue, but it's a bit too vague.
Can you try to produce a minimum reproducable code/directory compilation?
Or could you fire up your debugger to help us investigate?

@radmen

This comment has been minimized.

radmen commented Nov 23, 2015

@ravage84 Unfortunatelly I cannot share the source code on which phpmd was failing. I'll try to create repo with failing PHPMD build.

@ravage84

This comment has been minimized.

Member

ravage84 commented Nov 23, 2015

I totally understand that. Try what you can, we appreciate it.

@radmen

This comment has been minimized.

radmen commented Nov 23, 2015

@ravage84 I've managed to extract the failing parts from my project.

Here you can find repo: https://github.com/radmen/phpmd-nodes-freeze-error
Travis builds: https://travis-ci.org/radmen/phpmd-nodes-freeze-error

This code can be run under docker:

docker run -it -v "$PWD":/phpmd php:7.0 /phpmd/vendor/bin/phpmd /phpmd/src text /phpmd/phpmd.xml
@mikebronner

This comment has been minimized.

mikebronner commented Nov 24, 2015

I'm getting the same error. Is there a temporary work-around that I could use?

@quantumpacket

This comment has been minimized.

quantumpacket commented Nov 24, 2015

I too am getting this error with a PHP 7.0RC7 project using PHPMD master. I'll narrow the code down and post something reproducible later today.

@rbairwell

This comment has been minimized.

rbairwell commented Nov 24, 2015

If it helps, I'm also getting the identical error (PHP7.0.0-dev Oct 22: the Ubuntu based "rasmus" dev Vagrant VM: running on a Windows 7 host with the project source files mounted from Windows) - but only on one of the two projects (one, a library project, with 3848 LOC, but it works okay on a Slim3 project which only has 399 LOC).

@quantumpacket

This comment has been minimized.

quantumpacket commented Nov 24, 2015

I narrowed it down (at least in my case) to this example code. If PHPMD encounters a return type declaration it chokes on the next method. If I put that method last it works.

Can anyone confirm these code snippets produce the same results for you?

Errors

<?php

class Foo
{
    function bar() : \stdClass
    {

    }

    function baz()
    {

    }
}

Success

<?php

class Foo
{
    function baz()
    {

    }

    function bar() : \stdClass
    {

    }
}

Note: not sure if this http://news.php.net/php.internals/89375 will effect this issue or not. Just wanted to give a heads up in case it does.

@girvo

This comment has been minimized.

girvo commented Dec 16, 2015

Yeah that's what causing it in my case too, @quantumpacket

@quantumpacket

This comment has been minimized.

quantumpacket commented Dec 17, 2015

@ravage84 is there a time-frame on when this may be fixed? It essentially breaks PHPMD in PHP7 applications using return type declarations so no other PHPMD warnings are triggered, and also as a side effect is piling up errors for every single modification to a file in PhpStorm. I'm easily getting 300+ errors over the course of editing a file and the only way to fix it is to comment out any return type declarations.

@shssoichiro

This comment has been minimized.

shssoichiro commented Dec 29, 2015

Bump. Experiencing this issue as well with PHP7 using return type declarations. I've had to completely disable PHPMD for my current project.

@marco-msg-ferrari

This comment has been minimized.

marco-msg-ferrari commented Dec 29, 2015

+1

@marco-msg-ferrari

This comment has been minimized.

marco-msg-ferrari commented Dec 30, 2015

I've manged to solve the issue but it is a problem in pdepend.

pdepend/pdepend@master...marco-msg-ferrari:master

I need help creating the regression test to submit the PR.

@kuczek

This comment has been minimized.

kuczek commented Feb 12, 2016

+1

@jonnixs

This comment has been minimized.

jonnixs commented Feb 12, 2016

An update to this (as I've hit the same issue and wasn't sure how far it had gotten) seems to be that @marco-msg-ferrari submitted a pull request to pdepend which appears to have been merged into master.

Looking at the tags, it appears this will be added to pdepend 2.3, though I can't see an approx date for stable release.

@carlowens

This comment has been minimized.

carlowens commented Feb 16, 2016

Just to also confirm I get the same error using PHP 7.0.3-4+deb.sury.org~trusty+1. Disabling phpmd for now.

@djlambert

This comment has been minimized.

djlambert commented Feb 22, 2016

+1

@elhachmi

This comment has been minimized.

elhachmi commented Feb 23, 2016

Same error on php 7.0.3

@kleijnweb

This comment has been minimized.

kleijnweb commented Mar 2, 2016

Even though that PR is merged, still getting this error. Installed with:

composer global require pdepend/pdepend='dev-master as 2.3'  phpmd/phpmd=dev-master
Changed current directory to /var/lib/jenkins/.composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Removing pdepend/pdepend (2.2.3)
  - Installing pdepend/pdepend (dev-master 99bd1af)
    Cloning 99bd1af095b9147c257512b61b2ddcd358d1bc4a

  - Removing phpmd/phpmd (2.3.2)
  - Installing phpmd/phpmd (dev-master cd9c0b7)
    Cloning cd9c0b7cebf7681c87f0b1493fea676114813b80
@elhachmi

This comment has been minimized.

elhachmi commented Mar 3, 2016

I resolve this error temporarily by this, that may not work for you, but for me is enough while waiting a real solution, you must not use php7 namespace grouped declaration.

$filename = 'vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPBuilder.php';
$str = file_get_contents($filename);
//I comment this line :)
$newStr = str_replace('$this->frozen = true;', '//$this->frozen = true;', $str);
file_put_contents($filename, $newStr);

I run this once in my local env and at each build
perhaps this bug is caused by function return type declaration, when using a custom type.

@dereuromark

This comment has been minimized.

dereuromark commented Mar 3, 2016

We also experienced the same thing in CircleCI, locally all seems fine.

Cannot create new nodes, when internal state is frozen.

@zazoomauro

This comment has been minimized.

zazoomauro commented Mar 4, 2016

+1

@ravage84 ravage84 modified the milestones: 2.3.3, 2.4.2 Mar 8, 2016

@manuelpichler manuelpichler self-assigned this Mar 10, 2016

manuelpichler added a commit that referenced this issue Mar 10, 2016

Closes #328: Invalid Parser/AST state in PDepend
An issue with PHP 7 return types has caused an invalid state within PDepend's
Parser and AST.

giorgiosironi added a commit to elifesciences/proofreader-php that referenced this issue Nov 2, 2016

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