Open arderyp opened 2 years ago
I've gotten around the error with the following stub, but not sure if its the correct approach:
<?php
declare(strict_types=1);
namespace Doctrine\ORM;
abstract class AbstractQuery
{
public const HYDRATE_OBJECT = 1;
/**
* see: https://github.com/phpstan/phpstan-doctrine/issues/301
* @param string|int $hydrationMode
* @@phpstan-ignore-next-line we are overriding the return type
*/
public function getResult($hydrationMode = self::HYDRATE_OBJECT): array;
}
Have you configured objectManagerLoader from the README?
Yeah, I'm using the following:
#phpstan.neon
doctrine:
objectManagerLoader: tests/object-manager.php
#tests/object-manager.php
<?php
declare(strict_types=1);
// @todo Symfony 5.4 update this file, see https://github.com/phpstan/phpstan-symfony
use App\Kernel;
require __DIR__ . '/../config/bootstrap.php';
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
return $kernel->getContainer()->get('doctrine')->getManager();
FYI @arnaud-lb might be fixable :)
fixed typo in original post
INDEX BY and sub queries are currently not supported. When the extension can not determine the result type, mixed
is returned (for the whole result or a part of the result).
I confirm that support for INDEX BY can probably be added.
Sounds about right @arnaud-lb. If this should be an enhancement request, it would be really cool to have this support added.
any luck here?
I am not sure if this is a problem with phpstan itself, or this repo.
This throws no error:
This throws
findCustom() should return array<App\Entity\Users> but returns mixed.