@@ -55,8 +55,9 @@ public function specifyTypes(
55
55
TypeSpecifierContext $ context ,
56
56
): SpecifiedTypes
57
57
{
58
- $ propertyNameType = $ scope ->getType ($ node ->getArgs ()[1 ]->value );
59
- if (!$ propertyNameType instanceof ConstantStringType) {
58
+ $ propertyNameTypes = $ scope ->getType ($ node ->getArgs ()[1 ]->value )->getConstantStrings ();
59
+
60
+ if ($ propertyNameTypes === []) {
60
61
return $ this ->typeSpecifier ->create (
61
62
new FuncCall (new FullyQualified ('property_exists ' ), $ node ->getRawArgs ()),
62
63
new ConstantBooleanType (true ),
@@ -65,34 +66,41 @@ public function specifyTypes(
65
66
);
66
67
}
67
68
68
- if ($ propertyNameType ->getValue () === '' ) {
69
- return new SpecifiedTypes ([], []);
69
+ $ hasPropertyTypes = [];
70
+ foreach ($ propertyNameTypes as $ propertyNameType ) {
71
+ $ hasPropertyTypes [] = new HasPropertyType ($ propertyNameType ->getValue ());
70
72
}
71
73
72
74
$ objectType = $ scope ->getType ($ node ->getArgs ()[0 ]->value );
73
75
if ($ objectType instanceof ConstantStringType) {
74
76
return new SpecifiedTypes ([], []);
75
77
} elseif ($ objectType ->isObject ()->yes ()) {
76
- $ propertyNode = new PropertyFetch (
77
- $ node ->getArgs ()[0 ]->value ,
78
- new Identifier ($ propertyNameType ->getValue ()),
79
- );
78
+ $ propertyNodes = [];
79
+
80
+ foreach ($ propertyNameTypes as $ propertyNameType ) {
81
+ $ propertyNodes [] = new PropertyFetch (
82
+ $ node ->getArgs ()[0 ]->value ,
83
+ new Identifier ($ propertyNameType ->getValue ()),
84
+ );
85
+ }
80
86
} else {
81
87
return new SpecifiedTypes ([], []);
82
88
}
83
89
84
- $ propertyReflection = $ this ->propertyReflectionFinder ->findPropertyReflectionFromNode ($ propertyNode , $ scope );
85
- if ($ propertyReflection !== null ) {
86
- if (!$ propertyReflection ->isNative ()) {
87
- return new SpecifiedTypes ([], []);
90
+ foreach ($ propertyNodes as $ propertyNode ) {
91
+ $ propertyReflection = $ this ->propertyReflectionFinder ->findPropertyReflectionFromNode ($ propertyNode , $ scope );
92
+ if ($ propertyReflection !== null ) {
93
+ if (!$ propertyReflection ->isNative ()) {
94
+ return new SpecifiedTypes ([], []);
95
+ }
88
96
}
89
97
}
90
98
91
99
return $ this ->typeSpecifier ->create (
92
100
$ node ->getArgs ()[0 ]->value ,
93
101
new IntersectionType ([
94
102
new ObjectWithoutClassType (),
95
- new HasPropertyType ( $ propertyNameType -> getValue ()) ,
103
+ ... $ hasPropertyTypes ,
96
104
]),
97
105
$ context ,
98
106
$ scope ,
0 commit comments