77use PDO ;
88use PhpParser \Node \Expr ;
99use PhpParser \Node \Expr \MethodCall ;
10- use PHPStan \Reflection \MethodReflection ;
1110use PHPStan \Type \Constant \ConstantArrayType ;
1211use PHPStan \Type \Constant \ConstantArrayTypeBuilder ;
1312use PHPStan \Type \Constant \ConstantIntegerType ;
1817
1918final class PdoStatementReflection
2019{
21- public function findPrepareQueryStringExpression (MethodReflection $ methodReflection , MethodCall $ methodCall ): ?Expr
20+ public function findPrepareQueryStringExpression (MethodCall $ methodCall ): ?Expr
2221 {
2322 $ exprFinder = new ExpressionFinder ();
2423 $ queryExpr = $ exprFinder ->findQueryStringExpression ($ methodCall );
@@ -35,10 +34,8 @@ public function findPrepareQueryStringExpression(MethodReflection $methodReflect
3534
3635 /**
3736 * @param PDO::FETCH* $fetchType
38- *
39- * @return Type|null
4037 */
41- public function getStatementResultType (Type $ statementType , int $ fetchType )
38+ public function getStatementResultType (Type $ statementType , int $ fetchType ): ? Type
4239 {
4340 if (!$ statementType instanceof GenericObjectType) {
4441 return null ;
@@ -50,7 +47,8 @@ public function getStatementResultType(Type $statementType, int $fetchType)
5047 }
5148
5249 $ resultType = $ genericTypes [0 ];
53- if ((PDO ::FETCH_NUM === $ fetchType || PDO ::FETCH_ASSOC === $ fetchType ) && $ resultType instanceof ConstantArrayType) {
50+ if ((PDO ::FETCH_NUM === $ fetchType || PDO ::FETCH_ASSOC === $ fetchType ) &&
51+ $ resultType instanceof ConstantArrayType && \count ($ resultType ->getValueTypes ()) > 0 ) {
5452 $ builder = ConstantArrayTypeBuilder::createEmpty ();
5553
5654 $ keyTypes = $ resultType ->getKeyTypes ();
0 commit comments