Skip to content

Commit

Permalink
fix tests I missed before + fix unrelated spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Jan 13, 2024
1 parent aaff4b8 commit 8d79b3c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
19 changes: 16 additions & 3 deletions tests/ArrayAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ function f(array $p): void
$x = $d[0];',
'assertions' => [
'$x===' => '"a"|null',
'$x===' => '\'a\'',
],
'ignored_issues' => ['PossiblyUndefinedArrayOffset'],
],
Expand Down Expand Up @@ -1349,15 +1349,15 @@ public function __toString() {
echo $a[new Foo];',
'error_message' => 'InvalidArrayOffset',
],
'possiblyUndefinedIntArrayOffet' => [
'possiblyUndefinedIntArrayOffset' => [
'code' => '<?php
/** @var array{0?:string} */
$entry = ["a"];
[$elt] = $entry;',
'error_message' => 'PossiblyUndefinedArrayOffset',
],
'possiblyUndefinedStringArrayOffet' => [
'possiblyUndefinedStringArrayOffset' => [
'code' => '<?php
/** @var array{a?:string} */
$entry = ["a"];
Expand Down Expand Up @@ -1542,6 +1542,19 @@ function takesArrayOfFloats(array $arr): void {
avg(["a" => 0.5, "b" => 1.5, "c" => new Exception()]);',
'error_message' => 'InvalidArgument',
],
'possiblyUndefinedArrayOffsetKeyedArray' => [
'code' => '<?php
$d = [];
if (!rand(0,1)) {
$d[0] = "a";
}
$x = $d[0];
// should not report TypeDoesNotContainNull
if ($x === null) {}',
'error_message' => 'PossiblyUndefinedArrayOffset',
],
];
}
}
4 changes: 2 additions & 2 deletions tests/PropertyTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function getX() : ?int {
}
function testX(X $x): void {
if (is_int($x->getX())) {
if ($x->getX() !== null) {
XCollector::modify();
if ($x->getX() === null) {}
}
Expand Down Expand Up @@ -255,7 +255,7 @@ public function __construct(?int $x) {
}
function testX(X $x): void {
if (is_int($x->x)) {
if ($x->x !== null) {
XCollector::modify();
if ($x->x === null) {}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Template/ClassTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2878,6 +2878,8 @@ private static function test(
): void {
}
}',
'assertions' => [],
'ignored_issues' => ['RiskyTruthyFalsyComparison'],
],
'noCrashTemplateInsideGenerator' => [
'code' => '<?php
Expand Down
4 changes: 4 additions & 0 deletions tests/TypeReconciliation/EmptyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ function foo(array $args): void {
foreach ($arr as $item) {
if (empty($item["hide"]) || $item["hide"] === 3) {}
}',
'assertions' => [],
'ignored_issues' => ['RiskyTruthyFalsyComparison'],
],
'alwaysBoolResult' => [
'code' => '<?php
Expand Down Expand Up @@ -391,6 +393,8 @@ function createFromString(array $arr): void
echo $arr["a"];
}',
'assertions' => [],
'ignored_issues' => ['RiskyTruthyFalsyComparison'],
],
'reconcileEmptyTwiceWithoutReturn' => [
'code' => '<?php
Expand Down
4 changes: 4 additions & 0 deletions tests/TypeReconciliation/TypeAlgebraTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ function foo(?string $a, ?string $b): string {
if (!$a) return $b;
return $a;
}',
'assertions' => [],
'ignored_issues' => ['RiskyTruthyFalsyComparison'],
],
'invertedTwoVarLogicNotNestedWithAssignmentBeforeReturn' => [
'code' => '<?php
Expand Down Expand Up @@ -1363,6 +1365,7 @@ function foo(?string $a, ?string $b, ?string $c): string {
return $a;
}',
'error_message' => 'TypeDoesNotContainType',
'ignored_issues' => ['RiskyTruthyFalsyComparison'],
],
'twoVarLogicNotNestedWithElseifIncorrectlyReinforcedInIf' => [
'code' => '<?php
Expand Down Expand Up @@ -1394,6 +1397,7 @@ function foo(?string $a) {
}
}',
'error_message' => 'TypeDoesNotContainType',
'ignored_issues' => ['RiskyTruthyFalsyComparison'],
],
'repeatedConditionals' => [
'code' => '<?php
Expand Down

0 comments on commit 8d79b3c

Please sign in to comment.