Skip to content

Commit 45f4b20

Browse files
committed
Add offsetGet to stub again
1 parent dc7b869 commit 45f4b20

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

phpstan.neon

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,10 @@ parameters:
1818
- '*tests/*/Source/*'
1919
- '*tests/*/data/*'
2020
ignoreErrors:
21-
-
22-
message: '#^Class TYPO3\\CMS\\Core\\Context\\[a-zA-Z]* not found\.#'
23-
path: src/Type/ContextDynamicReturnTypeExtension.php
2421
-
2522
message: "#^Calling PHPStan\\\\Reflection\\\\InitializerExprTypeResolver\\:\\:getClassConstFetchType\\(\\) is not covered by backward compatibility promise\\. The method might change in a minor PHPStan version\\.$#"
2623
count: 1
2724
path: src/Rule/ValidatorResolverOptionsRule.php
28-
-
29-
message: "#^Method SaschaEgerer\\\\PhpstanTypo3\\\\Tests\\\\Unit\\\\Type\\\\QueryResultToArrayDynamicReturnTypeExtension\\\\FrontendUserGroupCustomFindAllWithoutModelTypeRepository\\:\\:findAll\\(\\) return type with generic interface TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\QueryResultInterface does not specify its types\\: ModelType$#"
30-
count: 1
31-
path: tests/Unit/Type/QueryResultToArrayDynamicReturnTypeExtension/data/query-result-to-array.php
32-
-
33-
message: "#^PHPDoc tag @var for variable \\$queryResult contains generic class TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\Generic\\\\QueryResult but does not specify its types\\: ModelType$#"
34-
count: 2
35-
path: tests/Unit/Type/QueryResultToArrayDynamicReturnTypeExtension/data/query-result-to-array.php
36-
-
37-
message: "#^Return type \\(TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\QueryResultInterface\\) of method SaschaEgerer\\\\PhpstanTypo3\\\\Tests\\\\Unit\\\\Type\\\\QueryResultToArrayDynamicReturnTypeExtension\\\\FrontendUserGroupCustomFindAllWithoutModelTypeRepository\\:\\:findAll\\(\\) should be covariant with return type \\(array\\<int, SaschaEgerer\\\\PhpstanTypo3\\\\Tests\\\\Unit\\\\Type\\\\QueryResultToArrayDynamicReturnTypeExtension\\\\FrontendUserGroup\\>\\|TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\QueryResultInterface\\<SaschaEgerer\\\\PhpstanTypo3\\\\Tests\\\\Unit\\\\Type\\\\QueryResultToArrayDynamicReturnTypeExtension\\\\FrontendUserGroup\\>\\) of method TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\Repository\\<SaschaEgerer\\\\PhpstanTypo3\\\\Tests\\\\Unit\\\\Type\\\\QueryResultToArrayDynamicReturnTypeExtension\\\\FrontendUserGroup\\>\\:\\:findAll\\(\\)$#"
38-
count: 1
39-
path: tests/Unit/Type/QueryResultToArrayDynamicReturnTypeExtension/data/query-result-to-array.php
4025
-
4126
message: '#^Although PHPStan\\Reflection\\Php\\PhpPropertyReflection is covered by backward compatibility promise, this instanceof assumption might break because it''s not guaranteed to always stay the same\.$#'
4227
identifier: phpstanApi.instanceofAssumption

stubs/ObjectStorage.stub

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace TYPO3\CMS\Extbase\Persistence;
1010
class ObjectStorage implements \Iterator, \ArrayAccess
1111
{
1212
/**
13-
* @param TEntity|int|string $value
14-
* @return ($value is int ? TEntity|null : mixed)
13+
* @param TEntity|string|int $value
14+
* @phpstan-return TEntity|null
1515
*/
16-
public function offsetGet($value);
16+
public function offsetGet(mixed $value);
1717
}

tests/Unit/Type/data/object-storage-stub-files.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,11 @@ public function checkArrayAccess(): void
4141
assertType(self::class . '|null', $this->testStorage->offsetGet(0));
4242
assertType(self::class . '|null', $this->testStorage->offsetGet('0'));
4343
assertType(self::class . '|null', $this->testStorage->current());
44-
45-
// We ignore errors in the next line as this will produce an
46-
// "Offset 0 does not exist on TYPO3\CMS\Extbase\Persistence\ObjectStorage<ObjectStorage\My\Test\Extension\Domain\Model\MyModel>
47-
// due to the weird implementation of ArrayAccess in ObjectStorage::offsetGet()
48-
// @phpstan-ignore-next-line
4944
assertType(self::class . '|null', $this->testStorage[0]);
5045

5146
$myModel = new self();
5247

48+
assertType('mixed', $this->testStorage->offsetGet($this->testStorage->current()));
5349
assertType('mixed', $this->testStorage->offsetGet($myModel));
5450
}
5551

0 commit comments

Comments
 (0)