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

Undefined property: PhpParser\Node\Stmt\Property::$type #14

Closed
if-owen opened this issue Mar 20, 2019 · 7 comments
Closed

Undefined property: PhpParser\Node\Stmt\Property::$type #14

if-owen opened this issue Mar 20, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@if-owen
Copy link

if-owen commented Mar 20, 2019

I have been trying to set this up in my gitlab CI and also tried running this locally on my macbook, and in both circumstances I get a lot of notices thrown to the screen/console like this:

Macbook:

Notice: Undefined property: PhpParser\Node\Stmt\Property::$type in phar:https:///Users/xxxxxx/www.xxxxx.com/drupal-check.phar/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php on line 98

Gitlab:

Notice: Undefined property: PhpParser\Node\Stmt\Property::$type in phar:https:///home/gitlab-runner/builds/e67c5a4b/0/xxxx/xxxx/drupal-check.phar/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/NameResolver.php on line 97

Any ideas what I may be doing wrong? In both circumstances we are using PHP 7.2

@mglaman
Copy link
Owner

mglaman commented Mar 21, 2019

So, with #9 we discovered there can be problems on custom projects. This might be due to PHP Mess Detector, Phan, Psalm, etc.

Can you:

  • Tun composer show nikic/php-parser on your project?
  • If it returns a version,
    • can you provide the version?
    • Run composer why nikic/php-parser

Drush requires psy/psysh for the PHP Shell. This uses the AST parser but allows any existing major version.

If not... I am not sure. We'd need to dig into your project's dependencies more.

@mglaman mglaman added the needs more information Further information is requested label Mar 21, 2019
@chx
Copy link

chx commented Mar 21, 2019

I can reproduce this. Here is the information requested:

versions : * v4.1.0

psy/psysh v0.9.9 requires nikic/php-parser (~1.3|~2.0|~3.0|~4.0)

Thanks for the super useful utility!

@mglaman
Copy link
Owner

mglaman commented Mar 21, 2019

phar:https:///Users/xxxxxx/www.xxxxx.com/drupal-check.phar

Is the Phar in your Drupal project's root? Can you try moving it into another directory and running it? Drupal Check is expecting v4.2.1. PHPStan only requires "^4.0.2". I wonder if Drupal Check needs a stronger constraint so it doesn't conflict with Drush.

psy/psysh may support ~4.0. But maybe the project only has 4.1 from when Drush was last updated. Now Drupal Check comes in expecting 4.2.1. But it adds Drupal's autoloader and now it's working with 4.1.0 and not 4.2.1.

@chx
Copy link

chx commented Mar 21, 2019

What I don't understand here and the vendor issue both: this is a phar file, why woud compontents outside of it matter? (Same goes for drush as well. I never studied PHAR much, I guess.)

@mglaman
Copy link
Owner

mglaman commented Mar 21, 2019

So there problem is this:

Phars are an archive, and the project's vendor is actually "zipped up" in the Phar. So it still runs Composer's autoloader inside of it.

In order to do static analysis, it needs to include the Drupal project's autoload.php and bootstrap Drupal's namespace/autoloading.

As soon as it loads Drupal.. any libraries from Drupal overwrite known namespace paths for Drupal Check.

@mglaman mglaman added bug Something isn't working and removed needs more information Further information is requested labels Mar 21, 2019
@chx
Copy link

chx commented Mar 22, 2019

Reload phar autoload after?

@mglaman
Copy link
Owner

mglaman commented May 3, 2019

Focusing on this in #37.

tl;dr of problem:

This means any Drupal 8 project created before Drupal 8.5.0 (7 Mar 2018) probably has the v3 branch of the PHP-Parser.

@mglaman mglaman closed this as completed May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants