diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 9912fb2..ac3e018 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -16,7 +16,11 @@ tests/BundleTest.php tests/Maker - + + + + + diff --git a/src/Maker/MakeDocument.php b/src/Maker/MakeDocument.php index a62d97b..fb78b07 100644 --- a/src/Maker/MakeDocument.php +++ b/src/Maker/MakeDocument.php @@ -50,8 +50,8 @@ final class MakeDocument extends AbstractMaker implements InputAwareMakerInterfa public function __construct( private FileManager $fileManager, private MongoDBHelper $mongoDBHelper, - private Generator|null $generator = null, - private DocumentClassGenerator|null $documentClassGenerator = null, + private ?Generator $generator = null, + private ?DocumentClassGenerator $documentClassGenerator = null, ) { $this->generator ??= new Generator($fileManager, 'App\\'); $this->documentClassGenerator ??= new DocumentClassGenerator($this->generator, $this->mongoDBHelper); @@ -176,7 +176,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen ]); } - public function configureDependencies(DependencyBuilder $dependencies, InputInterface|null $input = null): void + public function configureDependencies(DependencyBuilder $dependencies, ?InputInterface $input = null): void { $dependencies->addClassDependency( DoctrineMongoDBBundle::class, @@ -185,7 +185,7 @@ public function configureDependencies(DependencyBuilder $dependencies, InputInte } /** @param string[] $fields */ - private function askForNextField(ConsoleStyle $io, array $fields, string $documentClass, bool $isFirstField): ClassProperty|null + private function askForNextField(ConsoleStyle $io, array $fields, string $documentClass, bool $isFirstField): ?ClassProperty { $io->writeln(''); diff --git a/src/MongoDB/Validator.php b/src/MongoDB/Validator.php index 6ad1662..0fce645 100644 --- a/src/MongoDB/Validator.php +++ b/src/MongoDB/Validator.php @@ -16,7 +16,7 @@ final class Validator /** * Validates that a value is not blank. */ - public static function notBlank(string|null $value = null): string + public static function notBlank(?string $value = null): string { if ($value === null || $value === '') { throw new RuntimeCommandException('This value cannot be blank.'); diff --git a/tests/MongoDB/ValidatorTest.php b/tests/MongoDB/ValidatorTest.php index e492165..88e901a 100644 --- a/tests/MongoDB/ValidatorTest.php +++ b/tests/MongoDB/ValidatorTest.php @@ -30,7 +30,7 @@ public static function validNotBlankProvider(): Generator } #[DataProvider('invalidNotBlankProvider')] - public function testNotBlankWithInvalidValue(string|null $value): void + public function testNotBlankWithInvalidValue(?string $value): void { $this->expectException(RuntimeCommandException::class); $this->expectExceptionMessage('This value cannot be blank.'); @@ -38,7 +38,7 @@ public function testNotBlankWithInvalidValue(string|null $value): void Validator::notBlank($value); } - /** @return Generator */ + /** @return Generator */ public static function invalidNotBlankProvider(): Generator { yield 'null' => [null]; @@ -76,7 +76,7 @@ public function testValidateFieldNameWithEmptyValue(string $fieldName): void Validator::validateFieldName($fieldName); } - /** @return Generator */ + /** @return Generator */ public static function emptyFieldNameProvider(): Generator { yield 'empty string' => ['']; diff --git a/tests/fixtures/make-document/documents/User-basic.php b/tests/fixtures/make-document/documents/User-basic.php index a4ec830..35a76ed 100644 --- a/tests/fixtures/make-document/documents/User-basic.php +++ b/tests/fixtures/make-document/documents/User-basic.php @@ -10,8 +10,8 @@ class User { #[ODM\Id] - public int|null $id = null; + public ?int $id = null; #[ODM\Field] - public string|null $firstName = null; + public ?string $firstName = null; }