Skip to content
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
6 changes: 5 additions & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
<file>tests/BundleTest.php</file>
<file>tests/Maker</file>

<rule ref="Doctrine" />
<rule ref="Doctrine">
<!-- Allow short nullable syntax for non-union types -->
<exclude name="SlevomatCodingStandard.TypeHints.UnionTypeHintFormat.DisallowedShortNullable" />
<exclude name="SlevomatCodingStandard.TypeHints.DNFTypeHintFormat.DisallowedShortNullable" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint" />
<rule ref="PSR2.Classes.PropertyDeclaration.ScopeMissing" />

Expand Down
8 changes: 4 additions & 4 deletions src/Maker/MakeDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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('');

Expand Down
2 changes: 1 addition & 1 deletion src/MongoDB/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
6 changes: 3 additions & 3 deletions tests/MongoDB/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ 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.');

Validator::notBlank($value);
}

/** @return Generator<string, array{0: string|null}> */
/** @return Generator<string, array{0: ?string}> */
public static function invalidNotBlankProvider(): Generator
{
yield 'null' => [null];
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testValidateFieldNameWithEmptyValue(string $fieldName): void
Validator::validateFieldName($fieldName);
}

/** @return Generator<string, array{0: string|null}> */
/** @return Generator<string, array{0: ?string}> */
public static function emptyFieldNameProvider(): Generator
{
yield 'empty string' => [''];
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/make-document/documents/User-basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}