Skip to content

Commit

Permalink
PHPStan 1.11 TypeCombinator invalid usage on Rector config fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored and simonschaufi committed May 18, 2024
1 parent d29d8ac commit a3638a7
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 21 deletions.
11 changes: 5 additions & 6 deletions config/v10/typo3-100.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
51 changes: 37 additions & 14 deletions config/v13/strict-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()])
),
]);

Expand Down Expand Up @@ -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()
Expand All @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_('"'),
];

Expand Down

0 comments on commit a3638a7

Please sign in to comment.