8000 [Security] Add type declarations to Security util by ro0NL · Pull Request #27944 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Security] Add type declarations to Security util #27944

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 7 additions & 18 deletions src/Symfony/Component/Security/Core/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
*/
final class Security
{
const ACCESS_DENIED_ERROR = '_security.403_error';
const AUTHENTICATION_ERROR = '_security.last_error';
const LAST_USERNAME = '_security.last_username';
const MAX_USERNAME_LENGTH = 4096;
public const ACCESS_DENIED_ERROR = '_security.403_error';
public const AUTHENTICATION_ERROR = '_security.last_error';
public const LAST_USERNAME = '_security.last_username';
public const MAX_USERNAME_LENGTH = 4096;

private $container;

Expand All @@ -32,10 +32,7 @@ public function __construct(ContainerInterface $container)
$this->container = $container;
}

/**
* @return UserInterface|null
*/
public function getUser()
public function getUser(): ?UserInterface
{
if (!$token = $this->getToken()) {
return null;
Expand All @@ -51,22 +48,14 @@ public function getUser()

/**
* Checks if the attributes are granted against the current authentication token and optionally supplied subject.
*
* @param mixed $attributes
* @param mixed $subject
*
* @return bool
*/
public function isGranted($attributes, $subject = null)
public function isGranted($attributes, $subject = null): bool
{
return $this->container->get('security.authorization_checker')
->isGranted($attributes, $subject);
}

/**
* @return TokenInterface|null
*/
public function getToken()
public function getToken(): ?TokenInterface
{
return $this->container->get('security.token_storage')->getToken();
}
Expand Down
0