File tree Expand file tree Collapse file tree
src/Psalm/Internal/Analyzer/Statements/Expression Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -110,6 +110,11 @@ public static function analyze(
110110 $ stmt ->cond ->getAttributes (),
111111 );
112112 }
113+ } elseif ($ stmt ->cond instanceof PhpParser \Node \Expr \ClassConstFetch
114+ && $ stmt ->cond ->name instanceof PhpParser \Node \Identifier
115+ && $ stmt ->cond ->name ->toString () === 'class '
116+ ) {
117+ // do nothing
113118 } elseif ($ stmt ->cond instanceof PhpParser \Node \Expr \ConstFetch
114119 && $ stmt ->cond ->name ->toString () === 'true '
115120 ) {
Original file line number Diff line number Diff line change @@ -147,6 +147,26 @@ function bar(mixed $foo): int {
147147 'ignored_issues ' => [],
148148 'php_version ' => '8.0 ' ,
149149 ],
150+ 'matchOnConstClassFetch ' => [
151+ 'code ' => '<?php
152+ final class Obj1 {
153+ public string $propFromObj1 = "str";
154+ }
155+ final class Obj2 {
156+ public int $propFromObj2 = 42;
157+ }
158+
159+ function process(Obj1|Obj2 $obj): int|string
160+ {
161+ return match ($obj::class) {
162+ Obj1::class => $obj->propFromObj1,
163+ Obj2::class => $obj->propFromObj2,
164+ };
165+ } ' ,
166+ 'assertions ' => [],
167+ 'ignored_issues ' => [],
168+ 'php_version ' => '8.0 ' ,
169+ ],
150170 ];
151171 }
152172
You can’t perform that action at this time.
0 commit comments