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

Fix code base for support php 8.4 #283

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
matrix:
php-version:
- '8.3'
- '8.4'
dependencies: [ highest, lowest ]
make-test:
- test_core
Expand Down
2 changes: 1 addition & 1 deletion doc/advanced-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Loader/FakeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion fixtures/Persistence/FakePurgerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Bridge/Doctrine/Purger/Purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
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;

$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);
Expand Down
2 changes: 1 addition & 1 deletion src/Bridge/Eloquent/Purger/ModelPurger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/Exception/MaxPassReachedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions src/Loader/FileResolverLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
public function __construct(
LoaderInterface $decoratedLoader,
FileResolverInterface $fileResolver,
LoggerInterface $logger = null
?LoggerInterface $logger = null
) {
$this->loader = $decoratedLoader;
$this->fileResolver = $fileResolver;
Expand All @@ -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.');

Expand Down
2 changes: 1 addition & 1 deletion src/Loader/MultiPassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Loader/PersisterLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
public function __construct(
LoaderInterface $decoratedLoader,
PersisterInterface $persister,
LoggerInterface $logger = null,
?LoggerInterface $logger = null,
array $processors = []
) {
$this->loader = $decoratedLoader;
Expand All @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/Loader/PurgerLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Loader/SimpleLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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.');

Expand Down
2 changes: 1 addition & 1 deletion src/LoaderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/Persistence/PurgerFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion tests/Loader/MultiPassFileLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down