Skip to content

Commit dd1184a

Browse files
committed
Add test
1 parent 0a004e8 commit dd1184a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/PHPStan/Type/Constant/ConstantArrayTypeTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -1051,4 +1051,34 @@ public function testValuesArray(ConstantArrayType $type, ConstantArrayType $expe
10511051
$this->assertSame($expectedType->getNextAutoIndexes(), $actualType->getNextAutoIndexes());
10521052
}
10531053

1054+
public function testFindTypeAndMethodNames(): void
1055+
{
1056+
$classStringArray = new ConstantArrayType([
1057+
new ConstantIntegerType(0),
1058+
new ConstantIntegerType(1),
1059+
], [
1060+
new ConstantStringType(Closure::class, true),
1061+
new ConstantStringType('bind'),
1062+
]);
1063+
$objectArray = new ConstantArrayType([
1064+
new ConstantIntegerType(0),
1065+
new ConstantIntegerType(1),
1066+
], [
1067+
new ObjectType(Closure::class, null, $this->createReflectionProvider()->getClass(Closure::class)),
1068+
new ConstantStringType('bind'),
1069+
]);
1070+
1071+
$classStringResult = $classStringArray->findTypeAndMethodNames();
1072+
$objectResult = $objectArray->findTypeAndMethodNames();
1073+
1074+
$this->assertCount(1, $classStringResult);
1075+
$this->assertCount(1, $objectResult);
1076+
$this->assertInstanceOf(ConstantStringType::class, $classStringResult[0]->getType());
1077+
$this->assertInstanceOf(ObjectType::class, $objectResult[0]->getType());
1078+
$this->assertSame('bind', $classStringResult[0]->getMethod());
1079+
$this->assertSame('bind', $objectResult[0]->getMethod());
1080+
$this->assertSame(TrinaryLogic::createYes(), $classStringResult[0]->getCertainty());
1081+
$this->assertSame(TrinaryLogic::createYes(), $objectResult[0]->getCertainty());
1082+
}
1083+
10541084
}

0 commit comments

Comments
 (0)