Skip to content

Commit 9759075

Browse files
phpstan-botclaude
andcommitted
Improve IntersectionTypeTest comments and fix hasOffsetValue test case
- Make test comments more descriptive by including the accepting type details - Fix last hasOffsetValue failure test to use offset 0 (matching the constant array's offsets) so it properly tests type incompatibility, and update expected result to No since int at offset 0 conflicts with string Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3b83616 commit 9759075

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

tests/PHPStan/Type/IntersectionTypeTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ public static function dataIsAcceptedBy(): Iterator
121121
TrinaryLogic::createYes(),
122122
];
123123

124-
// array&callable isAcceptedBy array - failure
124+
// array&callable isAcceptedBy array<int> - failure
125125
yield [
126126
new IntersectionType([new ArrayType(new MixedType(), new MixedType()), new CallableType()]),
127127
new ArrayType(new MixedType(), new IntegerType()),
128128
TrinaryLogic::createNo(),
129129
];
130130

131-
// array&callable isAcceptedBy constantArray - success
131+
// array&callable isAcceptedBy constantArray{stdClass, string} - maybe
132132
yield [
133133
new IntersectionType([new ArrayType(new MixedType(), new MixedType()), new CallableType()]),
134134
new ConstantArrayType(
@@ -138,7 +138,7 @@ public static function dataIsAcceptedBy(): Iterator
138138
TrinaryLogic::createMaybe(),
139139
];
140140

141-
// array&callable isAcceptedBy constantArray - failure
141+
// array&callable isAcceptedBy constantArray{string, string} - maybe
142142
yield [
143143
new IntersectionType([new ArrayType(new MixedType(), new MixedType()), new CallableType()]),
144144
new ConstantArrayType(
@@ -170,7 +170,7 @@ public static function dataIsAcceptedBy(): Iterator
170170
TrinaryLogic::createNo(),
171171
];
172172

173-
// array&hasOffsetValue isAcceptedBy array - success (matching value type)
173+
// array&hasOffsetValue isAcceptedBy array<int> - success (matching value type)
174174
yield [
175175
new IntersectionType([
176176
new ArrayType(new MixedType(), new MixedType()),
@@ -181,7 +181,7 @@ public static function dataIsAcceptedBy(): Iterator
181181
TrinaryLogic::createYes(),
182182
];
183183

184-
// array&hasOffsetValue isAcceptedBy constantArray - success
184+
// array&hasOffsetValue isAcceptedBy constantArray{int, int} - success
185185
yield [
186186
new IntersectionType([
187187
new ArrayType(new MixedType(), new MixedType()),
@@ -195,18 +195,18 @@ public static function dataIsAcceptedBy(): Iterator
195195
TrinaryLogic::createMaybe(),
196196
];
197197

198-
// array&hasOffsetValue isAcceptedBy constantArray - failure
198+
// array&hasOffsetValue isAcceptedBy constantArray{string, string} - failure
199199
yield [
200200
new IntersectionType([
201201
new ArrayType(new MixedType(), new MixedType()),
202202
new NonEmptyArrayType(),
203-
new HasOffsetValueType(new ConstantIntegerType(3), new IntegerType()),
203+
new HasOffsetValueType(new ConstantIntegerType(0), new IntegerType()),
204204
]),
205205
new ConstantArrayType(
206206
[new ConstantIntegerType(0), new ConstantIntegerType(1)],
207207
[new StringType(), new StringType()],
208208
),
209-
TrinaryLogic::createMaybe(),
209+
TrinaryLogic::createNo(),
210210
];
211211
}
212212

0 commit comments

Comments
 (0)