From a3638a70d94df7c661cbeedcd20a77759674c630 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 18 May 2024 19:21:42 +0700 Subject: [PATCH] PHPStan 1.11 TypeCombinator invalid usage on Rector config fix --- config/v10/typo3-100.php | 11 ++-- config/v13/strict-types.php | 51 ++++++++++++++----- ...pMethodToRecordIconAltTextMethodRector.php | 6 ++- 3 files changed, 47 insertions(+), 21 deletions(-) diff --git a/config/v10/typo3-100.php b/config/v10/typo3-100.php index 73a220460..29bd101f4 100644 --- a/config/v10/typo3-100.php +++ b/config/v10/typo3-100.php @@ -9,7 +9,6 @@ use PHPStan\Type\NullType; use PHPStan\Type\ObjectType; use PHPStan\Type\StringType; -use PHPStan\Type\TypeCombinator; use PHPStan\Type\UnionType; use Rector\Config\RectorConfig; use Rector\Renaming\Rector\MethodCall\RenameMethodRector; @@ -73,12 +72,12 @@ new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface', 'getUid', - TypeCombinator::addNull(new IntegerType()) + new UnionType([new NullType(), new IntegerType()]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface', 'getPid', - TypeCombinator::addNull(new IntegerType()) + new UnionType([new NullType(), new IntegerType()]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface', @@ -93,12 +92,12 @@ new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject', 'getUid', - TypeCombinator::addNull(new IntegerType()) + new UnionType([new NullType(), new IntegerType()]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject', 'getPid', - TypeCombinator::addNull(new IntegerType()) + new UnionType([new NullType(), new IntegerType()]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject', @@ -313,7 +312,7 @@ new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder', 'getTargetPageUid', - TypeCombinator::addNull(new IntegerType()) + new UnionType([new NullType(), new IntegerType()]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder', diff --git a/config/v13/strict-types.php b/config/v13/strict-types.php index 36962ad3f..2bad5fb87 100644 --- a/config/v13/strict-types.php +++ b/config/v13/strict-types.php @@ -6,9 +6,10 @@ use PHPStan\Type\BooleanType; use PHPStan\Type\IntegerType; use PHPStan\Type\MixedType; +use PHPStan\Type\NullType; use PHPStan\Type\ObjectType; use PHPStan\Type\StringType; -use PHPStan\Type\TypeCombinator; +use PHPStan\Type\UnionType; use PHPStan\Type\VoidType; use Rector\Config\RectorConfig; use Rector\StaticTypeMapper\ValueObject\Type\SelfObjectType; @@ -138,12 +139,12 @@ new AddPropertyTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject', 'uid', - TypeCombinator::addNull(new IntegerType()) + new UnionType([new NullType(), new IntegerType()]) ), new AddPropertyTypeDeclaration( 'TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject', 'pid', - TypeCombinator::addNull(new IntegerType()) + new UnionType([new NullType(), new IntegerType()]) ), ]); @@ -670,19 +671,33 @@ new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'hasProperty', new BooleanType()), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getProperty', new MixedType(true)), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getSize', new IntegerType()), - new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getModificationTime', new IntegerType()), + new AddReturnTypeDeclaration( + 'TYPO3\CMS\Core\Resource\FileInterface', + 'getModificationTime', + new IntegerType() + ), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getCreationTime', new IntegerType()), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getSha1', new StringType()), - new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getNameWithoutExtension', new StringType()), + new AddReturnTypeDeclaration( + 'TYPO3\CMS\Core\Resource\FileInterface', + 'getNameWithoutExtension', + new StringType() + ), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getExtension', new StringType()), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getContents', new StringType()), - new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getForLocalProcessing', new StringType()), + new AddReturnTypeDeclaration( + 'TYPO3\CMS\Core\Resource\FileInterface', + 'getForLocalProcessing', + new StringType() + ), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getMimeType', new StringType()), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'delete', new BooleanType()), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'isIndexed', new BooleanType()), - new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'getPublicUrl', TypeCombinator::addNull( - new StringType() - )), + new AddReturnTypeDeclaration( + 'TYPO3\CMS\Core\Resource\FileInterface', + 'getPublicUrl', + new UnionType([new NullType(), new StringType()]) + ), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\FileInterface', 'toArray', new ArrayType( new MixedType(), new MixedType() @@ -695,14 +710,22 @@ 'setContents', new SelfObjectType('TYPO3\CMS\Core\Resource\FileInterface') ), - new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\ResourceInterface', 'getIdentifier', new StringType()), + new AddReturnTypeDeclaration( + 'TYPO3\CMS\Core\Resource\ResourceInterface', + 'getIdentifier', + new StringType() + ), new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\ResourceInterface', 'getName', new StringType()), new AddReturnTypeDeclaration( 'TYPO3\CMS\Core\Resource\ResourceInterface', 'getStorage', new ObjectType('TYPO3\CMS\Core\Resource\ResourceStorage') ), - new AddReturnTypeDeclaration('TYPO3\CMS\Core\Resource\ResourceInterface', 'getHashedIdentifier', new StringType()), + new AddReturnTypeDeclaration( + 'TYPO3\CMS\Core\Resource\ResourceInterface', + 'getHashedIdentifier', + new StringType() + ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Core\Resource\ResourceInterface', 'getParentFolder', @@ -767,12 +790,12 @@ new AddReturnTypeDeclaration( 'TYPO3\CMS\Core\Resource\Driver\DriverInterface', 'getParentFolderIdentifierOfIdentifier', - TypeCombinator::addNull(new StringType()) + new UnionType([new NullType(), new StringType()]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Core\Resource\Driver\DriverInterface', 'getPublicUrl', - TypeCombinator::addNull(new StringType()) + new UnionType([new NullType(), new StringType()]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Core\Resource\Driver\DriverInterface', @@ -950,7 +973,7 @@ new AddReturnTypeDeclaration( 'TYPO3\CMS\Core\Resource\FolderInterface', 'getFile', - TypeCombinator::addNull(new ObjectType('TYPO3\CMS\Core\Resource\FileInterface')) + new UnionType([new NullType(), new ObjectType('TYPO3\CMS\Core\Resource\FileInterface')]) ), new AddReturnTypeDeclaration( 'TYPO3\CMS\Core\Resource\FolderInterface', diff --git a/rules/TYPO312/v4/MigrateRecordTooltipMethodToRecordIconAltTextMethodRector.php b/rules/TYPO312/v4/MigrateRecordTooltipMethodToRecordIconAltTextMethodRector.php index 92900582e..d37102a2f 100644 --- a/rules/TYPO312/v4/MigrateRecordTooltipMethodToRecordIconAltTextMethodRector.php +++ b/rules/TYPO312/v4/MigrateRecordTooltipMethodToRecordIconAltTextMethodRector.php @@ -57,7 +57,11 @@ public function refactor(Node $node): ?Node $concatenationWithTitleAttribute = [ new String_('title="'), - $this->nodeFactory->createStaticCall('TYPO3\CMS\Backend\Utility\BackendUtility', 'getRecordIconAltText', $node->args), + $this->nodeFactory->createStaticCall( + 'TYPO3\CMS\Backend\Utility\BackendUtility', + 'getRecordIconAltText', + $node->args + ), new String_('"'), ];