for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PiedWeb\CMSBundle\EventListener;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use PiedWeb\CMSBundle\Entity\UserInterface;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class UserListener
{
protected $passwordEncoder;
public function __construct(UserPasswordEncoderInterface $passwordEncoder)
$this->passwordEncoder = $passwordEncoder;
}
/**
* Set Password on database update if PlainPassword is set.
*/
public function preUpdate(UserInterface $user, PreUpdateEventArgs $event)
$event
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function preUpdate(UserInterface $user, /** @scrutinizer ignore-unused */ PreUpdateEventArgs $event)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
if (\strlen($user->getPlainPassword()) > 0) {
$user->setPassword($this->passwordEncoder->encodePassword($user, $user->getPlainPassword()));
$user->eraseCredentials();
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.