Skip to content

Commit

Permalink
Allow Override attribute to be used in pure contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
weirdan committed Feb 21, 2024
1 parent c401490 commit 3cd9658
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 3cd9658

Please sign in to comment.