Skip to content

Commit

Permalink
[CLEANUP] Add more type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverklee committed Sep 29, 2021
1 parent 8a1ce8d commit 01f9a10
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- Allow `DateTimeImmutable` as change and creation date (#734)
- Update the usage of the Fluid view helper classes (#732)
- Stop using patches for dependencies (713)
- Improve some type annotations (#712, #769, #776, #792)
- Improve some type annotations (#712, #769, #776, #792, #793)

## 3.6.1

Expand Down
6 changes: 4 additions & 2 deletions Classes/DataStructures/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

/**
* This class represents a list of models.
*
* @extends \SplObjectStorage<AbstractModel, int>
*/
class Collection extends \SplObjectStorage
{
Expand Down Expand Up @@ -162,9 +164,9 @@ private function rebuildUidCache(): void
* second one, 1 means that the second parameter is sorted before the first
* one and 0 means the parameters stay in order.
*
* @param mixed $callbackFunction a callback function to use with the models stored in the list, must not be empty
* @param callable $callbackFunction callback function to use with the models stored in the list, must not be empty
*/
public function sort($callbackFunction): void
public function sort(callable $callbackFunction): void
{
$items = iterator_to_array($this, false);
usort($items, $callbackFunction);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Logging/Interfaces/LoggingAware.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
*/
interface LoggingAware
{
public function injectLogManager(LogManagerInterface $logManager);
public function injectLogManager(LogManagerInterface $logManager): void;
}
14 changes: 9 additions & 5 deletions Tests/Functional/Mapper/AbstractDataMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* @covers \OliverKlee\Oelib\Mapper\AbstractDataMapper
*/
class AbstractDataMapperTest extends FunctionalTestCase
{
/**
Expand Down Expand Up @@ -353,11 +356,12 @@ public function getListOfModelsReturnsListOfModelInstances(): void
*/
public function getListOfModelsReturnsListOfModelWithProvidedTitle(): void
{
self::assertSame(
'foo',
$this->subject->getListOfModels([['uid' => 1, 'title' => 'foo']])
->current()->getTitle()
);
/** @var Collection<TestingModel> $models */
$models = $this->subject->getListOfModels([['uid' => 1, 'title' => 'foo']]);

/** @var TestingModel $current */
$current = $models->current();
self::assertSame('foo', $current->getTitle());
}

// Tests concerning load and reload
Expand Down
10 changes: 0 additions & 10 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ parameters:
count: 1
path: Classes/Authentication/FrontEndLoginManager.php

-
message: "#^Class OliverKlee\\\\Oelib\\\\DataStructures\\\\Collection extends generic class SplObjectStorage but does not specify its types\\: TObject, TData$#"
count: 1
path: Classes/DataStructures/Collection.php

-
message: "#^Method OliverKlee\\\\Oelib\\\\Interfaces\\\\LoginManager\\:\\:getLoggedInUser\\(\\) has parameter \\$mapperName with generic class OliverKlee\\\\Oelib\\\\Mapper\\\\AbstractDataMapper but does not specify its types\\: M$#"
count: 1
path: Classes/Interfaces/LoginManager.php

-
message: "#^Method OliverKlee\\\\Oelib\\\\Logging\\\\Interfaces\\\\LoggingAware\\:\\:injectLogManager\\(\\) has no return typehint specified\\.$#"
count: 1
path: Classes/Logging/Interfaces/LoggingAware.php

-
message: "#^Method OliverKlee\\\\Oelib\\\\Mapper\\\\AbstractDataMapper\\:\\:saveManyToManyAndCommaSeparatedRelatedModels\\(\\) has parameter \\$mapper with generic class OliverKlee\\\\Oelib\\\\Mapper\\\\AbstractDataMapper but does not specify its types\\: M$#"
count: 1
Expand Down

0 comments on commit 01f9a10

Please sign in to comment.