Skip to content

Commit 71b09e3

Browse files
Merge pull request #170 from oliverklee/task/align-stubs-with-core
[TASK] Port some type annotation improvements from the Core
2 parents 85ff3e4 + 883c5dc commit 71b09e3

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

stubs/ObjectStorage.stub

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@ class ObjectStorage implements \Iterator, \ArrayAccess
1515
protected $storage;
1616

1717
/**
18-
* @param TEntity $value
18+
* @param TEntity|string|null $value
1919
* @param mixed $information
2020
*/
2121
public function offsetSet($value, $information);
2222

2323
/**
24-
* @param TEntity|int $value
24+
* @param TEntity|int|string $value
2525
* @return bool
2626
*/
2727
public function offsetExists($value);
2828

2929
/**
30-
* @param TEntity|int $value
30+
* @param TEntity|int|string $value
3131
*/
3232
public function offsetUnset($value);
3333

3434
/**
35-
* @param TEntity|int $value
35+
* @param TEntity|int|string $value
3636
* @return ($value is int ? TEntity|null : mixed)
3737
*/
3838
public function offsetGet($value);
3939

4040
/**
4141
* This is different from the SplObjectStorage as the key in this implementation is the object hash (string).
4242
* @phpstan-ignore-next-line See https://forge.typo3.org/issues/98146
43-
* @return string|null
43+
* @return string
4444
*/
4545
// @phpstan-ignore-next-line See https://forge.typo3.org/issues/98146
4646
public function key();

stubs/QueryInterface.stub

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@ namespace TYPO3\CMS\Extbase\Persistence;
66
*/
77
interface QueryInterface
88
{
9+
// We have to define the constants here to be able to use them in other stubs.
10+
// See https://phpstan.org/user-guide/stub-files
11+
public const ORDER_ASCENDING = 'ASC';
12+
public const ORDER_DESCENDING = 'DESC';
13+
914
/**
1015
* @param bool $returnRawQueryResult
11-
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface<ModelType>|array<string, mixed>
16+
* @return \TYPO3\CMS\Extbase\Persistence\QueryResultInterface<ModelType>|list<array<string, mixed>>
1217
*/
1318
public function execute($returnRawQueryResult = false);
1419

stubs/QueryResult.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
1010
class QueryResult implements QueryResultInterface
1111
{
1212
/**
13-
* @return null|ModelType
13+
* @return ModelType|null
1414
*/
1515
public function getFirst();
1616
}

stubs/QueryResultInterface.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface QueryResultInterface extends \Countable, \Iterator, \ArrayAccess
1414
public function getQuery();
1515

1616
/**
17-
* @return null|ModelType
17+
* @return ModelType|null
1818
*/
1919
public function getFirst();
2020

stubs/Repository.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Repository
4747
public function findByIdentifier($identifier);
4848

4949
/**
50-
* @phpstan-param array<string,string> $defaultOrderings
50+
* @phpstan-param array<non-empty-string, QueryInterface::ORDER_*> $defaultOrderings
5151
* @phpstan-return void
5252
*/
5353
public function setDefaultOrderings($defaultOrderings);

0 commit comments

Comments
 (0)