code cleanup for phpstan level 4 (#1522)

This commit is contained in:
Kevin Papst
2020-03-05 02:15:16 +01:00
committed by GitHub
parent 25a74ffeee
commit 20b3c31cbd
19 changed files with 40 additions and 64 deletions

View File

@@ -11,6 +11,7 @@ namespace App\Tests\Command;
use App\Command\CreateUserCommand;
use App\Entity\User;
use App\Repository\UserRepository;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Tester\CommandTester;
@@ -58,7 +59,9 @@ class CreateUserCommandTest extends KernelTestCase
$this->assertStringContainsString('[OK] Success! Created user: MyTestUser', $output);
$container = self::$kernel->getContainer();
$user = $container->get('doctrine')->getRepository(User::class)->loadUserByUsername('MyTestUser');
/** @var UserRepository $userRepository */
$userRepository = $container->get('doctrine')->getRepository(User::class);
$user = $userRepository->loadUserByUsername('MyTestUser');
self::assertInstanceOf(User::class, $user);
self::assertNotNull($user);
}

View File

@@ -10,7 +10,8 @@
namespace App\Tests\Repository;
use App\Tests\KernelTestTrait;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectManager;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
@@ -21,7 +22,7 @@ abstract class AbstractRepositoryTest extends KernelTestCase
use KernelTestTrait;
/**
* @var EntityManager|null
* @var ObjectManager|null
*/
private $entityManager;
@@ -38,7 +39,7 @@ abstract class AbstractRepositoryTest extends KernelTestCase
}
/**
* @return EntityManager
* @return ObjectManager
*/
protected function getEntityManager()
{
@@ -52,7 +53,9 @@ abstract class AbstractRepositoryTest extends KernelTestCase
{
parent::tearDown();
$this->entityManager->close();
if ($this->entityManager instanceof EntityManagerInterface) {
$this->entityManager->close();
}
$this->entityManager = null; // avoid memory leaks
}
}

View File

@@ -5,6 +5,8 @@ includes:
parameters:
tmpDir: %rootDir%/../../../var/cache/phpstan
symfony:
container_xml_path: '%rootDir%/../../../var/cache/dev/srcApp_KernelDevDebugContainer.xml'
ignoreErrors:
- '#Access to an undefined property Faker\\Generator::\$stateAbbr.#'
- '#Access to an undefined property Faker\\Generator::\$catchPhrase.#'