Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report usage of depreacted properties #6118

Closed
bdsl opened this issue Jul 16, 2021 · 4 comments · Fixed by #6127
Closed

Report usage of depreacted properties #6118

bdsl opened this issue Jul 16, 2021 · 4 comments · Fixed by #6127
Labels

Comments

@bdsl
Copy link
Contributor

bdsl commented Jul 16, 2021

In a large class or a class with widely used public properties it may be difficult to immediately delete an unwanted property, and preferable to deprecate it.

I would like Psalm to report usages of deprecated properties, as at

https://psalm.dev/r/34c8584df8

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/34c8584df8
<?php

class Foo
{
    /**
      * @deprecated
      * @var int
      */
    private $bar = 0;
    
    public function bar(): int
    {
        return $this->bar;
    }
      
}
Psalm output (using commit f015c30):

No issues!

@weirdan
Copy link
Collaborator

weirdan commented Jul 16, 2021

Actually Psalm reports deprecated properties when they are accessed from outside of the class. I don't see a reason why we shouldn't report when accessed from the class scope.

@weirdan weirdan added bug and removed enhancement labels Jul 16, 2021
@weirdan
Copy link
Collaborator

weirdan commented Jul 16, 2021

Moreover, we already report property writes: https://psalm.dev/r/66aa00201a

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/66aa00201a
<?php

class Foo
{
    /**
      * @deprecated
      * @var int
      */
    public $bar = 0;
    
    public function bar(int $p): void
    {
        $this->bar = $p;
    }
      
}
Psalm output (using commit f015c30):

ERROR: DeprecatedProperty - 13:9 - Foo::$bar is marked deprecated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants