Skip to content

Commit 10b627a

Browse files
committed
feat: add phpstan
1 parent 2addb93 commit 10b627a

File tree

5 files changed

+69
-9
lines changed

5 files changed

+69
-9
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"php": "^8.2"
2525
},
2626
"require-dev": {
27-
"phpunit/phpunit": "^11.4"
27+
"phpunit/phpunit": "^11.4",
28+
"phpstan/phpstan": "^2.0"
2829
}
2930
}

composer.lock

+59-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
parameters:
2+
paths:
3+
- src
4+
5+
level: 8

src/Helpers.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ function isReturnError(mixed $value, string|UnitEnum|BackedEnum $type): bool
1616
return false;
1717
}
1818

19-
if (is_null($type)) {
20-
return true;
21-
}
22-
2319
return $value->type === $type;
2420
}
2521

@@ -30,7 +26,7 @@ function newReturnError(?string $message = null, null|string|UnitEnum|BackedEnum
3026

3127
function reportRE(ReturnError $re, mixed $additionalLogData = null): void
3228
{
33-
report($re->toString($additionalLogData));
29+
report($re->toString($additionalLogData)); /** @phpstan-ignore-line */
3430
}
3531

3632
/**
@@ -50,7 +46,7 @@ function unwrapRE(mixed $re, mixed $additionalLogData = null): mixed
5046
/**
5147
* @template T
5248
* @param callable(): T $callable
53-
* @return T|\App\ReturnError\ReturnError
49+
* @return T|\Amirhossein5\ReturnError\ReturnError
5450
*/
5551
function wrapRE(callable $callable): mixed
5652
{

tests/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
abstract class TestCase extends FrameworkTestCase
1111
{
12-
protected function assertThrows(Closure $test, string|Closure $expectedClass = Throwable::class, ?string $expectedMessage = null)
12+
protected function assertThrows(Closure $test, string $expectedClass = Throwable::class, ?string $expectedMessage = null): self
1313
{
1414
try {
1515
$test();

0 commit comments

Comments
 (0)