mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
add test case reproducing issue #7428
This commit is contained in:
parent
9ed9c4b64c
commit
a2118c65d3
@ -2,6 +2,8 @@
|
||||
|
||||
namespace Psalm\Tests\TypeReconciliation;
|
||||
|
||||
use Psalm\Config;
|
||||
use Psalm\Context;
|
||||
use Psalm\Tests\TestCase;
|
||||
use Psalm\Tests\Traits\InvalidCodeAnalysisTestTrait;
|
||||
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
|
||||
@ -430,4 +432,31 @@ class ArrayKeyExistsTest extends TestCase
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function testAllowPropertyFetchAsNeedle(): void
|
||||
{
|
||||
Config::getInstance()->ensure_array_int_offsets_exist = true;
|
||||
|
||||
$this->addFile(
|
||||
'somefile.php',
|
||||
'<?php
|
||||
class Foo {
|
||||
/** @var self::STATE_* $status */
|
||||
public int $status = self::STATE_A;
|
||||
public const STATE_A = 0;
|
||||
public const STATE_B = 1;
|
||||
}
|
||||
|
||||
$foo = new Foo;
|
||||
|
||||
/** @var array<string> $bar */
|
||||
$bar = [];
|
||||
|
||||
if (array_key_exists($foo->status, $bar)) {
|
||||
echo $bar[$foo->status];
|
||||
}'
|
||||
);
|
||||
|
||||
$this->analyzeFile('somefile.php', new Context());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user