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

ASTNode expected, ASTAnonymousClass given #250

Closed
fracasula opened this Issue Mar 29, 2016 · 15 comments

Comments

Projects
None yet
@fracasula

fracasula commented Mar 29, 2016

Hi there,

I just ran phpmd on my project with this command:

vendor/bin/phpmd ./ text cleancode,codesize,controversial,design,naming,unusedcode --exclude=vendor/*,Tests/app/cache/*,Tests/app/logs/*,Tests/app/AppKernel.php

Error below:

PHP Catchable fatal error: Argument 1 passed to PDepend\Source\AST\AbstractASTNode::addChild() must implement interface PDepend\Source\AST\ASTNode, instance of PDepend\Source\AST\ASTAnonymousClass given, called in /squawka/squawka-database/vendor/pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserVersion70.php on line 214 and defined in /squawka/squawka-database/vendor/pdepend/pdepend/src/main/php/PDepend/Source/AST/AbstractASTNode.php on line 367

Versions used:

  • "phpmd/phpmd": "2.4.2"
  • "pdepend/pdepend": "2.2.4"

There's anything I could do to find out how to solve this?

@aschwin

This comment has been minimized.

aschwin commented Apr 1, 2016

+1 Same issue here. Exact same versions.

@edro

This comment has been minimized.

edro commented Apr 7, 2016

+1 the same

1 similar comment
@bezrukovp

This comment has been minimized.

bezrukovp commented Apr 9, 2016

+1 the same

@llato

This comment has been minimized.

llato commented Apr 18, 2016

Maybe it can help. This error occurred when anonymous class is used:

new class()

@fracasula

This comment has been minimized.

fracasula commented Apr 18, 2016

Is this what you mean @llato ?

$article = (new Entity\Article())
    ->setTitle($title)
    ->setAuthor($author);
    ->setCreatedAt(new \DateTime());

All setters in my case return $this so it works like a charm 👍

@dmaij

This comment has been minimized.

dmaij commented Jun 1, 2016

I changed the parent class of PHPParserGeneric from PHPParserVersion70 to PHPParserVersion56 in the pdepend source (./pdepend/pdepend/src/main/php/PDepend/Source/Language/PHP/PHPParserGeneric.php line 61).

Since I am running php56, i figures this was a weird contruction and it appears to work (for me at least)

@ChrisWesterfield

This comment has been minimized.

ChrisWesterfield commented Jun 5, 2016

Is there already an solution in site/in Master?

@sfeni

This comment has been minimized.

sfeni commented Jun 10, 2016

same here
downgraded pdepend/pdepend to version 2.2.2 worked for me

@ChrisWesterfield

This comment has been minimized.

ChrisWesterfield commented Jun 10, 2016

that helped thanks 👍

@SimonFolger

This comment has been minimized.

SimonFolger commented Jul 8, 2016

dmaij´s solution worked for me aswell, thanks

@neemzy

This comment has been minimized.

neemzy commented Aug 18, 2016

So one month later, are we still better off editing vendor code to work around this? :)

@Fjarlaegur

This comment has been minimized.

Fjarlaegur commented Sep 28, 2016

Neither downgrading to 2.2.2 (Cannot create nodes when, interval is in frozen state error) or setting the parser to PHP 5.6 is working for me. I run PHP 7.0.8.
Is there any other fix or workaround for this? Keeps me from getting green builds in jenkins as it cannot generate a JDepend xml report.

@mjacobus

This comment has been minimized.

mjacobus commented Sep 30, 2016

+1. Same as @Fjarlaegur

@Fjarlaegur

This comment has been minimized.

Fjarlaegur commented Sep 30, 2016

Seems like @manuelpichler is working on a fix on a closely same named branch. Last commit 14 days ago. Maybe he can give us some insight in fixing things?

EDIT: I fixed my errors. I was running Pdepend on all folders in my project. I was using this for a laravel project, as i changed all modules to just scan the /app folder, my build finally turned green.

@g4z

This comment has been minimized.

g4z commented Oct 22, 2016

Thanks @Fjarlaegur. I was having the same problem until I read your comment and realised I had forgotten to use --exclude vendor.

@stephenwf stephenwf referenced this issue Nov 2, 2016

Merged

Vendor update #25

3 of 3 tasks complete

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

Pinning pdepend to 2.2.2
pdepend/pdepend#250 in newer versions prevents us from using anonymous classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment