Skip to content

Commit

Permalink
Merge pull request #10734 from weirdan/override-attribute-in-pure-con…
Browse files Browse the repository at this point in the history
…text

Allow `Override` attribute to be used in pure contexts
  • Loading branch information
weirdan committed Feb 21, 2024
2 parents c401490 + 3cd9658 commit 2b64280
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions stubs/CoreGenericAttributes.phpstub
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down
17 changes: 17 additions & 0 deletions tests/OverrideTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,23 @@ public function f(): void;
'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',
],
];
}

Expand Down

0 comments on commit 2b64280

Please sign in to comment.