Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply PHPCS' PHP 8.1 rules #412

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions Command/LoadDataFixturesDoctrineCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@
*/
class LoadDataFixturesDoctrineCommand extends DoctrineCommand
{
private SymfonyFixturesLoader $fixturesLoader;

/** @var PurgerFactory[] */
private array $purgerFactories;

/** @param PurgerFactory[] $purgerFactories */
public function __construct(SymfonyFixturesLoader $fixturesLoader, ?ManagerRegistry $doctrine = null, array $purgerFactories = [])
{
public function __construct(
private SymfonyFixturesLoader $fixturesLoader,
ManagerRegistry|null $doctrine = null,
private array $purgerFactories = [],
) {
if ($doctrine === null) {
trigger_deprecation(
'doctrine/fixtures-bundle',
Expand All @@ -46,9 +44,6 @@ public function __construct(SymfonyFixturesLoader $fixturesLoader, ?ManagerRegis
}

parent::__construct($doctrine);

$this->fixturesLoader = $fixturesLoader;
$this->purgerFactories = $purgerFactories;
}

protected function configure(): void
Expand Down
6 changes: 3 additions & 3 deletions Loader/SymfonyFixturesLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function addFixtures(array $fixtures): void

public function addFixture(FixtureInterface $fixture): void
{
$class = get_class($fixture);
$class = $fixture::class;
$this->loadedFixtures[$class] = $fixture;

$reflection = new ReflectionClass($fixture);
Expand Down Expand Up @@ -103,7 +103,7 @@ public function getFixtures(array $groups = []): array
$filteredFixtures = [];
foreach ($fixtures as $fixture) {
foreach ($groups as $group) {
$fixtureClass = get_class($fixture);
$fixtureClass = $fixture::class;
if (isset($this->groupsFixtureMapping[$group][$fixtureClass])) {
$filteredFixtures[$fixtureClass] = $fixture;
continue 2;
Expand Down Expand Up @@ -145,7 +145,7 @@ private function validateDependencies(array $fixtures, FixtureInterface $fixture

foreach ($dependenciesClasses as $class) {
if (! array_key_exists($class, $fixtures)) {
throw new RuntimeException(sprintf('Fixture "%s" was declared as a dependency for fixture "%s", but it was not included in any of the loaded fixture groups.', $class, get_class($fixture)));
throw new RuntimeException(sprintf('Fixture "%s" was declared as a dependency for fixture "%s", but it was not included in any of the loaded fixture groups.', $class, $fixture::class));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Purger/ORMPurgerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ final class ORMPurgerFactory implements PurgerFactory
* {@inheritDoc}
*/
public function createForEntityManager(
?string $emName,
string|null $emName,
EntityManagerInterface $em,
array $excluded = [],
bool $purgeWithTruncate = false
bool $purgeWithTruncate = false,
): ORMPurger {
$purger = new ORMPurger($em, $excluded);
$purger->setPurgeMode($purgeWithTruncate ? ORMPurger::PURGE_MODE_TRUNCATE : ORMPurger::PURGE_MODE_DELETE);
Expand Down
4 changes: 2 additions & 2 deletions Purger/PurgerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ interface PurgerFactory
{
/** @psalm-param list<string> $excluded */
public function createForEntityManager(
?string $emName,
string|null $emName,
EntityManagerInterface $em,
array $excluded = [],
bool $purgeWithTruncate = false
bool $purgeWithTruncate = false,
): PurgerInterface;
}
11 changes: 5 additions & 6 deletions Tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Symfony\Component\DependencyInjection\Definition;

use function array_map;
use function get_class;

class IntegrationTest extends TestCase
{
Expand All @@ -51,7 +50,7 @@ public function testFixturesLoader(): void
$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
return $fixture::class;
}, $actualFixtures);

$this->assertSame([
Expand Down Expand Up @@ -84,7 +83,7 @@ public function testFixturesLoaderWhenFixtureHasDepdencenyThatIsNotYetLoaded():
$actualFixtures = $loader->getFixtures();
$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
return $fixture::class;
}, $actualFixtures);

$this->assertSame([
Expand Down Expand Up @@ -135,7 +134,7 @@ public function testFixturesLoaderWithGroupsOptionViaInterface(): void
$actualFixtures = $loader->getFixtures(['staging']);
$this->assertCount(1, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
return $fixture::class;
}, $actualFixtures);

$this->assertSame([
Expand Down Expand Up @@ -222,7 +221,7 @@ public function testLoadFixturesViaGroupWithFulfilledDependency(): void

$this->assertCount(2, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
return $fixture::class;
}, $actualFixtures);

$this->assertSame([
Expand Down Expand Up @@ -255,7 +254,7 @@ public function testLoadFixturesByShortName(): void

$this->assertCount(1, $actualFixtures);
$actualFixtureClasses = array_map(static function ($fixture) {
return get_class($fixture);
return $fixture::class;
}, $actualFixtures);

$this->assertSame([
Expand Down
2 changes: 1 addition & 1 deletion Tests/IntegrationTestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

class IntegrationTestKernel extends Kernel
{
private ?Closure $servicesCallback = null;
private Closure|null $servicesCallback = null;
private int $randomKey;

public function __construct(string $environment, bool $debug)
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<arg name="cache" value=".phpcs-cache"/>
<arg name="colors"/>

<config name="php_version" value="70400"/>
<config name="php_version" value="80100"/>

<!-- Ignore warnings and show progress of the run -->
<arg value="nps"/>
Expand Down