From cb48812750cda462af21c36e6a436c12b0e40630 Mon Sep 17 00:00:00 2001 From: Jesse Rushlow Date: Sat, 3 Feb 2024 01:53:41 -0500 Subject: [PATCH] [ci] php-cs-fixer it up --- .php-cs-fixer.dist.php | 2 +- src/Command/MakerCommand.php | 2 +- src/Doctrine/DoctrineHelper.php | 2 +- src/Generator.php | 4 ++-- src/InputAwareMakerInterface.php | 2 +- src/Maker/AbstractMaker.php | 2 +- src/Maker/MakeAuthenticator.php | 2 +- src/Maker/MakeEntity.php | 12 ++++++------ src/Maker/MakeTest.php | 2 +- src/Maker/MakeUser.php | 2 +- src/Renderer/FormTypeRenderer.php | 2 +- src/Security/InteractiveSecurityHelper.php | 4 ++-- src/Security/UserClassBuilder.php | 2 +- src/Util/YamlSourceManipulator.php | 6 +++--- src/Validator.php | 6 +++--- tests/Util/AutoloaderUtilTest.php | 2 +- tests/Util/ClassSourceManipulatorTest.php | 10 +++++----- 17 files changed, 32 insertions(+), 32 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 082e894c8..276232ee7 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -36,7 +36,7 @@ 'arrays', 'parameters' ], - ] + ], )) ->setRiskyAllowed(true) ->setFinder($finder) diff --git a/src/Command/MakerCommand.php b/src/Command/MakerCommand.php index 4350b8844..320bfde7f 100644 --- a/src/Command/MakerCommand.php +++ b/src/Command/MakerCommand.php @@ -111,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 0; } - public function setApplication(Application $application = null): void + public function setApplication(?Application $application = null): void { parent::setApplication($application); diff --git a/src/Doctrine/DoctrineHelper.php b/src/Doctrine/DoctrineHelper.php index 53ae3cfef..4d2f1ad26 100644 --- a/src/Doctrine/DoctrineHelper.php +++ b/src/Doctrine/DoctrineHelper.php @@ -147,7 +147,7 @@ public function getEntitiesForAutocomplete(): array return $entities; } - public function getMetadata(string $classOrNamespace = null, bool $disconnected = false): array|ClassMetadata + public function getMetadata(?string $classOrNamespace = null, bool $disconnected = false): array|ClassMetadata { // Invalidating the cached AttributeDriver::$classNames to find new Entity classes foreach ($this->mappingDriversByPrefix ?? [] as $managerName => $prefixes) { diff --git a/src/Generator.php b/src/Generator.php index 44582900d..9843e03ae 100644 --- a/src/Generator.php +++ b/src/Generator.php @@ -31,8 +31,8 @@ class Generator public function __construct( private FileManager $fileManager, private string $namespacePrefix, - PhpCompatUtil $phpCompatUtil = null, - TemplateComponentGenerator $templateComponentGenerator = null, + ?PhpCompatUtil $phpCompatUtil = null, + ?TemplateComponentGenerator $templateComponentGenerator = null, ) { $this->twigHelper = new GeneratorTwigHelper($fileManager); $this->namespacePrefix = trim($namespacePrefix, '\\'); diff --git a/src/InputAwareMakerInterface.php b/src/InputAwareMakerInterface.php index 67008ebe6..ac5c80529 100644 --- a/src/InputAwareMakerInterface.php +++ b/src/InputAwareMakerInterface.php @@ -20,5 +20,5 @@ */ interface InputAwareMakerInterface extends MakerInterface { - public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null); + public function configureDependencies(DependencyBuilder $dependencies, ?InputInterface $input = null); } diff --git a/src/Maker/AbstractMaker.php b/src/Maker/AbstractMaker.php index 50d8fcf6e..8341fdd6f 100644 --- a/src/Maker/AbstractMaker.php +++ b/src/Maker/AbstractMaker.php @@ -41,7 +41,7 @@ protected function writeSuccessMessage(ConsoleStyle $io) $io->newLine(); } - protected function addDependencies(array $dependencies, string $message = null): string + protected function addDependencies(array $dependencies, ?string $message = null): string { $dependencyBuilder = new DependencyBuilder(); diff --git a/src/Maker/MakeAuthenticator.php b/src/Maker/MakeAuthenticator.php index 5ca317f3f..8a8708149 100644 --- a/src/Maker/MakeAuthenticator.php +++ b/src/Maker/MakeAuthenticator.php @@ -446,7 +446,7 @@ private function userClassHasEncoder(array $securityData, string $userClass): bo return $userNeedsEncoder; } - public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void + public function configureDependencies(DependencyBuilder $dependencies, ?InputInterface $input = null): void { $dependencies->addClassDependency( SecurityBundle::class, diff --git a/src/Maker/MakeEntity.php b/src/Maker/MakeEntity.php index cc3818185..df2653952 100644 --- a/src/Maker/MakeEntity.php +++ b/src/Maker/MakeEntity.php @@ -26,9 +26,9 @@ use Symfony\Bundle\MakerBundle\InputConfiguration; use Symfony\Bundle\MakerBundle\Str; use Symfony\Bundle\MakerBundle\Util\ClassDetails; +use Symfony\Bundle\MakerBundle\Util\ClassSource\Model\ClassProperty; use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator; use Symfony\Bundle\MakerBundle\Util\CliOutputHelper; -use Symfony\Bundle\MakerBundle\Util\ClassSource\Model\ClassProperty; use Symfony\Bundle\MakerBundle\Util\PhpCompatUtil; use Symfony\Bundle\MakerBundle\Validator; use Symfony\Component\Console\Command\Command; @@ -53,10 +53,10 @@ final class MakeEntity extends AbstractMaker implements InputAwareMakerInterface public function __construct( private FileManager $fileManager, private DoctrineHelper $doctrineHelper, - string $projectDirectory = null, - Generator $generator = null, - EntityClassGenerator $entityClassGenerator = null, - PhpCompatUtil $phpCompatUtil = null, + ?string $projectDirectory = null, + ?Generator $generator = null, + ?EntityClassGenerator $entityClassGenerator = null, + ?PhpCompatUtil $phpCompatUtil = null, ) { if (null !== $projectDirectory) { @trigger_error('The $projectDirectory constructor argument is no longer used since 1.41.0', \E_USER_DEPRECATED); @@ -309,7 +309,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen ]); } - public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void + public function configureDependencies(DependencyBuilder $dependencies, ?InputInterface $input = null): void { if (null !== $input && $input->getOption('api-resource')) { $dependencies->addClassDependency( diff --git a/src/Maker/MakeTest.php b/src/Maker/MakeTest.php index ca9997976..b98a314bc 100644 --- a/src/Maker/MakeTest.php +++ b/src/Maker/MakeTest.php @@ -160,7 +160,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen ]); } - public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void + public function configureDependencies(DependencyBuilder $dependencies, ?InputInterface $input = null): void { if (null === $input) { return; diff --git a/src/Maker/MakeUser.php b/src/Maker/MakeUser.php index 12d6d8b56..a5302e187 100644 --- a/src/Maker/MakeUser.php +++ b/src/Maker/MakeUser.php @@ -231,7 +231,7 @@ public function generate(InputInterface $input, ConsoleStyle $io, Generator $gen $io->text($nextSteps); } - public function configureDependencies(DependencyBuilder $dependencies, InputInterface $input = null): void + public function configureDependencies(DependencyBuilder $dependencies, ?InputInterface $input = null): void { // checking for SecurityBundle guarantees security.yaml is present $dependencies->addClassDependency( diff --git a/src/Renderer/FormTypeRenderer.php b/src/Renderer/FormTypeRenderer.php index 567e3516e..4b9864322 100644 --- a/src/Renderer/FormTypeRenderer.php +++ b/src/Renderer/FormTypeRenderer.php @@ -29,7 +29,7 @@ public function __construct( ) { } - public function render(ClassNameDetails $formClassDetails, array $formFields, ClassNameDetails $boundClassDetails = null, array $constraintClasses = [], array $extraUseClasses = []): void + public function render(ClassNameDetails $formClassDetails, array $formFields, ?ClassNameDetails $boundClassDetails = null, array $constraintClasses = [], array $extraUseClasses = []): void { $fieldTypeUseStatements = []; $fields = []; diff --git a/src/Security/InteractiveSecurityHelper.php b/src/Security/InteractiveSecurityHelper.php index 6da9cb6e4..d6a472ca5 100644 --- a/src/Security/InteractiveSecurityHelper.php +++ b/src/Security/InteractiveSecurityHelper.php @@ -21,7 +21,7 @@ */ final class InteractiveSecurityHelper { - public function guessFirewallName(SymfonyStyle $io, array $securityData, string $questionText = null): string + public function guessFirewallName(SymfonyStyle $io, array $securityData, ?string $questionText = null): string { $realFirewalls = array_filter( $securityData['security']['firewalls'] ?? [], @@ -45,7 +45,7 @@ static function ($item) { ); } - public function guessUserClass(SymfonyStyle $io, array $providers, string $questionText = null): string + public function guessUserClass(SymfonyStyle $io, array $providers, ?string $questionText = null): string { if (1 === \count($providers) && isset(current($providers)['entity'])) { $entityProvider = current($providers); diff --git a/src/Security/UserClassBuilder.php b/src/Security/UserClassBuilder.php index f77bfd132..ec6a7de09 100644 --- a/src/Security/UserClassBuilder.php +++ b/src/Security/UserClassBuilder.php @@ -12,8 +12,8 @@ namespace Symfony\Bundle\MakerBundle\Security; use PhpParser\Node; -use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator; use Symfony\Bundle\MakerBundle\Util\ClassSource\Model\ClassProperty; +use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; diff --git a/src/Util/YamlSourceManipulator.php b/src/Util/YamlSourceManipulator.php index ec1891a30..67da7a486 100644 --- a/src/Util/YamlSourceManipulator.php +++ b/src/Util/YamlSourceManipulator.php @@ -947,7 +947,7 @@ private function decrementDepth() --$this->depth; } - private function getCurrentIndentation(int $override = null): string + private function getCurrentIndentation(?int $override = null): string { $indent = $override ?? $this->indentationForDepths[$this->depth]; @@ -1174,7 +1174,7 @@ private function manuallyIncrementIndentation() $this->indentationForDepths[$this->depth] += $this->getPreferredIndentationSize(); } - private function isEOF(int $position = null) + private function isEOF(?int $position = null) { $position = null === $position ? $this->currentPosition : $position; @@ -1296,7 +1296,7 @@ private function isCharLineBreak(string $char): bool * Usually an empty line needs to be prepended to this result before * adding to the content. */ - private function indentMultilineYamlArray(string $yaml, int $indentOverride = null): string + private function indentMultilineYamlArray(string $yaml, ?int $indentOverride = null): string { $indent = $this->getCurrentIndentation($indentOverride); diff --git a/src/Validator.php b/src/Validator.php index 9e678b7f2..616f9b342 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -68,7 +68,7 @@ public static function validateClassName(string $className, string $errorMessage return $className; } - public static function notBlank(string $value = null): string + public static function notBlank(?string $value = null): string { if (null === $value || '' === $value) { throw new RuntimeCommandException('This value cannot be blank.'); @@ -176,7 +176,7 @@ public static function validateEmailAddress(?string $email): string return $email; } - public static function existsOrNull(string $className = null, array $entities = []): ?string + public static function existsOrNull(?string $className = null, array $entities = []): ?string { if (null !== $className) { self::validateClassName($className); @@ -204,7 +204,7 @@ public static function classExists(string $className, string $errorMessage = '') return $className; } - public static function entityExists(string $className = null, array $entities = []): string + public static function entityExists(?string $className = null, array $entities = []): string { self::notBlank($className); diff --git a/tests/Util/AutoloaderUtilTest.php b/tests/Util/AutoloaderUtilTest.php index bfc65baf0..a3f42b6c8 100644 --- a/tests/Util/AutoloaderUtilTest.php +++ b/tests/Util/AutoloaderUtilTest.php @@ -65,7 +65,7 @@ public function testIsNamespaceConfiguredToAutoload() } } - private function createComposerAutoloaderFinder(array $composerJsonParams = null): ComposerAutoloaderFinder + private function createComposerAutoloaderFinder(?array $composerJsonParams = null): ComposerAutoloaderFinder { $composerJsonParams = $composerJsonParams ?: [ 'autoload' => [ diff --git a/tests/Util/ClassSourceManipulatorTest.php b/tests/Util/ClassSourceManipulatorTest.php index 193587b79..0bdf78c40 100644 --- a/tests/Util/ClassSourceManipulatorTest.php +++ b/tests/Util/ClassSourceManipulatorTest.php @@ -20,8 +20,8 @@ use Symfony\Bundle\MakerBundle\Doctrine\RelationManyToOne; use Symfony\Bundle\MakerBundle\Doctrine\RelationOneToMany; use Symfony\Bundle\MakerBundle\Doctrine\RelationOneToOne; -use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator; use Symfony\Bundle\MakerBundle\Util\ClassSource\Model\ClassProperty; +use Symfony\Bundle\MakerBundle\Util\ClassSourceManipulator; use Symfony\Component\Security\Core\User\UserInterface; class ClassSourceManipulatorTest extends TestCase @@ -185,7 +185,7 @@ public function getAddSetterTests(): \Generator /** * @dataProvider getAttributeClassTests */ - public function testAddAttributeToClass(string $sourceFilename, string $expectedSourceFilename, string $attributeClass, array $attributeOptions, string $attributePrefix = null): void + public function testAddAttributeToClass(string $sourceFilename, string $expectedSourceFilename, string $attributeClass, array $attributeOptions, ?string $attributePrefix = null): void { $source = file_get_contents(__DIR__.'/fixtures/source/'.$sourceFilename); $expectedSource = file_get_contents(__DIR__.'/fixtures/add_class_attribute/'.$expectedSourceFilename); @@ -242,7 +242,7 @@ public function getAddEntityFieldTests(): \Generator yield 'entity_normal_add' => [ 'User_simple.php', - new ClassProperty(propertyName: 'fooProp', type: 'string', length: 255, nullable: false, options: ['comment' => 'new field']), + new ClassProperty(propertyName: 'fooProp', type: 'string', length: 255, nullable: false, options: ['comment' => 'new field']), 'User_simple.php', ]; @@ -389,9 +389,9 @@ public function testAddOneToManyRelation(string $sourceFilename, string $expecte $sourcePath = __DIR__.'/fixtures/source'; $expectedPath = __DIR__.'/fixtures/add_one_to_many_relation'; - /** @legacy - Remove when Doctrine/ORM 2.x is no longer supported. */ + /* @legacy - Remove when Doctrine/ORM 2.x is no longer supported. */ if (!class_exists(FieldMapping::class)) { - $expectedPath.= '/legacy'; + $expectedPath .= '/legacy'; } $this->runAddOneToManyRelationTests(