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

Argument 5 passed to PHPStan\Analyser\Scope::__construct() must be an instance of PHPStan\Analyser\ScopeContext, instance of PHPStan\Rules\Properties\PropertyReflectionFinder given #104

Closed
1 of 4 tasks
goba opened this issue Sep 21, 2019 · 3 comments

Comments

@goba
Copy link
Sponsor

goba commented Sep 21, 2019

How is drupal-check installed?

  • drupal-check is installed using the phar
  • drupal-check is installed globally via Composer
  • drupal-check is installed globally using consolidation/cgr
  • drupal-check is installed as a dependency to my project

Environment:

  • OS: MacOS
  • PHP Version: 7.1.23
  • Drupal core: 8.7.7

Describe the bug

Downloaded drupal-check.phar with curl -O -L https://github.com/mglaman/drupal-check/releases/latest/download/drupal-check.phar

Trying to run on core path module, finding 35 instances of


Line tests/src/Unit/Field/PathFieldDefinitionTest.php


     Internal error: Argument 5 passed to PHPStan\Analyser\Scope::__construct() must be an instance of PHPStan\Analyser\ScopeContext, instance of         
     PHPStan\Rules\Properties\PropertyReflectionFinder given, called in                                                                                   
     phar:https:///[...]/web/core/modules/path/drupal-check.phar/vendor/phpstan/phpstan/src/Analyser/ScopeFactory.php on line 103  
     Run PHPStan with --debug option and post the stack trace to:                                                                                         
     https://github.com/phpstan/phpstan/issues/new                                                                                                        

This sounds like a potential bleeding edge dependency problem.

Console output


Fatal error: Uncaught TypeError: Argument 5 passed to PHPStan\Analyser\ScopeFactory::__construct() must implement interface PHPStan\DependencyInjection\Container, instance of PHPStan\Rules\Properties\PropertyReflectionFinder given, called in /private/var/folders/pz/nxd0q9hs15d2n2yqljmhxzbm0000gn/T/phpstan/cache/nette.configurator/Container_6fc5ccf691.php on line 4420 and defined in [...]/vendor/phpstan/phpstan/src/Analyser/ScopeFactory.php:28
Stack trace:
#0 /private/var/folders/pz/nxd0q9hs15d2n2yqljmhxzbm0000gn/T/phpstan/cache/nette.configurator/Container_6fc5ccf691.php(4420): PHPStan\Analyser\ScopeFactory->__construct('PHPStan\\Analyse...', Object(PHPStan\Broker\Broker), Object(PhpParser\PrettyPrinter\Standard), Object(PHPStan\Analyser\TypeSpecifier), Object(PHPStan\Rules\Properties\PropertyReflectionFinder), Object(PHPStan\DependencyInjection\Nette\NetteContainer))
#1 phar:https:///[...]/web/core/modules/path/drupal-check.phar/vendor/nette/di/src/DI/Container.php(189 in [...]/vendor/phpstan/phpstan/src/Analyser/ScopeFactory.php on line 28
Gabors-MacBook-Pro:path gaborhojtsy$ php drupal-check.phar tests/src/Unit/Field/PathFieldDefinitionTest.php -vvv
Current working directory: [...]/web/core/modules/path
Using Drupal root: [...]/web
Using vendor root: [...]/vendor
Using autoloader: [...]/vendor/autoload.php

Fatal error: Uncaught TypeError: Argument 5 passed to PHPStan\Analyser\ScopeFactory::__construct() must implement interface PHPStan\DependencyInjection\Container, instance of PHPStan\Rules\Properties\PropertyReflectionFinder given, called in /private/var/folders/pz/nxd0q9hs15d2n2yqljmhxzbm0000gn/T/phpstan/cache/nette.configurator/Container_6fc5ccf691.php on line 4420 and defined in [...]/vendor/phpstan/phpstan/src/Analyser/ScopeFactory.php:28
Stack trace:
#0 /private/var/folders/pz/nxd0q9hs15d2n2yqljmhxzbm0000gn/T/phpstan/cache/nette.configurator/Container_6fc5ccf691.php(4420): PHPStan\Analyser\ScopeFactory->__construct('PHPStan\\Analyse...', Object(PHPStan\Broker\Broker), Object(PhpParser\PrettyPrinter\Standard), Object(PHPStan\Analyser\TypeSpecifier), Object(PHPStan\Rules\Properties\PropertyReflectionFinder), Object(PHPStan\DependencyInjection\Nette\NetteContainer))
#1 phar:https:///[...]/web/core/modules/path/drupal-check.phar/vendor/nette/di/src/DI/Container.php(189 in [...]/vendor/phpstan/phpstan/src/Analyser/ScopeFactory.php on line 28```
@dens0ne
Copy link

dens0ne commented Nov 7, 2019

I did get this error myself too.

I installed drupal-check globally with composer. My specs:

OS: MacOS
PHP: 7.1.32
Drupal Core: 8.6.15

Since I am mostly supporting contrib modules, I decided to do what usage step 1 recommends, which is running composer create-project drupal-composer/drupal-project:8.x-dev drupal --no-interaction --stability=dev, and drupal-check did work in there. So, for now, I'll assume that perhaps I'm behind in my local codebase with a few composer packages, and will focus on working on this other environment for now.

@ndobromirov
Copy link

Same error when installed globally with composer.
Testing against Drupal 8.7.11 on PHP 7.2.

@mglaman
Copy link
Owner

mglaman commented May 11, 2020

PHPStan moved fast, and there was mismatched arguments. It was fixed before, and now it no longer constructs that object.

FYI, if using the phar, it is broken, see #167

@mglaman mglaman closed this as completed May 11, 2020
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

4 participants