-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9742 from fluffycondor/allow-phpdoc-dynamic-prope…
…rties Allow dynamic properties from PHPDoc
- Loading branch information
Showing
3 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
tests/Internal/Analyzer/Statements/Expression/Fetch/AtomicPropertyFetchAnalyzerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?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', | ||
], | ||
]; | ||
} | ||
} |