1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Merge pull request #10734 from weirdan/override-attribute-in-pure-context

Allow `Override` attribute to be used in pure contexts
This commit is contained in:
Bruce Weirdan 2024-02-21 15:55:32 -04:00 committed by GitHub
commit 2b642804b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View File

@ -1,17 +1,20 @@
<?php
/** @psalm-immutable */
#[Attribute(Attribute::TARGET_CLASS)]
final class AllowDynamicProperties
{
public function __construct() {}
}
/** @psalm-immutable */
#[Attribute(Attribute::TARGET_METHOD)]
final class Override
{
public function __construct() {}
}
/** @psalm-immutable */
#[Attribute(Attribute::TARGET_PARAMETER)]
final class SensitiveParameter
{

View File

@ -68,6 +68,23 @@ class OverrideTest extends TestCase
'ignored_issues' => [],
'php_version' => '8.3',
],
'canBeUsedOnPureMethods' => [
'code' => <<<'PHP'
<?php
class A {
/** @psalm-pure */
public function f(): void {}
}
class B extends A {
/** @psalm-pure */
#[Override]
public function f(): void {}
}
PHP,
'assertions' => [],
'ignored_issues' => [],
'php_version' => '8.3',
],
];
}