Skip to content

Commit 0ab6462

Browse files
committed
minor #4 Fixed CS (chalasr)
This PR was merged into the 0.1-dev branch. Discussion ---------- Fixed CS No global imports. Commits ------- e4f7756 Fixed CS
2 parents 920e408 + e4f7756 commit 0ab6462

34 files changed

+91
-130
lines changed

.php_cs.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ return PhpCsFixer\Config::create()
2222
'concat_space' => ['spacing' => 'one'],
2323
'declare_strict_types' => true,
2424
'heredoc_to_nowdoc' => true,
25+
'global_namespace_import' => [
26+
'import_classes' => false,
27+
'import_constants' => false,
28+
'import_functions' => false,
29+
],
2530
'list_syntax' => ['syntax' => 'short'],
2631
'no_null_property_initialization' => true,
2732
'no_superfluous_phpdoc_tags' => true,

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ before_script:
2222

2323
script:
2424
- stty cols 120
25-
- if [ "$CHECK_CS" == 1 ]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.15.8/php-cs-fixer.phar && php php-cs-fixer.phar fix --dry-run --diff; fi
25+
- if [ "$CHECK_CS" == 1 ]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.16.7/php-cs-fixer.phar && php php-cs-fixer.phar fix --dry-run --diff; fi
2626
- vendor/bin/simple-phpunit

src/Command/CreateClientCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace League\Bundle\OAuth2ServerBundle\Command;
66

7-
use InvalidArgumentException;
87
use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface;
98
use League\Bundle\OAuth2ServerBundle\Model\Client;
109
use League\Bundle\OAuth2ServerBundle\Model\Grant;
@@ -86,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8685

8786
try {
8887
$client = $this->buildClientFromInput($input);
89-
} catch (InvalidArgumentException $exception) {
88+
} catch (\InvalidArgumentException $exception) {
9089
$io->error($exception->getMessage());
9190

9291
return 1;
@@ -111,7 +110,7 @@ private function buildClientFromInput(InputInterface $input): Client
111110
$isPublic = $input->getOption('public');
112111

113112
if (null !== $input->getArgument('secret') && $isPublic) {
114-
throw new InvalidArgumentException('The client cannot have a secret and be public.');
113+
throw new \InvalidArgumentException('The client cannot have a secret and be public.');
115114
}
116115

117116
$secret = $isPublic ? null : $input->getArgument('secret') ?? hash('sha512', random_bytes(32));

src/DBAL/Type/ImplodedArray.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
use Doctrine\DBAL\Platforms\AbstractPlatform;
88
use Doctrine\DBAL\Types\TextType;
9-
use InvalidArgumentException;
10-
use LogicException;
119

1210
abstract class ImplodedArray extends TextType
1311
{
@@ -22,7 +20,7 @@ abstract class ImplodedArray extends TextType
2220
public function convertToDatabaseValue($value, AbstractPlatform $platform)
2321
{
2422
if (!\is_array($value)) {
25-
throw new LogicException('This type can only be used in combination with arrays.');
23+
throw new \LogicException('This type can only be used in combination with arrays.');
2624
}
2725

2826
if (0 === \count($value)) {
@@ -82,7 +80,7 @@ private function assertValueCanBeImploded($value): void
8280
return;
8381
}
8482

85-
throw new InvalidArgumentException(sprintf('The value of \'%s\' type cannot be imploded.', \gettype($value)));
83+
throw new \InvalidArgumentException(sprintf('The value of \'%s\' type cannot be imploded.', \gettype($value)));
8684
}
8785

8886
abstract protected function convertDatabaseValues(array $values): array;

src/DependencyInjection/LeagueOAuth2ServerExtension.php

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
namespace League\Bundle\OAuth2ServerBundle\DependencyInjection;
66

7-
use DateInterval;
87
use Defuse\Crypto\Key;
98
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
10-
use Exception;
119
use League\Bundle\OAuth2ServerBundle\DBAL\Type\Grant as GrantType;
1210
use League\Bundle\OAuth2ServerBundle\DBAL\Type\RedirectUri as RedirectUriType;
1311
use League\Bundle\OAuth2ServerBundle\DBAL\Type\Scope as ScopeType;
@@ -29,8 +27,6 @@
2927
use League\OAuth2\Server\Grant\PasswordGrant;
3028
use League\OAuth2\Server\Grant\RefreshTokenGrant;
3129
use League\OAuth2\Server\ResourceServer;
32-
use LogicException;
33-
use RuntimeException;
3430
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
3531
use Symfony\Bundle\SecurityBundle\SecurityBundle;
3632
use Symfony\Component\Config\FileLocator;
@@ -49,7 +45,7 @@ final class LeagueOAuth2ServerExtension extends Extension implements PrependExte
4945
/**
5046
* {@inheritdoc}
5147
*
52-
* @throws Exception
48+
* @throws \Exception
5349
*/
5450
public function load(array $configs, ContainerBuilder $container)
5551
{
@@ -120,7 +116,7 @@ private function assertRequiredBundlesAreEnabled(ContainerBuilder $container): v
120116

121117
foreach ($requiredBundles as $bundleAlias => $requiredBundle) {
122118
if (!$container->hasExtension($bundleAlias)) {
123-
throw new LogicException(sprintf('Bundle \'%s\' needs to be enabled in your application kernel.', $requiredBundle));
119+
throw new \LogicException(sprintf('Bundle \'%s\' needs to be enabled in your application kernel.', $requiredBundle));
124120
}
125121
}
126122
}
@@ -139,7 +135,7 @@ private function configureAuthorizationServer(ContainerBuilder $container, array
139135
$authorizationServer->replaceArgument('$encryptionKey', $config['encryption_key']);
140136
} elseif ('defuse' === $config['encryption_key_type']) {
141137
if (!class_exists(Key::class)) {
142-
throw new RuntimeException('You must install the "defuse/php-encryption" package to use "encryption_key_type: defuse".');
138+
throw new \RuntimeException('You must install the "defuse/php-encryption" package to use "encryption_key_type: defuse".');
143139
}
144140

145141
$keyDefinition = (new Definition(Key::class))
@@ -153,35 +149,35 @@ private function configureAuthorizationServer(ContainerBuilder $container, array
153149
if ($config['enable_client_credentials_grant']) {
154150
$authorizationServer->addMethodCall('enableGrantType', [
155151
new Reference(ClientCredentialsGrant::class),
156-
new Definition(DateInterval::class, [$config['access_token_ttl']]),
152+
new Definition(\DateInterval::class, [$config['access_token_ttl']]),
157153
]);
158154
}
159155

160156
if ($config['enable_password_grant']) {
161157
$authorizationServer->addMethodCall('enableGrantType', [
162158
new Reference(PasswordGrant::class),
163-
new Definition(DateInterval::class, [$config['access_token_ttl']]),
159+
new Definition(\DateInterval::class, [$config['access_token_ttl']]),
164160
]);
165161
}
166162

167163
if ($config['enable_refresh_token_grant']) {
168164
$authorizationServer->addMethodCall('enableGrantType', [
169165
new Reference(RefreshTokenGrant::class),
170-
new Definition(DateInterval::class, [$config['access_token_ttl']]),
166+
new Definition(\DateInterval::class, [$config['access_token_ttl']]),
171167
]);
172168
}
173169

174170
if ($config['enable_auth_code_grant']) {
175171
$authorizationServer->addMethodCall('enableGrantType', [
176172
new Reference(AuthCodeGrant::class),
177-
new Definition(DateInterval::class, [$config['access_token_ttl']]),
173+
new Definition(\DateInterval::class, [$config['access_token_ttl']]),
178174
]);
179175
}
180176

181177
if ($config['enable_implicit_grant']) {
182178
$authorizationServer->addMethodCall('enableGrantType', [
183179
new Reference(ImplicitGrant::class),
184-
new Definition(DateInterval::class, [$config['access_token_ttl']]),
180+
new Definition(\DateInterval::class, [$config['access_token_ttl']]),
185181
]);
186182
}
187183

@@ -193,21 +189,21 @@ private function configureGrants(ContainerBuilder $container, array $config): vo
193189
$container
194190
->getDefinition(PasswordGrant::class)
195191
->addMethodCall('setRefreshTokenTTL', [
196-
new Definition(DateInterval::class, [$config['refresh_token_ttl']]),
192+
new Definition(\DateInterval::class, [$config['refresh_token_ttl']]),
197193
])
198194
;
199195

200196
$container
201197
->getDefinition(RefreshTokenGrant::class)
202198
->addMethodCall('setRefreshTokenTTL', [
203-
new Definition(DateInterval::class, [$config['refresh_token_ttl']]),
199+
new Definition(\DateInterval::class, [$config['refresh_token_ttl']]),
204200
])
205201
;
206202

207203
$authCodeGrantDefinition = $container->getDefinition(AuthCodeGrant::class);
208-
$authCodeGrantDefinition->replaceArgument('$authCodeTTL', new Definition(DateInterval::class, [$config['auth_code_ttl']]))
204+
$authCodeGrantDefinition->replaceArgument('$authCodeTTL', new Definition(\DateInterval::class, [$config['auth_code_ttl']]))
209205
->addMethodCall('setRefreshTokenTTL', [
210-
new Definition(DateInterval::class, [$config['refresh_token_ttl']]),
206+
new Definition(\DateInterval::class, [$config['refresh_token_ttl']]),
211207
])
212208
;
213209

@@ -217,17 +213,17 @@ private function configureGrants(ContainerBuilder $container, array $config): vo
217213

218214
$container
219215
->getDefinition(ImplicitGrant::class)
220-
->replaceArgument('$accessTokenTTL', new Definition(DateInterval::class, [$config['access_token_ttl']]))
216+
->replaceArgument('$accessTokenTTL', new Definition(\DateInterval::class, [$config['access_token_ttl']]))
221217
;
222218
}
223219

224220
/**
225-
* @throws Exception
221+
* @throws \Exception
226222
*/
227223
private function configurePersistence(LoaderInterface $loader, ContainerBuilder $container, array $config): void
228224
{
229225
if (\count($config) > 1) {
230-
throw new LogicException('Only one persistence method can be configured at a time.');
226+
throw new \LogicException('Only one persistence method can be configured at a time.');
231227
}
232228

233229
$persistenceConfiguration = current($config);

src/Event/AuthorizationRequestResolveEventFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use League\Bundle\OAuth2ServerBundle\Converter\ScopeConverterInterface;
88
use League\Bundle\OAuth2ServerBundle\Manager\ClientManagerInterface;
99
use League\OAuth2\Server\RequestTypes\AuthorizationRequest;
10-
use RuntimeException;
1110

1211
class AuthorizationRequestResolveEventFactory
1312
{
@@ -27,7 +26,7 @@ public function fromAuthorizationRequest(AuthorizationRequest $authorizationRequ
2726
$client = $this->clientManager->find($authorizationRequest->getClient()->getIdentifier());
2827

2928
if (null === $client) {
30-
throw new RuntimeException(sprintf('No client found for the given identifier \'%s\'.', $authorizationRequest->getClient()->getIdentifier()));
29+
throw new \RuntimeException(sprintf('No client found for the given identifier \'%s\'.', $authorizationRequest->getClient()->getIdentifier()));
3130
}
3231

3332
return new AuthorizationRequestResolveEvent($authorizationRequest, $scopes, $client);

src/League/AuthorizationServer/GrantTypeInterface.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44

55
namespace League\Bundle\OAuth2ServerBundle\League\AuthorizationServer;
66

7-
use DateInterval;
87
use League\OAuth2\Server\Grant\GrantTypeInterface as LeagueGrantTypeInterface;
98

109
interface GrantTypeInterface extends LeagueGrantTypeInterface
1110
{
12-
public function getAccessTokenTTL(): ?DateInterval;
11+
public function getAccessTokenTTL(): ?\DateInterval;
1312
}

src/Manager/Doctrine/AccessTokenManager.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace League\Bundle\OAuth2ServerBundle\Manager\Doctrine;
66

7-
use DateTimeImmutable;
87
use Doctrine\ORM\EntityManagerInterface;
98
use League\Bundle\OAuth2ServerBundle\Manager\AccessTokenManagerInterface;
109
use League\Bundle\OAuth2ServerBundle\Model\AccessToken;
@@ -43,7 +42,7 @@ public function clearExpired(): int
4342
return $this->entityManager->createQueryBuilder()
4443
->delete(AccessToken::class, 'at')
4544
->where('at.expiry < :expiry')
46-
->setParameter('expiry', new DateTimeImmutable())
45+
->setParameter('expiry', new \DateTimeImmutable())
4746
->getQuery()
4847
->execute();
4948
}

src/Manager/Doctrine/AuthorizationCodeManager.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace League\Bundle\OAuth2ServerBundle\Manager\Doctrine;
66

7-
use DateTimeImmutable;
87
use Doctrine\ORM\EntityManagerInterface;
98
use League\Bundle\OAuth2ServerBundle\Manager\AuthorizationCodeManagerInterface;
109
use League\Bundle\OAuth2ServerBundle\Model\AuthorizationCode;
@@ -43,7 +42,7 @@ public function clearExpired(): int
4342
return $this->entityManager->createQueryBuilder()
4443
->delete(AuthorizationCode::class, 'ac')
4544
->where('ac.expiry < :expiry')
46-
->setParameter('expiry', new DateTimeImmutable())
45+
->setParameter('expiry', new \DateTimeImmutable())
4746
->getQuery()
4847
->execute();
4948
}

src/Manager/Doctrine/RefreshTokenManager.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace League\Bundle\OAuth2ServerBundle\Manager\Doctrine;
66

7-
use DateTimeImmutable;
87
use Doctrine\ORM\EntityManagerInterface;
98
use League\Bundle\OAuth2ServerBundle\Manager\RefreshTokenManagerInterface;
109
use League\Bundle\OAuth2ServerBundle\Model\RefreshToken;
@@ -43,7 +42,7 @@ public function clearExpired(): int
4342
return $this->entityManager->createQueryBuilder()
4443
->delete(RefreshToken::class, 'rt')
4544
->where('rt.expiry < :expiry')
46-
->setParameter('expiry', new DateTimeImmutable())
45+
->setParameter('expiry', new \DateTimeImmutable())
4746
->getQuery()
4847
->execute();
4948
}

0 commit comments

Comments
 (0)