Skip to content

Commit

Permalink
Fix PHPStan issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
drupol committed May 27, 2020
1 parent ef92e50 commit c25b22d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
5 changes: 1 addition & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
parameters:
ignoreErrors:
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::arrayNode()#'
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface::scalarNode()#'
- '#Calling method scalarNode\(\) on possibly null value of type Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface#'
- '#Cannot call method scalarNode() on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null.#'
- '#Class EcPhp\\CasBundle\\Security\\CasGuardAuthenticator#'
7 changes: 6 additions & 1 deletion src/Controller/ProxyCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use EcPhp\CasLib\CasInterface;
use Symfony\Bridge\PsrHttpMessage\HttpFoundationFactoryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;

/**
* Class ProxyCallback.
Expand All @@ -21,6 +22,10 @@ final class ProxyCallback extends AbstractController
*/
public function __invoke(CasInterface $casProtocol, HttpFoundationFactoryInterface $httpFoundationFactory)
{
return $httpFoundationFactory->createResponse($casProtocol->handleProxyCallback());
if (null !== $response = $casProtocol->handleProxyCallback()) {
return $httpFoundationFactory->createResponse($response);
}

return new Response('', Response::HTTP_INTERNAL_SERVER_ERROR);
}
}
1 change: 1 addition & 0 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function getConfigTreeBuilder()
/** @var \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();

/** @phpstan-ignore-next-line */
$rootNode
->children()
->scalarNode('base_url')->defaultValue('')->end()
Expand Down
26 changes: 20 additions & 6 deletions src/Security/CasGuardAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio

return new RedirectResponse((string) $uri);
}

return null;
}

/**
Expand All @@ -158,10 +160,16 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
*/
public function onLogoutSuccess(Request $request)
{
$response = $this
->cas
->logout();

if (null === $response) {
throw new AuthenticationException('Unable to trigger the logout procedure');
}

return new RedirectResponse(
$this
->cas
->logout()
$response
->getHeaderLine('location')
);
}
Expand All @@ -178,10 +186,16 @@ public function start(Request $request, ?AuthenticationException $authException
);
}

$response = $this
->cas
->login();

if (null === $response) {
throw new AuthenticationException('Unable to trigger the login procedure');
}

return new RedirectResponse(
$this
->cas
->login()
$response
->getHeaderLine('location')
);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Security/Core/User/CasUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function getAttributes(): array
*/
public function getPassword()
{
return null;
}

/**
Expand All @@ -85,6 +86,7 @@ public function getRoles()
*/
public function getSalt()
{
return null;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Core/User/CasUserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface CasUserInterface extends UserInterface
* @param string $key
* @param mixed $default
*
* @return string|null
* @return mixed|null
*/
public function get(string $key, $default = null);

Expand Down

0 comments on commit c25b22d

Please sign in to comment.