File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed
tests/PHPStan/Rules/Methods/data Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -51,15 +51,17 @@ public function isResolvable(): bool
5151 protected function getResult (): Type
5252 {
5353 if ($ this ->type ->isEnum ()->yes ()) {
54+ $ enumCases = $ this ->type ->getEnumCases ();
5455 if (
55- $ this ->type instanceof TemplateType
56- && $ this ->type ->getBound ()->equals (new ObjectType ('BackedEnum ' ))
56+ $ enumCases === []
57+ && $ this ->type instanceof TemplateType
58+ && (new ObjectType ('BackedEnum ' ))->isSuperTypeOf ($ this ->type ->getBound ())->yes ()
5759 ) {
5860 return new UnionType ([new IntegerType (), new StringType ()]);
5961 }
6062
6163 $ valueTypes = [];
62- foreach ($ this -> type -> getEnumCases () as $ enumCase ) {
64+ foreach ($ enumCases as $ enumCase ) {
6365 $ valueType = $ enumCase ->getBackingValueType ();
6466 if ($ valueType === null ) {
6567 continue ;
Original file line number Diff line number Diff line change @@ -24,3 +24,31 @@ public function bar(string $class, mixed $value): void
2424 $ this ->foo ($ class , $ value );
2525 }
2626}
27+
28+ interface SuperBackedEnum extends \BackedEnum
29+ {
30+ public function customMethod (): void ;
31+ }
32+
33+ class Bug2
34+ {
35+ /**
36+ * @template T of SuperBackedEnum
37+ * @param class-string<T> $class
38+ * @param value-of<T> $value
39+ */
40+ public function foo (string $ class , mixed $ value ): void
41+ {
42+ }
43+
44+ /**
45+ * @template Q of SuperBackedEnum
46+ * @param class-string<Q> $class
47+ * @param value-of<Q> $value
48+ */
49+ public function bar (string $ class , mixed $ value ): void
50+ {
51+ // Parameter #2 $value of static method Bug::foo() contains unresolvable type.
52+ $ this ->foo ($ class , $ value );
53+ }
54+ }
You can’t perform that action at this time.
0 commit comments