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

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

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

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

radmen opened this issue Nov 17, 2015 · 22 comments
Assignees
Labels
Milestone

Comments

@radmen
Copy link
Contributor

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
Copy link
Member

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
Copy link
Contributor Author

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
Copy link
Member

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

@radmen
Copy link
Contributor Author

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
Copy link

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

@quantumpacket
Copy link

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
Copy link

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
Copy link

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
Copy link

girvo commented Dec 16, 2015

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

@quantumpacket
Copy link

@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
Copy link

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
Copy link

+1

@marco-msg-ferrari
Copy link

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
Copy link

kuczek commented Feb 12, 2016

+1

@jonnixs
Copy link

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
Copy link

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
Copy link

+1

@elhachmi
Copy link

Same error on php 7.0.3

@kleijnweb
Copy link

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
Copy link

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
Copy link

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

Cannot create new nodes, when internal state is frozen.

@zazoomauro
Copy link

+1

@ravage84 ravage84 modified the milestones: 2.3.3, 2.4.2 Mar 8, 2016
@manuelpichler manuelpichler self-assigned this Mar 10, 2016
manuelpichler pushed a commit that referenced this issue Mar 10, 2016
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
Labels
Development

No branches or pull requests