Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/PHPStan/Analyser/AnalyserIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ public function testBug9994(): void
$this->assertSame('Parameter #2 $callback of function array_filter expects (callable(1|2|3|null): bool)|null, false given.', $errors[1]->getMessage());
}

#[RequiresPhp('>= 8.1')]
public function testBug13987(): void
{
$errors = $this->runAnalyse(__DIR__ . '/data/bug-13987.php');
Expand Down
2 changes: 1 addition & 1 deletion tests/PHPStan/Analyser/data/bug-13987.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php // lint >= 8.1

namespace Bug13987;

Expand Down
10 changes: 10 additions & 0 deletions tests/PHPStan/Rules/Variables/DefinedVariableRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1180,4 +1180,14 @@ public function testBug13353(): void
$this->analyse([__DIR__ . '/data/bug-13353.php'], []);
}

public function testBug13694(): void
{
$this->cliArgumentsVariablesRegistered = true;
$this->polluteScopeWithLoopInitialAssignments = true;
$this->checkMaybeUndefinedVariables = true;
$this->polluteScopeWithAlwaysIterableForeach = true;

$this->analyse([__DIR__ . '/data/bug-13694.php'], []);
}

}
21 changes: 21 additions & 0 deletions tests/PHPStan/Rules/Variables/data/bug-13694.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Bug13694;

/**
* @param int[] $keys
* @param array<int, int|null> $things
*/
function evaluateThings(array $keys, array $things): void
{
foreach ($keys as $key) {
if (array_key_exists($key, $things) && $things[$key] === null) {
echo "Value for key $key is null\n";
continue;
}

if (isset($things[$key])) {
echo "Key $key is set\n";
}
}
}
Loading