33namespace PHPStan \Type \PHPUnit \Assert ;
44
55use PhpParser \Node \Arg ;
6+ use PhpParser \Node \Expr \BinaryOp \Identical ;
7+ use PhpParser \Node \Expr \FuncCall ;
8+ use PhpParser \Node \Expr \Instanceof_ ;
69use PhpParser \Node \Name ;
710use PHPStan \Analyser \Scope ;
811use PHPStan \Analyser \SpecifiedTypes ;
@@ -117,7 +120,7 @@ private static function getExpressionResolvers(): array
117120 {
118121 if (self ::$ resolvers === null ) {
119122 self ::$ resolvers = [
120- 'InstanceOf ' => function (Scope $ scope , Arg $ class , Arg $ object ) {
123+ 'InstanceOf ' => function (Scope $ scope , Arg $ class , Arg $ object ): ? Instanceof_ {
121124 $ classType = $ scope ->getType ($ class ->value );
122125 if (!$ classType instanceof ConstantStringType) {
123126 return null ;
@@ -128,64 +131,64 @@ private static function getExpressionResolvers(): array
128131 new \PhpParser \Node \Name ($ classType ->getValue ())
129132 );
130133 },
131- 'Same ' => function (Scope $ scope , Arg $ expected , Arg $ actual ) {
134+ 'Same ' => function (Scope $ scope , Arg $ expected , Arg $ actual ): Identical {
132135 return new \PhpParser \Node \Expr \BinaryOp \Identical (
133136 $ expected ->value ,
134137 $ actual ->value
135138 );
136139 },
137- 'True ' => function (Scope $ scope , Arg $ actual ) {
140+ 'True ' => function (Scope $ scope , Arg $ actual ): Identical {
138141 return new \PhpParser \Node \Expr \BinaryOp \Identical (
139142 $ actual ->value ,
140143 new \PhpParser \Node \Expr \ConstFetch (new Name ('true ' ))
141144 );
142145 },
143- 'False ' => function (Scope $ scope , Arg $ actual ) {
146+ 'False ' => function (Scope $ scope , Arg $ actual ): Identical {
144147 return new \PhpParser \Node \Expr \BinaryOp \Identical (
145148 $ actual ->value ,
146149 new \PhpParser \Node \Expr \ConstFetch (new Name ('false ' ))
147150 );
148151 },
149- 'Null ' => function (Scope $ scope , Arg $ actual ) {
152+ 'Null ' => function (Scope $ scope , Arg $ actual ): Identical {
150153 return new \PhpParser \Node \Expr \BinaryOp \Identical (
151154 $ actual ->value ,
152155 new \PhpParser \Node \Expr \ConstFetch (new Name ('null ' ))
153156 );
154157 },
155- 'IsArray ' => function (Scope $ scope , Arg $ actual ) {
158+ 'IsArray ' => function (Scope $ scope , Arg $ actual ): FuncCall {
156159 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_array ' ), [$ actual ]);
157160 },
158- 'IsBool ' => function (Scope $ scope , Arg $ actual ) {
161+ 'IsBool ' => function (Scope $ scope , Arg $ actual ): FuncCall {
159162 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_bool ' ), [$ actual ]);
160163 },
161- 'IsCallable ' => function (Scope $ scope , Arg $ actual ) {
164+ 'IsCallable ' => function (Scope $ scope , Arg $ actual ): FuncCall {
162165 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_callable ' ), [$ actual ]);
163166 },
164- 'IsFloat ' => function (Scope $ scope , Arg $ actual ) {
167+ 'IsFloat ' => function (Scope $ scope , Arg $ actual ): FuncCall {
165168 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_float ' ), [$ actual ]);
166169 },
167- 'IsInt ' => function (Scope $ scope , Arg $ actual ) {
170+ 'IsInt ' => function (Scope $ scope , Arg $ actual ): FuncCall {
168171 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_int ' ), [$ actual ]);
169172 },
170- 'IsIterable ' => function (Scope $ scope , Arg $ actual ) {
173+ 'IsIterable ' => function (Scope $ scope , Arg $ actual ): FuncCall {
171174 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_iterable ' ), [$ actual ]);
172175 },
173- 'IsNumeric ' => function (Scope $ scope , Arg $ actual ) {
176+ 'IsNumeric ' => function (Scope $ scope , Arg $ actual ): FuncCall {
174177 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_numeric ' ), [$ actual ]);
175178 },
176- 'IsObject ' => function (Scope $ scope , Arg $ actual ) {
179+ 'IsObject ' => function (Scope $ scope , Arg $ actual ): FuncCall {
177180 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_object ' ), [$ actual ]);
178181 },
179- 'IsResource ' => function (Scope $ scope , Arg $ actual ) {
182+ 'IsResource ' => function (Scope $ scope , Arg $ actual ): FuncCall {
180183 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_resource ' ), [$ actual ]);
181184 },
182- 'IsString ' => function (Scope $ scope , Arg $ actual ) {
185+ 'IsString ' => function (Scope $ scope , Arg $ actual ): FuncCall {
183186 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_string ' ), [$ actual ]);
184187 },
185- 'IsScalar ' => function (Scope $ scope , Arg $ actual ) {
188+ 'IsScalar ' => function (Scope $ scope , Arg $ actual ): FuncCall {
186189 return new \PhpParser \Node \Expr \FuncCall (new Name ('is_scalar ' ), [$ actual ]);
187190 },
188- 'InternalType ' => function (Scope $ scope , Arg $ type , Arg $ value ) {
191+ 'InternalType ' => function (Scope $ scope , Arg $ type , Arg $ value ): ? FuncCall {
189192 $ typeType = $ scope ->getType ($ type ->value );
190193 if (!$ typeType instanceof ConstantStringType) {
191194 return null ;
0 commit comments