Fix phpstan issues

This commit is contained in:
2023-12-12 22:34:26 +01:00
parent af663cf27c
commit da997badd9
26 changed files with 275 additions and 261 deletions

View File

@@ -31,31 +31,21 @@ namespace Chill\PersonBundle\Privacy;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
class PrivacyEventSubscriber implements EventSubscriberInterface
final readonly class PrivacyEventSubscriber implements EventSubscriberInterface
{
/**
* @var LoggerInterface
*/
protected $logger;
/**
* @var TokenStorageInterface
*/
protected $token;
/**
* PrivacyEventSubscriber constructor.
*/
public function __construct(LoggerInterface $logger, TokenStorageInterface $token)
{
$this->logger = $logger;
$this->token = $token;
}
public function __construct(
private LoggerInterface $logger,
private TokenStorageInterface $token
) {}
public static function getSubscribedEvents()
{
@@ -109,11 +99,20 @@ class PrivacyEventSubscriber implements EventSubscriberInterface
);
}
protected function getInvolved(): array
private function getInvolved(): array
{
$user = $this->token->getToken()->getUser();
if ($user instanceof User) {
return [
'by_user' => $user->getUserIdentifier(),
'by_user_id' => $user->getId(),
];
}
return [
'by_user' => $this->token->getToken()->getUser()->getUsername(),
'by_user_id' => $this->token->getToken()->getUser()->getId(),
'by_user' => $user->getUsername(),
'by_user_id' => $user->getUserIdentifier(),
];
}
}