From 143f6be538fec0ed5ae69bcb3be013b3e55ed92e Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Sun, 8 Dec 2024 10:58:55 +0200 Subject: [PATCH 1/3] Fix code base for support php 8.4 --- doc/advanced-usage.md | 2 +- fixtures/Loader/FakeLoader.php | 2 +- fixtures/Persistence/FakePurgerFactory.php | 2 +- src/Bridge/Doctrine/Purger/Purger.php | 4 ++-- src/Bridge/Eloquent/Purger/ModelPurger.php | 2 +- src/Exception/MaxPassReachedException.php | 4 ++-- src/Loader/FileResolverLoader.php | 4 ++-- src/Loader/MultiPassLoader.php | 2 +- src/Loader/PersisterLoader.php | 2 +- src/Loader/PurgerLoader.php | 4 ++-- src/Loader/SimpleLoader.php | 4 ++-- src/LoaderInterface.php | 2 +- src/Persistence/PurgerFactoryInterface.php | 2 +- tests/Loader/MultiPassFileLoaderTest.php | 2 +- 14 files changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/advanced-usage.md b/doc/advanced-usage.md index 7256147d..b1b32505 100644 --- a/doc/advanced-usage.md +++ b/doc/advanced-usage.md @@ -114,7 +114,7 @@ use Nelmio\Alice\IsAServiceTrait; private $manager; private $purger; - public function __construct(ObjectManager $manager, PurgeMode $purgeMode = null) + public function __construct(ObjectManager $manager, ?PurgeMode $purgeMode = null) { $this->manager = $manager; $this->purger = static::createPurger($manager, $purgeMode); diff --git a/fixtures/Loader/FakeLoader.php b/fixtures/Loader/FakeLoader.php index 066dfa2c..d2404cd6 100644 --- a/fixtures/Loader/FakeLoader.php +++ b/fixtures/Loader/FakeLoader.php @@ -21,7 +21,7 @@ class FakeLoader implements LoaderInterface { use NotCallableTrait; - public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array + public function load(array $fixturesFiles, array $parameters = [], array $objects = [], ?PurgeMode $purgeMode = null): array { $this->__call(__METHOD__, func_get_args()); } diff --git a/fixtures/Persistence/FakePurgerFactory.php b/fixtures/Persistence/FakePurgerFactory.php index 812d2de1..c4491d34 100644 --- a/fixtures/Persistence/FakePurgerFactory.php +++ b/fixtures/Persistence/FakePurgerFactory.php @@ -19,7 +19,7 @@ class FakePurgerFactory implements PurgerFactoryInterface { use NotCallableTrait; - public function create(PurgeMode $mode, PurgerInterface $purger = null): PurgerInterface + public function create(PurgeMode $mode, ?PurgerInterface $purger = null): PurgerInterface { $this->__call(__METHOD__, func_get_args()); } diff --git a/src/Bridge/Doctrine/Purger/Purger.php b/src/Bridge/Doctrine/Purger/Purger.php index 15c6e3c7..d2a1fba2 100644 --- a/src/Bridge/Doctrine/Purger/Purger.php +++ b/src/Bridge/Doctrine/Purger/Purger.php @@ -44,7 +44,7 @@ private ?PurgeMode $purgeMode; private DoctrinePurgerInterface $purger; - public function __construct(ObjectManager $manager, PurgeMode $purgeMode = null) + public function __construct(ObjectManager $manager, ?PurgeMode $purgeMode = null) { $this->manager = $manager; $this->purgeMode = $purgeMode; @@ -52,7 +52,7 @@ public function __construct(ObjectManager $manager, PurgeMode $purgeMode = null) $this->purger = static::createPurger($manager, $purgeMode); } - public function create(PurgeMode $mode, PurgerInterface $purger = null): PurgerInterface + public function create(PurgeMode $mode, ?PurgerInterface $purger = null): PurgerInterface { if (null === $purger) { return new self($this->manager, $mode); diff --git a/src/Bridge/Eloquent/Purger/ModelPurger.php b/src/Bridge/Eloquent/Purger/ModelPurger.php index b2feb946..4eb1fd57 100644 --- a/src/Bridge/Eloquent/Purger/ModelPurger.php +++ b/src/Bridge/Eloquent/Purger/ModelPurger.php @@ -39,7 +39,7 @@ public function __construct(MigrationRepositoryInterface $repository, string $mi $this->repository = $repository; } - public function create(PurgeMode $mode, PurgerInterface $purger = null): PurgerInterface + public function create(PurgeMode $mode, ?PurgerInterface $purger = null): PurgerInterface { if (PurgeMode::createTruncateMode() == $mode) { throw new InvalidArgumentException( diff --git a/src/Exception/MaxPassReachedException.php b/src/Exception/MaxPassReachedException.php index be977de0..896404aa 100644 --- a/src/Exception/MaxPassReachedException.php +++ b/src/Exception/MaxPassReachedException.php @@ -31,7 +31,7 @@ class MaxPassReachedException extends RuntimeException implements LoadingThrowab private array $stack = []; #[Pure] - public function __construct($message, $code = 0, Throwable $previous = null, ErrorTracker $errorTracker = null) + public function __construct($message, $code = 0, Throwable $previous = null, ?ErrorTracker $errorTracker = null) { parent::__construct($message, $code, $previous); @@ -53,7 +53,7 @@ public static function createForLimit( FileTracker $fileTracker, ErrorTracker $errorTracker, int $code = 0, - Throwable $previous = null + ?Throwable $previous = null ) { return new static( static::createMessage($limit, $fileTracker, $errorTracker), diff --git a/src/Loader/FileResolverLoader.php b/src/Loader/FileResolverLoader.php index 93c39275..4c6a2840 100644 --- a/src/Loader/FileResolverLoader.php +++ b/src/Loader/FileResolverLoader.php @@ -40,7 +40,7 @@ public function __construct( LoaderInterface $decoratedLoader, FileResolverInterface $fileResolver, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { $this->loader = $decoratedLoader; $this->fileResolver = $fileResolver; @@ -63,7 +63,7 @@ public function withPersister(PersisterInterface $persister): self * * {@inheritdoc} */ - public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array + public function load(array $fixturesFiles, array $parameters = [], array $objects = [], ?PurgeMode $purgeMode = null): array { $this->logger->info('Resolving fixture files.'); diff --git a/src/Loader/MultiPassLoader.php b/src/Loader/MultiPassLoader.php index 72788a6f..826d1f44 100644 --- a/src/Loader/MultiPassLoader.php +++ b/src/Loader/MultiPassLoader.php @@ -63,7 +63,7 @@ public function __construct(FileLoaderInterface $fileLoader, int $maxPass = 15) * * @throws MaxPassReachedException */ - public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array + public function load(array $fixturesFiles, array $parameters = [], array $objects = [], ?PurgeMode $purgeMode = null): array { $errorTracker = new ErrorTracker(); $filesTracker = new FileTracker(...$fixturesFiles); diff --git a/src/Loader/PersisterLoader.php b/src/Loader/PersisterLoader.php index a19fa178..83197f74 100644 --- a/src/Loader/PersisterLoader.php +++ b/src/Loader/PersisterLoader.php @@ -74,7 +74,7 @@ public function withPersister(PersisterInterface $persister): self * * {@inheritdoc} */ - public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array + public function load(array $fixturesFiles, array $parameters = [], array $objects = [], ?PurgeMode $purgeMode = null): array { $objects = $this->loader->load($fixturesFiles, $parameters, $objects, $purgeMode); diff --git a/src/Loader/PurgerLoader.php b/src/Loader/PurgerLoader.php index 2044d6b1..1ecaa4e6 100644 --- a/src/Loader/PurgerLoader.php +++ b/src/Loader/PurgerLoader.php @@ -46,7 +46,7 @@ public function __construct( LoaderInterface $decoratedLoader, PurgerFactoryInterface $purgerFactory, string $defaultPurgeMode, - LoggerInterface $logger = null + ?LoggerInterface $logger = null ) { if (!isset(self::$PURGE_MAPPING)) { self::$PURGE_MAPPING = [ @@ -98,7 +98,7 @@ public function withPersister(PersisterInterface $persister): self * * {@inheritdoc} */ - public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array + public function load(array $fixturesFiles, array $parameters = [], array $objects = [], ?PurgeMode $purgeMode = null): array { if (null === $purgeMode) { $purgeMode = $this->defaultPurgeMode; diff --git a/src/Loader/SimpleLoader.php b/src/Loader/SimpleLoader.php index 9a471d23..7a93c198 100644 --- a/src/Loader/SimpleLoader.php +++ b/src/Loader/SimpleLoader.php @@ -37,7 +37,7 @@ private LoggerInterface $logger; #[Pure] - public function __construct(FilesLoaderInterface $fileLoader, LoggerInterface $logger = null) + public function __construct(FilesLoaderInterface $fileLoader, ?LoggerInterface $logger = null) { $this->filesLoader = $fileLoader; $this->logger = $logger ?? new NullLogger(); @@ -48,7 +48,7 @@ public function __construct(FilesLoaderInterface $fileLoader, LoggerInterface $l * * {@inheritdoc} */ - public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array + public function load(array $fixturesFiles, array $parameters = [], array $objects = [], ?PurgeMode $purgeMode = null): array { $this->logger->info('Loading fixtures.'); diff --git a/src/LoaderInterface.php b/src/LoaderInterface.php index feed104e..62031559 100644 --- a/src/LoaderInterface.php +++ b/src/LoaderInterface.php @@ -24,5 +24,5 @@ interface LoaderInterface * * @return object[] */ - public function load(array $fixturesFiles, array $parameters = [], array $objects = [], PurgeMode $purgeMode = null): array; + public function load(array $fixturesFiles, array $parameters = [], array $objects = [], ?PurgeMode $purgeMode = null): array; } diff --git a/src/Persistence/PurgerFactoryInterface.php b/src/Persistence/PurgerFactoryInterface.php index ddb4c84b..955e1070 100644 --- a/src/Persistence/PurgerFactoryInterface.php +++ b/src/Persistence/PurgerFactoryInterface.php @@ -19,5 +19,5 @@ interface PurgerFactoryInterface * Creates a new purger with the given purger mode. As the purger is stateful, it may be useful sometimes to create * a new purger with the same state as an existing one and just have control on the purge mode. */ - public function create(PurgeMode $mode, PurgerInterface $purger = null): PurgerInterface; + public function create(PurgeMode $mode, ?PurgerInterface $purger = null): PurgerInterface; } diff --git a/tests/Loader/MultiPassFileLoaderTest.php b/tests/Loader/MultiPassFileLoaderTest.php index cbaa30f8..5321282e 100644 --- a/tests/Loader/MultiPassFileLoaderTest.php +++ b/tests/Loader/MultiPassFileLoaderTest.php @@ -53,7 +53,7 @@ public function testIsNotClonable(): void /** * @dataProvider provideMaxPassValue */ - public function testMaxPassGivenMustBeAStrictlyPositiveInteger(int $maxPass, string $expectedExceptionMessage = null): void + public function testMaxPassGivenMustBeAStrictlyPositiveInteger(int $maxPass, ?string $expectedExceptionMessage = null): void { try { new MultiPassLoader(new FakeFileLoader(), $maxPass); From f2434d12703b07a25e9ee735c84c334601ea3d3e Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Sun, 8 Dec 2024 11:00:14 +0200 Subject: [PATCH 2/3] Fix code base for support php 8.4 --- .github/workflows/tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8001be83..ea4f5e90 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -24,6 +24,7 @@ jobs: matrix: php-version: - '8.3' + - '8.4' dependencies: [ highest, lowest ] make-test: - test_core From 53ff37e432852b77d5eb53a330b74d04c74cb62b Mon Sep 17 00:00:00 2001 From: Serhii Donii Date: Sun, 8 Dec 2024 11:03:25 +0200 Subject: [PATCH 3/3] Fix code base for support php 8.4 --- src/Exception/MaxPassReachedException.php | 2 +- src/Loader/PersisterLoader.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Exception/MaxPassReachedException.php b/src/Exception/MaxPassReachedException.php index 896404aa..9f5489b4 100644 --- a/src/Exception/MaxPassReachedException.php +++ b/src/Exception/MaxPassReachedException.php @@ -31,7 +31,7 @@ class MaxPassReachedException extends RuntimeException implements LoadingThrowab private array $stack = []; #[Pure] - public function __construct($message, $code = 0, Throwable $previous = null, ?ErrorTracker $errorTracker = null) + public function __construct($message, $code = 0, ?Throwable $previous = null, ?ErrorTracker $errorTracker = null) { parent::__construct($message, $code, $previous); diff --git a/src/Loader/PersisterLoader.php b/src/Loader/PersisterLoader.php index 83197f74..a84f3e9d 100644 --- a/src/Loader/PersisterLoader.php +++ b/src/Loader/PersisterLoader.php @@ -47,7 +47,7 @@ public function __construct( LoaderInterface $decoratedLoader, PersisterInterface $persister, - LoggerInterface $logger = null, + ?LoggerInterface $logger = null, array $processors = [] ) { $this->loader = $decoratedLoader;