Skip to content

Commit 17d8273

Browse files
committed
fix(ExceptionMustImplementNativeThrowableRule): Improve type assertion for nativeThrowable
- Change assertion from is_subclass_of to is_a for stricter type checking - Ensures that the provided nativeThrowable is a valid instance of Throwable
1 parent eaa34e0 commit 17d8273

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

baselines/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 8 errors
1+
# total 9 errors
22

33
includes:
44
- phpstanApi.runtimeReflection.neon

baselines/phpstanApi.runtimeReflection.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ parameters:
44
ignoreErrors:
55
-
66
message: '#^Function is_a\(\) is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine\. Use objects retrieved from ReflectionProvider instead\.$#'
7-
count: 1
7+
count: 2
88
path: ../src/Rule/Class_/ExceptionMustImplementNativeThrowableRule.php
99

1010
-
1111
message: '#^Function is_subclass_of\(\) is a runtime reflection concept that might not work in PHPStan because it uses fully static reflection engine\. Use objects retrieved from ReflectionProvider instead\.$#'
12-
count: 3
12+
count: 2
1313
path: ../src/Rule/Class_/ExceptionMustImplementNativeThrowableRule.php
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# total 1 error
1+
# total 2 errors
22

33
parameters:
44
ignoreErrors:
55
-
66
message: '#^Instead of "instanceof/is_a\(\)" use ReflectionProvider service or "\(new ObjectType\(\<desired_type\>\)\)\-\>isSuperTypeOf\(\<element_type\>\)" for static reflection to work$#'
7-
count: 1
7+
count: 2
88
path: ../src/Rule/Class_/ExceptionMustImplementNativeThrowableRule.php

src/Rule/Class_/ExceptionMustImplementNativeThrowableRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class ExceptionMustImplementNativeThrowableRule extends AbstractMixedNodeT
4040
*/
4141
public function __construct(string $nativeThrowable)
4242
{
43-
\assert(is_subclass_of($nativeThrowable, \Throwable::class));
43+
\assert(is_a($nativeThrowable, \Throwable::class, true));
4444
$this->nativeThrowable = $nativeThrowable;
4545
}
4646

0 commit comments

Comments
 (0)