Skip to content

Instantly share code, notes, and snippets.

@bastienapp
Created December 14, 2021 16:01
Show Gist options
  • Save bastienapp/a59fc9bc7c3bbc8128f75a2d9ddaf7ba to your computer and use it in GitHub Desktop.
Save bastienapp/a59fc9bc7c3bbc8128f75a2d9ddaf7ba to your computer and use it in GitHub Desktop.
Fix PHPStan with Doctrine
<?php
// this file is in tests/object-manager.php
use App\Kernel;
use Symfony\Component\Dotenv\Dotenv;
require __DIR__ . '/../vendor/autoload.php';
(new Dotenv())->bootEnv(__DIR__ . '/../.env');
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
/** @var \Doctrine\Bundle\DoctrineBundle\Registry */
$doctrine = $kernel->getContainer()->get('doctrine');
return $doctrine->getManager();
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-doctrine/rules.neon
- vendor/phpstan/phpstan-symfony/extension.neon
parameters:
excludePaths:
- src/DataFixtures
- src/Security
ignoreErrors:
- '#Call to an undefined method [a-zA-Z0-9\\_]+::findOneBy[A-Z][a-zA-Z]*\(\)#'
- '#Call to an undefined method [a-zA-Z0-9\\_]+::findBy[A-Z][a-zA-Z]*\(\)#'
reportUnmatchedIgnoredErrors: false
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false
doctrine:
objectManagerLoader: tests/object-manager.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment