larastan: Invalid argument supplied for foreach()

  • Larastan Version: 0.6.1
  • --level used: 8

Description

phpstan/phpstan-doctrine Version: 0.12.17

phpstan.neon

parameters:
	doctrine:
		objectManagerLoader: %currentWorkingDirectory%/tests/phpstan-doctrine.php

phpstan-doctrine.php

require __DIR__.'/../vendor/autoload.php';

$app = require __DIR__.'/../bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();

return $app->make(\Doctrine\ORM\EntityManager::class);

Laravel code where the issue was found

phpstan --debug

Invalid argument supplied for foreach() at vendor/nunomaduro/larastan/src/Methods/Passable.php:179

         if (! $this->staticAllowed && $staticAllowed === false) {
             $statics = $this->resolve('config') === null ? [] : $this->resolve('config')->get('larastan.statics');

             foreach ($statics as $staticClass) {
                 if ($staticClass === $class || $classReflection->isSubclassOf($staticClass)) {
                     $staticAllowed = true;
                     break;
                 }

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15

Most upvoted comments

@szepeviktor

This is dump($statics).

# phpstan --debug

/var/www/html/app/Console/Kernel.php
array:2 [
  0 => "Illuminate\Database\Eloquent\Model"
  1 => "Illuminate\Support\Facades\Facade" 
]
array:2 [
  0 => "Illuminate\Database\Eloquent\Model"
  1 => "Illuminate\Support\Facades\Facade"
]
/var/www/html/app/Doctrine/Repositories/ScheduleRepository.php
/var/www/html/app/Exceptions/Handler.php
array:2 [
  0 => "Illuminate\Database\Eloquent\Model"
  1 => "Illuminate\Support\Facades\Facade"
]
/var/www/html/app/Http/Controllers/Api/ScheduleController.php
/var/www/html/app/Http/Controllers/Controller.php
/var/www/html/app/Http/Controllers/DoctrineController.php
/var/www/html/app/Http/Controllers/HomeController.php
/var/www/html/app/Http/Kernel.php
/var/www/html/app/Http/Middleware/Authenticate.php
/var/www/html/app/Http/Middleware/CheckForMaintenanceMode.php
/var/www/html/app/Http/Middleware/EncryptCookies.php
/var/www/html/app/Http/Middleware/RedirectIfAuthenticated.php
null