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
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,11 @@ public function testBug12605(): void
]);
}

public function testBug4809(): void
{
$this->analyse([__DIR__ . '/data/bug-4809.php'], []);
}

public function testBug11602(): void
{
$this->reportPossiblyNonexistentGeneralArrayOffset = true;
Expand Down
27 changes: 27 additions & 0 deletions tests/PHPStan/Rules/Arrays/data/bug-4809.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php declare(strict_types = 1);

namespace Bug4809;

class SomeClass
{
/**
* @param array{
* some?: string,
* another?: string,
* } $data
* @param string $key
* @return void
*/
public function someFunction(array $data, string $key): void
{
if($key !== 'some' && $key !== 'another') {
return;
}

if(!array_key_exists($key, $data)) {
return;
}

var_dump($data[$key]);
}
}
Loading