Skip to content

Commit

Permalink
Fixed PHPStan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Nov 29, 2017
1 parent 08d6baa commit 737f429
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
25 changes: 20 additions & 5 deletions src/Controller/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;

final class AuthController extends Controller
{
const SESSION_LASTFM_NAME = '_CORE23_LASTFM_NAME';
const SESSION_LASTFM_TOKEN = '_CORE23_LASTFM_TOKEN';
public const SESSION_LASTFM_NAME = '_CORE23_LASTFM_NAME';
public const SESSION_LASTFM_TOKEN = '_CORE23_LASTFM_TOKEN';

/**
* @return Response
Expand Down Expand Up @@ -46,7 +48,12 @@ public function checkAction(Request $request): Response
// Store session
$lastFmSession = $this->getAuthService()->createSession($token);

$session = $this->get('session');
if (null === $lastFmSession) {
return $this->redirectToRoute('core23_lastfm_error');
}

/** @var Session $session */
$session = $this->getSession();
$session->set(static::SESSION_LASTFM_NAME, $lastFmSession->getName());
$session->set(static::SESSION_LASTFM_TOKEN, $lastFmSession->getKey());

Expand Down Expand Up @@ -82,7 +89,7 @@ public function successAction(): Response
return $this->redirectToRoute($this->getParameter('core23.lastfm.auth_success.redirect_route'), $this->getParameter('core23.lastfm.auth_success.redirect_route_params'));
}

$session = $this->get('session');
$session = $this->getSession();

return $this->render('Core23LastFmBundle:Auth:success.html.twig', array(
'name' => $session->get(static::SESSION_LASTFM_NAME),
Expand All @@ -96,7 +103,7 @@ public function successAction(): Response
*/
private function isAuthenticated(): bool
{
return (bool) $this->get('session')->get(static::SESSION_LASTFM_TOKEN);
return (bool) $this->getSession()->get(static::SESSION_LASTFM_TOKEN);
}

/**
Expand All @@ -106,4 +113,12 @@ private function getAuthService(): AuthService
{
return $this->get('core23.lastfm.service.auth');
}

/**
* @return SessionInterface
*/
private function getSession() : SessionInterface
{
return $this->get('session');
}
}
4 changes: 3 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ final class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$node = $treeBuilder->root('core23_last_fm');

/** @var ArrayNodeDefinition $node */
$node = $treeBuilder->root('core23_last_fm');

$this->addRoutingSection($node);
$this->addApiSection($node);
Expand Down

0 comments on commit 737f429

Please sign in to comment.