Skip to content

Commit

Permalink
[CLEANUP] Use specific PHPStan error code in the annotations (#602)
Browse files Browse the repository at this point in the history
Also harden some array accesses in the tests.

Fixes #586
  • Loading branch information
oliverklee authored May 15, 2024
1 parent b4109f3 commit 3c60224
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function findByUidsSilentlyIgnoresNonStringUids(): void
{
$this->importCSVDataSet(__DIR__ . '/Fixtures/UserGroupWithAllScalarData.csv');

// @phpstan-ignore-next-line We are explicitly testing with a contract-violating value.
// @phpstan-ignore argument.type (We are explicitly testing with a contract-violating value.)
$models = $this->subject->findByUids([1, '\'"--ab']);

self::assertCount(1, $models);
Expand Down
11 changes: 6 additions & 5 deletions Tests/Unit/Domain/Model/FrontendUserGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ protected function setUp(): void

protected function tearDown(): void
{
// @phpstan-ignore-next-line We know that the necessary array keys exist.
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FrontendUserGroup::class]);
// @phpstan-ignore offsetAccess.nonOffsetAccessible, offsetAccess.nonOffsetAccessible
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']);
MakeInstanceCacheFlusher::flushMakeInstanceCache();
parent::tearDown();
}
Expand All @@ -48,9 +48,10 @@ public function isAbstractEntity(): void
*/
public function canBeSubclassed(): void
{
// @phpstan-ignore-next-line We know that the necessary array keys exist.
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FrontendUserGroup::class]
= ['className' => XclassFrontendUserGroup::class];
// @phpstan-ignore offsetAccess.nonOffsetAccessible, offsetAccess.nonOffsetAccessible
$xclassConfiguration = &$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'];
self::assertIsArray($xclassConfiguration);
$xclassConfiguration[FrontendUserGroup::class] = ['className' => XclassFrontendUserGroup::class];

$instance = GeneralUtility::makeInstance(FrontendUserGroup::class);

Expand Down
10 changes: 6 additions & 4 deletions Tests/Unit/Domain/Model/FrontendUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ protected function setUp(): void

protected function tearDown(): void
{
// @phpstan-ignore-next-line We know that the necessary array keys exist.
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FrontendUser::class]);
// @phpstan-ignore offsetAccess.nonOffsetAccessible, offsetAccess.nonOffsetAccessible
unset($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']);
MakeInstanceCacheFlusher::flushMakeInstanceCache();
parent::tearDown();
}
Expand All @@ -50,8 +50,10 @@ public function isAbstractEntity(): void
*/
public function canBeSubclassed(): void
{
// @phpstan-ignore-next-line We know that the necessary array keys exist.
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][FrontendUser::class] = ['className' => XclassFrontendUser::class];
// @phpstan-ignore offsetAccess.nonOffsetAccessible, offsetAccess.nonOffsetAccessible
$xclassConfiguration = &$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'];
self::assertIsArray($xclassConfiguration);
$xclassConfiguration[FrontendUser::class] = ['className' => XclassFrontendUser::class];

$instance = GeneralUtility::makeInstance(FrontendUser::class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp(): void

if (\interface_exists(ObjectManagerInterface::class)) {
$objectManagerStub = $this->createStub(ObjectManagerInterface::class);
// @phpstan-ignore-next-line This line is 11LTS-specific, but we're running PHPStan on TYPO3 12.
// @phpstan-ignore arguments.count (This line is 11LTS-specific, but we're running PHPStan on TYPO3 12.)
$this->subject = new FrontendUserGroupRepository($objectManagerStub);
} else {
$this->subject = new FrontendUserGroupRepository();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function setUp(): void

if (\interface_exists(ObjectManagerInterface::class)) {
$objectManagerStub = $this->createStub(ObjectManagerInterface::class);
// @phpstan-ignore-next-line This line is 11LTS-specific, but we're running PHPStan on TYPO3 12.
// @phpstan-ignore arguments.count (This line is 11LTS-specific, but we're running PHPStan on TYPO3 12.)
$this->subject = new FrontendUserRepository($objectManagerStub);
} else {
$this->subject = new FrontendUserRepository();
Expand Down

0 comments on commit 3c60224

Please sign in to comment.