Skip to content

Child function inheriting deprecated state? #70

Description

@mmarton

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions