Skip to content

Commit c92421b

Browse files
committed
Fix tests for PHP versions below 8.4
SplFixedArray::setSize() has the tentative return type true only since PHP 8.4. The SOAP E2E fixture is analysed in a PHP 8.2+ range from composer.json, so its implicitly nullable parameter is now reported as deprecated in PHP 8.4; declare it explicitly nullable instead. Amp-Thread-ID: https://ampcode.com/threads/T-01a1b1b9-0a7d-772a-a8bb-331fd76aa9cc
1 parent 8cf6b64 commit c92421b

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

‎tests/PHPStan/Rules/Methods/OverridingMethodRuleTest.php‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,14 @@ public function testOverridingFinalMethod(int $phpVersion, string $contravariant
143143

144144
if (PHP_VERSION_ID >= 80100) {
145145
$tip = 'Make it covariant, or use the #[\ReturnTypeWillChange] attribute to temporarily suppress the error.';
146-
$errors[] = [
147-
'Return type bool of method OverridingFinalMethod\FixedArray::setSize() is not covariant with tentative return type true of method SplFixedArray<mixed>::setSize().',
148-
125,
149-
$tip,
150-
];
146+
if (PHP_VERSION_ID >= 80400) {
147+
// SplFixedArray::setSize() has the tentative return type true since PHP 8.4, bool before
148+
$errors[] = [
149+
'Return type bool of method OverridingFinalMethod\FixedArray::setSize() is not covariant with tentative return type true of method SplFixedArray<mixed>::setSize().',
150+
125,
151+
$tip,
152+
];
153+
}
151154
$errors[] = [
152155
'Return type mixed of method OverridingFinalMethod\SomeIterator::getIterator() is not covariant with tentative return type Traversable of method IteratorAggregate<int,OverridingFinalMethod\Foo>::getIterator().',
153156
250,

‎tests/e2e/data/soap.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MySoapClient3 extends \SoapClient
2929
* @param string|null $wsdl
3030
* @param mixed[]|null $options
3131
*/
32-
public function __construct($wsdl, array $options = null)
32+
public function __construct($wsdl, ?array $options = null)
3333
{
3434
parent::SoapClient($wsdl, $options);
3535
}

0 commit comments

Comments
 (0)