Skip to content

Commit 9b5bf8a

Browse files
committed
Remove deprecations, fix code merged from 1.5
1 parent 352f3b1 commit 9b5bf8a

File tree

4 files changed

+16
-26
lines changed

4 files changed

+16
-26
lines changed

Command/CreateClientCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the FOSOAuthServerBundle package.
57
*
@@ -11,11 +13,11 @@
1113

1214
namespace FOS\OAuthServerBundle\Command;
1315

14-
use Symfony\Component\Console\Input\InputOption;
15-
use Symfony\Component\Console\Style\SymfonyStyle;
16+
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
1617
use Symfony\Component\Console\Input\InputInterface;
18+
use Symfony\Component\Console\Input\InputOption;
1719
use Symfony\Component\Console\Output\OutputInterface;
18-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
20+
use Symfony\Component\Console\Style\SymfonyStyle;
1921

2022
class CreateClientCommand extends ContainerAwareCommand
2123
{

Form/Handler/AuthorizeFormHandler.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ public function __construct(FormInterface $form, $requestStack = null)
5353
$this->requestStack = $requestStack;
5454
}
5555

56-
public function __get($name)
57-
{
58-
if ($name === 'request') {
59-
@trigger_error(sprintf('%s::$request is deprecated since 1.4 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
60-
61-
return $this->getCurrentRequest();
62-
}
63-
}
64-
6556
/**
6657
* Sets the container.
6758
*

Security/Firewall/OAuthListener.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class OAuthListener implements ListenerInterface
3333
/**
3434
* @var TokenStorageInterface
3535
*/
36-
protected $securityContext;
36+
protected $tokenStorage;
3737

3838
/**
3939
* @var AuthenticationManagerInterface
@@ -49,17 +49,10 @@ class OAuthListener implements ListenerInterface
4949
* @param TokenStorageInterface $tokenStorage the token storage
5050
* @param AuthenticationManagerInterface $authenticationManager the authentication manager
5151
* @param OAuth2 $serverService
52-
* @param mixed $securityContext
5352
*/
54-
public function __construct($securityContext, AuthenticationManagerInterface $authenticationManager, OAuth2 $serverService)
53+
public function __construct(TokenStorageInterface $tokenStorage, AuthenticationManagerInterface $authenticationManager, OAuth2 $serverService)
5554
{
56-
if (!$securityContext instanceof TokenStorageInterface) {
57-
throw new \InvalidArgumentException('Wrong type for OAuthListener, it has to implement TokenStorageInterface');
58-
}
59-
if ($securityContext instanceof SecurityContextInterface) {
60-
@trigger_error(sprintf('Injecting SecurityContextInterface into %1$s::__construct is deprecated since 1.6 and will be removed in 2.0.', __CLASS__), E_USER_DEPRECATED);
61-
}
62-
$this->securityContext = $securityContext;
55+
$this->tokenStorage = $tokenStorage;
6356
$this->authenticationManager = $authenticationManager;
6457
$this->serverService = $serverService;
6558
}
@@ -80,7 +73,7 @@ public function handle(GetResponseEvent $event)
8073
$returnValue = $this->authenticationManager->authenticate($token);
8174

8275
if ($returnValue instanceof TokenInterface) {
83-
return $this->securityContext->setToken($returnValue);
76+
return $this->tokenStorage->setToken($returnValue);
8477
}
8578

8679
if ($returnValue instanceof Response) {

Tests/Command/CreateClientCommandTest.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/*
46
* This file is part of the FOSOAuthServerBundle package.
57
*
@@ -48,7 +50,9 @@ protected function setUp()
4850
/**
4951
* @dataProvider classProvider
5052
*
51-
* @param string $class A fully qualified class name.
53+
* @param string $class a fully qualified class name
54+
* @param mixed $clientManager
55+
* @param mixed $client
5256
*/
5357
public function testItShouldCreateClient($clientManager, $client)
5458
{
@@ -60,7 +64,7 @@ public function testItShouldCreateClient($clientManager, $client)
6064
$clientManager
6165
->expects($this->any())
6266
->method('createClient')
63-
->will($this->returnValue(new $client));
67+
->will($this->returnValue(new $client()));
6468

6569
$this->container->set('fos_oauth_server.client_manager.default', $clientManager);
6670

@@ -78,7 +82,7 @@ public function testItShouldCreateClient($clientManager, $client)
7882
],
7983
]);
8084

81-
$this->assertEquals(0, $commandTester->getStatusCode());
85+
$this->assertSame(0, $commandTester->getStatusCode());
8286

8387
$output = $commandTester->getDisplay();
8488

0 commit comments

Comments
 (0)