Commit 8c28103c authored by Oliver Klee's avatar Oliver Klee Committed by Christian Kuhn
Browse files

[TASK] Ignore PHPStan errors in GeneralUtilityTest for contract violations

In tests for `GeneralUtility` that explicitly violate the contract
(and test the correct error handling in those cases), PHPStan errors about
the contract violation are not helpful and rather clutter the
PHPStan baseline.

So these errors are now silenced with an annotation in the corresponding
tests, allowing us to focus on PHPStan errors about actual issues.

Note: We only use this annotation in tests, not in production code,
to avoid silencing errors about actual problems.

Resolves: #97574
Releases: main, 11.5
Change-Id: I2586dd77a4e3f9d801e24af68ab29984ad8d02c5
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/74547

Tested-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Nikita Hovratov's avatarNikita Hovratov <nikita.h@live.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 7b4d1cd5
......@@ -2210,31 +2210,6 @@ parameters:
count: 3
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Parameter \\#1 \\$className of static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:makeInstance\\(\\) expects string, array given\\.$#"
count: 1
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Parameter \\#1 \\$className of static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:makeInstance\\(\\) expects string, array\\<int, string\\> given\\.$#"
count: 1
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Parameter \\#1 \\$className of static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:makeInstance\\(\\) expects string, int given\\.$#"
count: 1
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Parameter \\#1 \\$className of static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:makeInstance\\(\\) expects string, null given\\.$#"
count: 1
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Parameter \\#1 \\$directory of static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:mkdir_deep\\(\\) expects string, array given\\.$#"
count: 1
path: ../../typo3/sysext/core/Tests/Unit/Utility/GeneralUtilityTest.php
-
message: "#^Parameter \\#1 \\$expected of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertInstanceOf\\(\\) expects class\\-string\\<foo&PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\>, class\\-string\\<foo\\>&class\\-string\\<PHPUnit\\\\Framework\\\\MockObject\\\\MockObject\\> given\\.$#"
count: 1
......
......@@ -2582,6 +2582,7 @@ class GeneralUtilityTest extends UnitTestCase
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1303662955);
// @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
GeneralUtility::mkdir_deep([]);
}
......@@ -3062,6 +3063,7 @@ class GeneralUtilityTest extends UnitTestCase
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1288965219);
// @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
GeneralUtility::makeInstance(null);
}
......@@ -3073,6 +3075,7 @@ class GeneralUtilityTest extends UnitTestCase
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1288965219);
// @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
GeneralUtility::makeInstance(0);
}
......@@ -3084,6 +3087,7 @@ class GeneralUtilityTest extends UnitTestCase
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1288965219);
// @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
GeneralUtility::makeInstance([]);
}
......@@ -3095,6 +3099,7 @@ class GeneralUtilityTest extends UnitTestCase
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionCode(1288965219);
// @phpstan-ignore-next-line We're explicitly checking the behavior for a contract violation.
GeneralUtility::makeInstance(['foo']);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment