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

PHP Fatal error with symfony/framework-bundle and traits #44

Closed
Adirelle opened this issue Nov 15, 2017 · 3 comments
Closed

PHP Fatal error with symfony/framework-bundle and traits #44

Adirelle opened this issue Nov 15, 2017 · 3 comments

Comments

@Adirelle
Copy link

I have got this error with master.

composer-require-checker check composer.json 
ComposerRequireChecker 0.1.6-27-ga1b1407
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to ComposerRequireChecker\NodeVisitor\UsedSymbolCollector::recordUsageOf() must be an instance of PhpParser\Node\Name, null given, called in /home/user/.composer/vendor/maglnet/composer-require-checker/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php on line 153 and defined in /home/user/.composer/vendor/maglnet/composer-require-checker/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php:166
Stack trace:
#0 /home/user/.composer/vendor/maglnet/composer-require-checker/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php(153): ComposerRequireChecker\NodeVisitor\UsedSymbolCollector->recordUsageOf(NULL)
#1 /home/user/.composer/vendor/maglnet/composer-require-checker/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php(50): ComposerRequireChecker\NodeVisitor\UsedSymbolCollector->recordTraitUsage(Object(PhpParser\Node\Stmt\TraitUse))
#2 /home/user/.composer/vendor/nikic in /home/user/.composer/vendor/maglnet/composer-require-checker/src/ComposerRequireChecker/NodeVisitor/UsedSymbolCollector.php on line 166

PHP Version:

php -v
PHP 7.1.11-1+ubuntu17.10.1+deb.sury.org+1 (cli) (built: Oct 27 2017 13:50:57) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.1.11-1+ubuntu17.10.1+deb.sury.org+1, Copyright (c) 1999-2017, by Zend Technologies

I Added a var_dump just before the error, this gives me this:

object(PhpParser\Node\Stmt\TraitUseAdaptation\Alias)#5785 (5) {
  ["newModifier"]=>
  int(1)
  ["newName"]=>
  NULL
  ["trait"]=>
  NULL
  ["method"]=>
  string(11) "generateUrl"
  ["attributes":protected]=>
  array(2) {
    ["startLine"]=>
    int(536)
    ["endLine"]=>
    int(536)
  }
}

Can be reproduced with the following composer.json (just do composer install and run composer-require-checker on it):

{
    "require": {
        "symfony/framework-bundle": "^3.3"
    },
    "autoload": {
        "psr-4": { "\\MyNS\\": "./" }
    }
}
@Adirelle Adirelle changed the title PHP Fatal error: Uncaught TypeError: Argument 1 passed to ComposerRequireChecker\NodeVisitor\UsedSymbolCollector::recordUsageOf() must be an instance of PhpParser\Node\Name, null given PHP Fatal error with symfony/framework-bundle and traits Nov 15, 2017
@Adirelle
Copy link
Author

I just added a non-null check around the failing statement and it works, without breaking the test suite, but this seems too easy.

@maglnet
Copy link
Owner

maglnet commented Nov 15, 2017

@Adirelle the null check seems to be sufficient, since the parameter is only null when a visibility modifier has changed.

This happens here:
https://github.com/symfony/framework-bundle/blob/34b13d9e21146b9cd9914d48ccc086230f04bf32/Tests/Controller/ControllerTraitTest.php#L535

Just as a side note:
I first thought it was the "psr-4": { "\\MyNS\\": "./" } autoloader line that causes problems, but it can also be reproduced when running composer-require-checker within the repository symfony/framework-bundle.

@Adirelle
Copy link
Author

#45 fixes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants