1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-11 16:59:45 +01:00
psalm/tests/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzerTest.php
2023-05-04 18:49:41 +02:00

76 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace Psalm\Tests\Internal\Analyzer\Statements\Expression\Fetch;
use Psalm\Tests\TestCase;
use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;
final class AtomicPropertyFetchAnalyzerTest extends TestCase
{
use ValidCodeAnalysisTestTrait;
public function providerValidCodeParse(): iterable
{
return [
'allowDynamicProperties' => [
'code' => '<?php
/** @property-read string $foo */
#[\AllowDynamicProperties]
class A {
public function __construct(string $key, string $value)
{
$this->$key = $value;
}
}
echo (new A("foo", "bar"))->foo;
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.2',
],
'allowDynamicProperties for child' => [
'code' => '<?php
/** @property-read string $foo */
#[\AllowDynamicProperties]
class A {
public function __construct(string $key, string $value)
{
$this->$key = $value;
}
}
class B extends A {}
echo (new B("foo", "bar"))->foo;
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.2',
],
'allowDynamicProperties for grandchild' => [
'code' => '<?php
/** @property-read string $foo */
#[\AllowDynamicProperties]
class A {
public function __construct(string $key, string $value)
{
$this->$key = $value;
}
}
class B extends A {}
class C extends B {}
echo (new C("foo", "bar"))->foo;
',
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.2',
],
];
}
}