Skip to content

Commit

Permalink
bug #554 Fix deprecations on Symfony 4.2 (chalasr)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.x-dev branch.

Discussion
----------

Fix deprecations on Symfony 4.2

Commits
-------

6dd3e1c Fix deprecations on Symfony 4.2
  • Loading branch information
chalasr committed Oct 1, 2018
2 parents 35296fc + 6dd3e1c commit 63ae9f3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 55 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ matrix:
group: edge
allow_failures:
- php: hhvm-stable
- php: 7.2

cache:
directories:
Expand Down
9 changes: 4 additions & 5 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('lexik_jwt_authentication');
$treeBuilder = new TreeBuilder('lexik_jwt_authentication');
$rootNode = \method_exists(TreeBuilder::class, 'getRootNode') ? $treeBuilder->getRootNode() : $treeBuilder->root('lexik_jwt_authentication');

$rootNode
->addDefaultsIfNotSet()
Expand Down Expand Up @@ -82,9 +82,8 @@ public function getConfigTreeBuilder()

private function getTokenExtractorsNode()
{
$builder = new TreeBuilder();
$node = $builder->root('token_extractors');

$builder = new TreeBuilder('token_extractors');
$node = \method_exists(TreeBuilder::class, 'getRootNode') ? $builder->getRootNode() : $builder->root('token_extractors');
$node
->addDefaultsIfNotSet()
->children()
Expand Down
14 changes: 8 additions & 6 deletions Tests/Functional/Bundle/Controller/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

namespace Lexik\Bundle\JWTAuthenticationBundle\Tests\Functional\Bundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Lexik\Bundle\JWTAuthenticationBundle\Tests\Stubs\User;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\User\UserInterface;

class TestController extends Controller
class TestController
{
public function securedAction()
public function securedAction(UserInterface $user)
{
return new JsonResponse([
'class' => get_class($this->getUser()),
'roles' => $this->getUser()->getRoles(),
'username' => $this->getUser()->getUsername(),
'class' => get_class($user),
'roles' => $user->getRoles(),
'username' => $user->getUsername(),
]);
}
}
5 changes: 5 additions & 0 deletions Tests/Functional/app/config/base_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ services:
class: Lexik\Bundle\JWTAuthenticationBundle\Encoder\LcobucciJWTEncoder
arguments: ['@lexik_jwt_authentication.jws_provider.lcobucci']
public: true


Lexik\Bundle\JWTAuthenticationBundle\Tests\Functional\Bundle\Controller\TestController:
arguments: ['@security.token_storage']
public: true
46 changes: 3 additions & 43 deletions Tests/Stubs/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Lexik\Bundle\JWTAuthenticationBundle\Tests\Stubs;

use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* User is the user implementation used by the in-memory user provider.
Expand All @@ -20,29 +20,21 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
final class User implements AdvancedUserInterface
final class User implements UserInterface
{
private $username;
private $password;
private $enabled;
private $accountNonExpired;
private $credentialsNonExpired;
private $accountNonLocked;
private $roles;
private $email;

public function __construct($username, $password, $email = '', array $roles = [], $enabled = true, $userNonExpired = true, $credentialsNonExpired = true, $userNonLocked = true)
public function __construct($username, $password, $email = '', array $roles = [])
{
if (empty($username)) {
throw new \InvalidArgumentException('The username cannot be empty.');
}

$this->username = $username;
$this->password = $password;
$this->enabled = $enabled;
$this->accountNonExpired = $userNonExpired;
$this->credentialsNonExpired = $credentialsNonExpired;
$this->accountNonLocked = $userNonLocked;
$this->roles = $roles;
$this->email = $email;
}
Expand Down Expand Up @@ -78,38 +70,6 @@ public function getUsername()
return $this->username;
}

/**
* {@inheritdoc}
*/
public function isAccountNonExpired()
{
return $this->accountNonExpired;
}

/**
* {@inheritdoc}
*/
public function isAccountNonLocked()
{
return $this->accountNonLocked;
}

/**
* {@inheritdoc}
*/
public function isCredentialsNonExpired()
{
return $this->credentialsNonExpired;
}

/**
* {@inheritdoc}
*/
public function isEnabled()
{
return $this->enabled;
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 63ae9f3

Please sign in to comment.