Code improvements (#1649)

* use global namespace for faster lookups
* phpstan level 5
This commit is contained in:
Kevin Papst
2020-04-19 14:37:14 +02:00
committed by GitHub
parent 7b25e9acaf
commit 0f3fa8fdbe
183 changed files with 604 additions and 574 deletions

View File

@@ -14,10 +14,8 @@ use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\Executor\ORMExecutor;
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpKernel\HttpKernelBrowser;
/**
* A trait to be used in all tests that extend the KernelTestCase.
@@ -33,19 +31,9 @@ trait KernelTestTrait
return $this::$container->get('doctrine.orm.entity_manager');
}
/**
* @param HttpKernelBrowser|EntityManager|KernelTestCase $client
* @param Fixture $fixture
*/
protected function importFixture($client, Fixture $fixture)
protected function importFixture(Fixture $fixture)
{
if ($client instanceof EntityManager) {
$em = $client;
} elseif ($this instanceof KernelTestCase) {
$em = $this::$container->get('doctrine.orm.entity_manager');
} else {
throw new \InvalidArgumentException('Need an EntityManager to import fixtures');
}
$em = $this::$container->get('doctrine.orm.entity_manager');
$loader = new Loader();
$loader->addFixture($fixture);
@@ -60,11 +48,10 @@ trait KernelTestTrait
}
/**
* @param EntityManager $em
* @param string $role
* @return User|null
*/
protected function getUserByRole(EntityManager $em, string $role = User::ROLE_USER)
protected function getUserByRole(string $role = User::ROLE_USER)
{
$name = null;