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

Detecting deprecated methods from an interface #48

Closed
eiriksm opened this issue Nov 19, 2021 · 2 comments
Closed

Detecting deprecated methods from an interface #48

eiriksm opened this issue Nov 19, 2021 · 2 comments

Comments

@eiriksm
Copy link
Contributor

eiriksm commented Nov 19, 2021

Hi there. First of all. Thanks so much for this, it has been so helpful in our projects.

I encountered an issue today that surprised me. If you are calling a class method that is deprecated on the interface level, phpstan does not complain. It surprised me only because my IDE shows me this, and I never thought about checking if this was detected in phpstan as well.

Here is a minimal example:

<?php

class Foo implements FooInterface
{
    /**
     * {@inheritdoc}
     */
    public function createBar() {}
}

interface FooInterface
{
    /**
     * @deprecated Don't use this plz.
     */
    public function createBar();
}


$var = new Foo();
$var->createBar(); // I expect this to be an error, but it's not.

/** @var \FooInterface $var */
$var = $var;
$var->createBar(); // I also expect this to be an error, and it is.

Attached also a picture of my IDE where this is clearly identified. Not that I am saying phpstan and Phpstorm should obviously have the same feature set, just for completion on this issue report :)

Screenshot from 2021-11-19 11-31-39

Here is also the phpstan.neon file:

parameters:
    level: 1
includes:
    - vendor/phpstan/phpstan-deprecation-rules/rules.neon

Using phpstan/phpstan 1.2.0 and phpstan/phpstan-deprecation-rules 1.0.0

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src#792

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants