Skip to content

Commit

Permalink
Add proper support for DQL types in PHPStan Doctrine
Browse files Browse the repository at this point in the history
  • Loading branch information
apfelbox committed Sep 24, 2024
1 parent 831bdbf commit bf2c9d1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.3.5
=====

* (improvement) Add proper support for DQL types in PHPStan Doctrine.


1.3.4
=====

Expand Down
6 changes: 5 additions & 1 deletion _init/symfony/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
includes:
- vendor/21torr/janus/phpstan/symfony.neon


parameters:
doctrine:
objectManagerLoader: tests/phpstan-doctrine-object-manager.php

# If you use simple-phpunit, you need to uncomment the following line.
# Always make sure to first run simple-phpunit and then PHPStan.
# parameters:
# bootstrapFiles:
# - vendor/bin/.phpunit/phpunit/vendor/autoload.php
13 changes: 13 additions & 0 deletions _init/symfony/tests/phpstan-doctrine-object-manager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

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();

return $kernel->getContainer()->get('doctrine')->getManager();
6 changes: 6 additions & 0 deletions phpstan/symfony.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ includes:
parameters:
symfony:
container_xml_path: %currentWorkingDirectory%/var/cache/dev/App_KernelDevDebugContainer.xml

ignoreErrors:
# We will always have the issue, that the type of the prop and the database type won't match,
# as we validate in between and PHPStan can't know that. So let's just deactivate it.
- identifier: doctrine.columnType

0 comments on commit bf2c9d1

Please sign in to comment.