From 0a004e899d63fb989a90148d4170f74971f20b50 Mon Sep 17 00:00:00 2001
From: Jan Nedbal <janedbal@gmail.com>
Date: Fri, 30 Aug 2024 11:33:33 +0200
Subject: [PATCH 1/2] ConstantArrayType: fix returned
 ConstantArrayTypeAndMethod

---
 src/Type/Constant/ConstantArrayType.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/Type/Constant/ConstantArrayType.php b/src/Type/Constant/ConstantArrayType.php
index 1514781d0f..9a7e314d2c 100644
--- a/src/Type/Constant/ConstantArrayType.php
+++ b/src/Type/Constant/ConstantArrayType.php
@@ -483,6 +483,7 @@ public function getCallableParametersAcceptors(ClassMemberAccessAnswerer $scope)
 			}
 
 			$method = $typeAndMethodName->getType()
+				->getObjectTypeOrClassStringObjectType()
 				->getMethod($typeAndMethodName->getMethod(), $scope);
 
 			if (!$scope->canCallMethod($method)) {
@@ -567,7 +568,7 @@ public function findTypeAndMethodNames(): array
 				$has = $has->and(TrinaryLogic::createMaybe());
 			}
 
-			$typeAndMethods[] = ConstantArrayTypeAndMethod::createConcrete($type, $method->getValue(), $has);
+			$typeAndMethods[] = ConstantArrayTypeAndMethod::createConcrete($classOrObject, $method->getValue(), $has);
 		}
 
 		return $typeAndMethods;

From dd1184ab179b0d0d2bc3ff59256122a19e509027 Mon Sep 17 00:00:00 2001
From: Jan Nedbal <janedbal@gmail.com>
Date: Fri, 27 Dec 2024 16:35:25 +0100
Subject: [PATCH 2/2] Add test

---
 .../Type/Constant/ConstantArrayTypeTest.php   | 30 +++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php b/tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php
index b047b86a69..5697dee6b2 100644
--- a/tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php
+++ b/tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php
@@ -1051,4 +1051,34 @@ public function testValuesArray(ConstantArrayType $type, ConstantArrayType $expe
 		$this->assertSame($expectedType->getNextAutoIndexes(), $actualType->getNextAutoIndexes());
 	}
 
+	public function testFindTypeAndMethodNames(): void
+	{
+		$classStringArray = new ConstantArrayType([
+			new ConstantIntegerType(0),
+			new ConstantIntegerType(1),
+		], [
+			new ConstantStringType(Closure::class, true),
+			new ConstantStringType('bind'),
+		]);
+		$objectArray = new ConstantArrayType([
+			new ConstantIntegerType(0),
+			new ConstantIntegerType(1),
+		], [
+			new ObjectType(Closure::class, null, $this->createReflectionProvider()->getClass(Closure::class)),
+			new ConstantStringType('bind'),
+		]);
+
+		$classStringResult = $classStringArray->findTypeAndMethodNames();
+		$objectResult = $objectArray->findTypeAndMethodNames();
+
+		$this->assertCount(1, $classStringResult);
+		$this->assertCount(1, $objectResult);
+		$this->assertInstanceOf(ConstantStringType::class, $classStringResult[0]->getType());
+		$this->assertInstanceOf(ObjectType::class, $objectResult[0]->getType());
+		$this->assertSame('bind', $classStringResult[0]->getMethod());
+		$this->assertSame('bind', $objectResult[0]->getMethod());
+		$this->assertSame(TrinaryLogic::createYes(), $classStringResult[0]->getCertainty());
+		$this->assertSame(TrinaryLogic::createYes(), $objectResult[0]->getCertainty());
+	}
+
 }