-
Notifications
You must be signed in to change notification settings - Fork 102
Issue with QueryBuilderGetQueryDynamicReturnTypeExtension
when a variable typed as an interface is used
#501
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Hi, did you configure |
Yes the <?php
// phpstan/object-manager.php
/**
* This file is used by PHPStan, see https://github.com/phpstan/phpstan-doctrine#configuration.
*/
declare(strict_types=1);
use App\Kernel;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Dotenv\Dotenv;
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
/** @var EntityManager $entityManager */
$entityManager = $kernel->getContainer()->get('doctrine')->getManager();
return $entityManager; But since |
PHPStan just uses Doctrine internals to infer the query type. How come that when called from PHPStan the internals crash but within your application the code is okay? |
Because at runtime, But when running PHPStan on it, |
I have a same problem. Did you have any solution ? |
I didn't look any further than that, I've explicitly pinned the version 1.3.50 in order to deal with those issues later :/ |
This should be fixed since 1.3.55 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi everyone,
When upgrading from 1.3.50 to 1.3.53, we started to have the following issue:
App\Common\Entity\Behavior\StatsOwnerInterface
is indeed not a class, but it exists as an interface.When running PHPStan with
--debug
:We can see the exception is thrown at this line:
which refers to the following PHP code:
Here, the
$ownerEntity
(used in$this->entityManager->getRepository()
) is an implementation ofStatsOwnerInterface
, due to the method's PHPDoc, and so it makes the extension crash.I didn't check the extension code yet, but maybe early-checking if we really have a class would be great, or catch a
MappingException
exception to return anew QueryType($dql, null)
.WDYT?
The text was updated successfully, but these errors were encountered: