Skip to content
New issue

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

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

Already on GitHub? # to your account

Child function inheriting deprecated state? #70

Closed
mmarton opened this issue May 10, 2022 · 2 comments
Closed

Child function inheriting deprecated state? #70

mmarton opened this issue May 10, 2022 · 2 comments

Comments

@mmarton
Copy link

mmarton commented May 10, 2022

Hi!

this is a bug report/question.

In doctrine persistence LifecycleEventArgs class as parentclass and doctrine orm LifecycleEventArgs as child class

the method getEntity is deprecated and will be removed in parentclass:
https://github.com/doctrine/persistence/blob/2.5.x/src/Persistence/Event/LifecycleEventArgs.php#L39

but overwritten and not deprecated and will be kept in child class:
https://github.com/doctrine/orm/blob/2.12.x/lib/Doctrine/ORM/Event/LifecycleEventArgs.php#L23

When I use phpstan with deprecation rules on my class

<?php

declare(strict_types=1);

namespace App\EventSubscriber;

use Doctrine\Bundle\DoctrineBundle\EventSubscriber\EventSubscriberInterface;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Events;

class MySubscriber implements EventSubscriberInterface
{
    public function getSubscribedEvents(): array
    {
        return [Events::postPersist];
    }

    public function postPersist(LifecycleEventArgs $args): void
    {
        $entity = $args->getEntity();
        // ...
    }
}

I got the error message:

Call to deprecated method getEntity() of class Doctrine\ORM\Event\LifecycleEventArgs.

Looks like the detprecated state is inherited. Is it a bug, or is it expected?

@ondrejmirtes
Copy link
Member

This is expected behaviour. See: #48, phpstan/phpstan-src#792, #50

@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 Jun 13, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants