Skip to content

Commit 96e1fd6

Browse files
committed
phpstan level 9
opencode (opus 4.5)
1 parent c38d859 commit 96e1fd6

7 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎composer.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"test:infection": "vendor/bin/infection --threads=$(nproc) --min-msi=83 --verbose --coverage=build/phpunit",
5353
"test:integration": "vendor/bin/phpunit --testsuite=Integration --cache-directory=build/phpunit",
5454
"test:lint": "mkdir -p build && find src tests -name '*.php' -print0 | xargs -0 -n1 -P$(nproc) php -l | tee build/phplint.log",
55-
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=8 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
55+
"test:static-analysis": "mkdir -p build && bash -c 'vendor/bin/phpstan analyse src --no-progress --level=9 --error-format=junit | tee build/phpstan.junit.xml; if [ ${PIPESTATUS[0]} -ne \"0\" ]; then exit 1; fi'",
5656
"test:unit": "vendor/bin/phpunit --testsuite=Unit --coverage-text --coverage-clover=build/phpunit/clover.xml --coverage-html=build/phpunit/coverage-html --coverage-xml=build/phpunit/coverage-xml --log-junit=build/phpunit/junit.xml --cache-directory=build/phpunit"
5757
},
5858
"config": {

‎src/Exceptions/AbstractMock.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ private function getObjectData(object $value, array &$splObjectHashes): array|st
6969
if ($reflectionObject->hasMethod($method)) {
7070
$reflectionMethod = $reflectionObject->getMethod($method);
7171

72+
/** @var array<mixed> */
7273
$data = $this->getData($reflectionMethod->invoke($value), $splObjectHashes);
7374

7475
$data['__CLASS__'] = $value::class;

‎src/MockClassBuilder.php‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,15 +305,19 @@ public function enterNode(Node $node): null
305305
if ('self' === $node->name) {
306306
$reflectionMethod = new \ReflectionMethod($this->mockClassBuilder, 'replaceSelfWithOriginalClassInType');
307307

308-
$node->name = $reflectionMethod->invoke($this->mockClassBuilder, $this->reflectionClasses, $this->methodName, 'self');
308+
/** @var non-empty-string */
309+
$name = $reflectionMethod->invoke($this->mockClassBuilder, $this->reflectionClasses, $this->methodName, 'self');
310+
$node->name = $name;
309311

310312
return null;
311313
}
312314

313315
if ('parent' === $node->name) {
314316
$reflectionMethod = new \ReflectionMethod($this->mockClassBuilder, 'replaceSelfWithOriginalClassInType');
315317

316-
$node->name = $reflectionMethod->invoke($this->mockClassBuilder, $this->reflectionClasses, $this->methodName, 'parent');
318+
/** @var non-empty-string */
319+
$name = $reflectionMethod->invoke($this->mockClassBuilder, $this->reflectionClasses, $this->methodName, 'parent');
320+
$node->name = $name;
317321

318322
return null;
319323
}
@@ -402,9 +406,12 @@ private function resolveOriginalClassConst(
402406
if (\is_string($value)) {
403407
$matches = [];
404408
if (preg_match('/^'.$this->originalClassConstPattern($reflectionClass).'$/', $value, $matches)) {
409+
/** @var null|bool|float|int|string */
410+
$constantValue = $reflectionClass->getConstant($matches[1]);
411+
405412
return $this->resolveOriginalClassConst(
406413
$reflectionClass,
407-
$reflectionClass->getConstant($matches[1])
414+
$constantValue
408415
);
409416
}
410417

‎src/MockMethod/WithException.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct(
1515
string $expectedName,
1616
array $expectedParameters,
1717
private readonly \Throwable $exception,
18-
mixed $strict = true,
18+
bool $strict = true,
1919
) {
2020
$this->withoutReturn = new WithoutReturn(
2121
$expectedName,

‎src/MockMethod/WithReturn.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function __construct(
1515
string $expectedName,
1616
array $expectedParameters,
1717
private readonly mixed $return,
18-
mixed $strict = true,
18+
bool $strict = true,
1919
) {
2020
$this->withoutReturn = new WithoutReturn($expectedName, $expectedParameters, $strict);
2121
}

‎src/MockMethod/WithReturnSelf.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class WithReturnSelf implements MockMethodInterface
1414
public function __construct(
1515
string $expectedName,
1616
array $expectedParameters,
17-
mixed $strict = true,
17+
bool $strict = true,
1818
) {
1919
$this->withoutReturn = new WithoutReturn(
2020
$expectedName,

‎src/MockMethod/WithoutReturn.php‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class WithoutReturn implements MockMethodInterface
1313
/**
1414
* @param array<mixed> $expectedParameters
1515
*/
16-
public function __construct(private readonly string $expectedName, private readonly array $expectedParameters, private readonly mixed $strict = true) {}
16+
public function __construct(private readonly string $expectedName, private readonly array $expectedParameters, private readonly bool $strict = true) {}
1717

1818
/**
1919
* @param array<mixed> $actualParameters
@@ -118,10 +118,12 @@ private function compareEqual(mixed $actual, mixed $expected): bool
118118
}
119119

120120
if (\is_array($actual)) {
121+
/** @var array<mixed> $expected */
121122
return $this->compareArrayEqual($actual, $expected);
122123
}
123124

124125
if (\is_object($actual)) {
126+
/** @var object $expected */
125127
return $this->compareObjectEqual($actual, $expected);
126128
}
127129

0 commit comments

Comments
 (0)