Provide an interface for BaseLifecycleEventArgs childs #7130

Closed
opened 2026-01-22 15:45:18 +01:00 by admin · 2 comments
Owner

Originally created by @tebaly on GitHub (Apr 5, 2023).

https://github.com/doctrine/orm/blame/2.14.x/UPGRADE.md#L61

BC Break Report

BaseLifecycleEventArgs

Q A
BC Break yes
Version 2.14.1

Summary

Hello. Please provide an interface


    public function getSubscribedEvents(): array
    {
        return [
            Events::prePersist,
            Events::preUpdate,
        ];
    }

    public function preUpdate(PreUpdateEventArgs $args): void # <-- PreUpdateEventArgs
    {
        $this->index($args, false); # <--
    }

    public function prePersist(PrePersistEventArgs $args): void # <-- PrePersistEventArgs
    {
        $this->index($args, true); # <--
    }

    public function index($args, $skipOverwriteInitial): void # <-- [????????] $args ?
    {
        $entity = $args->getObject();
        if (!$entity) {
            return;
        }
        $this->entityDateUpdater->updateFields($entity, $skipOverwriteInitial);
    }

Previously all types were LifecycleEventArgs

Right now I can't determine the type for $args in index method :(

Originally created by @tebaly on GitHub (Apr 5, 2023). https://github.com/doctrine/orm/blame/2.14.x/UPGRADE.md#L61 ### BC Break Report BaseLifecycleEventArgs <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 2.14.1 #### Summary Hello. Please provide an interface ```php public function getSubscribedEvents(): array { return [ Events::prePersist, Events::preUpdate, ]; } public function preUpdate(PreUpdateEventArgs $args): void # <-- PreUpdateEventArgs { $this->index($args, false); # <-- } public function prePersist(PrePersistEventArgs $args): void # <-- PrePersistEventArgs { $this->index($args, true); # <-- } public function index($args, $skipOverwriteInitial): void # <-- [????????] $args ? { $entity = $args->getObject(); if (!$entity) { return; } $this->entityDateUpdater->updateFields($entity, $skipOverwriteInitial); } ``` ### Previously all types were LifecycleEventArgs Right now I can't determine the type for `$args` in `index` method :(
admin added the Question label 2026-01-22 15:45:18 +01:00
admin closed this issue 2026-01-22 15:45:20 +01:00
Author
Owner

@derrabus commented on GitHub (Apr 5, 2023):

BC Break Report

For a deprecation that you don't agree with? Seriously?

Right now I can't determine the type for $args in index method :(

It's PreUpdateEventArgs | PrePersistEventArgs.

@derrabus commented on GitHub (Apr 5, 2023): > BC Break Report For a deprecation that you don't agree with? Seriously? > Right now I can't determine the type for `$args` in `index` method :( It's `PreUpdateEventArgs | PrePersistEventArgs`.
Author
Owner

@tebaly commented on GitHub (Apr 5, 2023):

It's PreUpdateEventArgs | PrePersistEventArgs.

Let's have the full version of your beautiful code

public function index(PrePersistEventArgs | PreUpdateEventArgs | PreRemoveEventArgs | PostPersistEventArgs | PostUpdateEventArgs | PostRemoveEventArgs | PostLoadEventArgs $args, $skipOverwriteInitial): void

Seriously?

@tebaly commented on GitHub (Apr 5, 2023): > It's `PreUpdateEventArgs | PrePersistEventArgs`. Let's have the full version of your beautiful code ```php public function index(PrePersistEventArgs | PreUpdateEventArgs | PreRemoveEventArgs | PostPersistEventArgs | PostUpdateEventArgs | PostRemoveEventArgs | PostLoadEventArgs $args, $skipOverwriteInitial): void ``` # Seriously?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#7130