for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Doctrine;
use App\Entity\Message;
use App\Event\MessageCreatedEvent;
use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Events;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* This listener listens for new messages being created and
* dispatches an event into the EventDispatcher
*/
class MessagePersistSubscriber implements EventSubscriber {
public function __construct(private EventDispatcherInterface $dispatcher)
{
}
public function postPersist(LifecycleEventArgs $eventArgs) {
$entity = $eventArgs->getEntity();
Doctrine\ORM\Event\LifecycleEventArgs::getEntity()
If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated annotation
ignore-deprecated
$entity = /** @scrutinizer ignore-deprecated */ $eventArgs->getEntity();
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.
if($entity instanceof Message) {
$this->dispatcher->dispatch(new MessageCreatedEvent($entity));
* @inheritDoc
public function getSubscribedEvents(): array {
return [
Events::postPersist
];
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.