Skip to content

Commit 9c5ed85

Browse files
committed
rector + mago fmt applied
1 parent 932a8f7 commit 9c5ed85

587 files changed

Lines changed: 3098 additions & 3480 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/auth/src/AccessControl/PolicyBasedAccessControl.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Tempest\Reflection\ParameterReflector;
1414
use Tempest\Support\Arr\ImmutableArray;
1515
use Tempest\Support\Str;
16+
use Throwable;
1617
use UnitEnum;
1718

1819
/**
@@ -45,7 +46,7 @@ public function isGranted(UnitEnum|string $action, object|string $resource, ?obj
4546
throw new NoPolicyWereFoundForResource($resource);
4647
}
4748

48-
$resource = ! is_object($resource) ? null : $resource;
49+
$resource = is_object($resource) ? $resource : null;
4950

5051
foreach ($policies as $policy) {
5152
$decision = $this->evaluatePolicy($policy, $resource, $subject);
@@ -60,13 +61,13 @@ public function isGranted(UnitEnum|string $action, object|string $resource, ?obj
6061

6162
private function resolveSubject(?object $subject): ?object
6263
{
63-
if ($subject) {
64+
if ($subject !== null) {
6465
return $subject;
6566
}
6667

6768
try {
6869
return $this->container->get(Authenticator::class)->current();
69-
} catch (\Throwable) {
70+
} catch (Throwable) {
7071
return null;
7172
}
7273
}
@@ -113,9 +114,9 @@ private function evaluatePolicy(MethodReflector $policy, ?object $resource, ?obj
113114
return AccessDecision::from($decision);
114115
}
115116

116-
private function ensureParameterAcceptsInput(?ParameterReflector $reflector, mixed $input, \Closure $throw): void
117+
private function ensureParameterAcceptsInput(?ParameterReflector $reflector, mixed $input, Closure $throw): void
117118
{
118-
if ($reflector === null || $input === null) {
119+
if (! $reflector instanceof ParameterReflector || $input === null) {
119120
return;
120121
}
121122

packages/auth/src/Authentication/Authenticatable.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77
/**
88
* Represents an entity that may be authenticated.
99
*/
10-
interface Authenticatable
11-
{
12-
}
10+
interface Authenticatable {}

packages/auth/src/Authentication/SessionAuthenticator.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
final readonly class SessionAuthenticator implements Authenticator
1111
{
1212
public const string AUTHENTICATABLE_KEY = '#authenticatable:id';
13+
1314
public const string AUTHENTICATABLE_CLASS = '#authenticatable:class';
1415

1516
public function __construct(
@@ -35,6 +36,7 @@ public function deauthenticate(): void
3536
{
3637
$this->session->remove(self::AUTHENTICATABLE_KEY);
3738
$this->session->remove(self::AUTHENTICATABLE_CLASS);
39+
3840
$this->sessionManager->save($this->session);
3941
}
4042

packages/auth/src/Exceptions/AuthenticationException.php

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

33
namespace Tempest\Auth\Exceptions;
44

5-
interface AuthenticationException
6-
{
7-
}
5+
interface AuthenticationException {}

packages/auth/src/Exceptions/NoPolicyWereFoundForResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ final class NoPolicyWereFoundForResource extends Exception implements Authentica
99
public function __construct(
1010
public readonly string|object $resource,
1111
) {
12-
parent::__construct(sprintf('No policies were found for resource `%s`.', is_object($resource) ? get_class($resource) : $resource));
12+
parent::__construct(sprintf('No policies were found for resource `%s`.', is_object($resource) ? $resource::class : $resource));
1313
}
1414
}

packages/auth/src/Exceptions/OAuthStateWasInvalid.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66

77
use Exception;
88

9-
final class OAuthStateWasInvalid extends Exception implements AuthenticationException
10-
{
11-
}
9+
final class OAuthStateWasInvalid extends Exception implements AuthenticationException {}

packages/auth/src/Installer/AuthenticationInstaller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Tempest\Console\Console;
88
use Tempest\Console\ConsoleCommand;
99
use Tempest\Console\Input\ConsoleArgumentBag;
10+
use Tempest\Console\Input\ConsoleInputArgument;
1011
use Tempest\Container\Container;
1112
use Tempest\Core\Installer;
1213
use Tempest\Core\PublishesFiles;
@@ -47,7 +48,7 @@ private function shouldMigrate(): bool
4748
{
4849
$argument = $this->consoleArgumentBag->get('migrate');
4950

50-
if ($argument === null || ! is_bool($argument->value)) {
51+
if (! $argument instanceof ConsoleInputArgument || ! is_bool($argument->value)) {
5152
return $this->console->confirm('Do you want to execute migrations?', default: false);
5253
}
5354

@@ -58,7 +59,7 @@ private function shouldInstallOAuth(): bool
5859
{
5960
$argument = $this->consoleArgumentBag->get('oauth');
6061

61-
if ($argument === null || ! is_bool($argument->value)) {
62+
if (! $argument instanceof ConsoleInputArgument || ! is_bool($argument->value)) {
6263
return $this->console->confirm('Do you want to install OAuth?', default: false);
6364
}
6465

packages/auth/src/Installer/OAuthInstaller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function install(): void
3030
{
3131
$providers = $this->getProviders();
3232

33-
if (count($providers) === 0) {
33+
if ($providers === []) {
3434
return;
3535
}
3636

packages/auth/src/OAuth/OAuthConfig.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,24 @@ interface OAuthConfig extends HasTag
1414
/**
1515
* The OAuth provider class name.
1616
*/
17-
public string $provider {
18-
get;
19-
}
17+
public string $provider { get; }
2018

2119
/**
2220
* The authorization scopes for this OAuth provider.
2321
*
2422
* @return string[]
2523
*/
26-
public array $scopes {
27-
get;
28-
}
24+
public array $scopes { get; }
2925

3026
/**
3127
* The client ID for the OAuth provider.
3228
*/
33-
public string $clientId {
34-
get;
35-
}
29+
public string $clientId { get; }
3630

3731
/**
3832
* The controller action to redirect to after the user authorizes the application.
3933
*/
40-
public string|array $redirectTo {
41-
get;
42-
}
34+
public string|array $redirectTo { get; }
4335

4436
/**
4537
* Creates the OAuth provider instance.

packages/auth/tests/AuthenticationAndOAuthSafetyTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PHPUnit\Framework\TestCase;
1010
use ReflectionClass;
1111
use ReflectionMethod;
12+
use stdClass;
1213
use Tempest\Auth\Authentication\DatabaseAuthenticatableResolver;
1314
use Tempest\Auth\Exceptions\ModelWasNotAuthenticatable;
1415
use Tempest\Auth\OAuth\GenericOAuthClient;
@@ -23,7 +24,7 @@ public function database_authenticatable_resolver_rejects_non_authenticatable_cl
2324

2425
$this->expectException(ModelWasNotAuthenticatable::class);
2526

26-
$resolve->invoke($resolver, 1, \stdClass::class);
27+
$resolve->invoke($resolver, 1, stdClass::class);
2728
}
2829

2930
#[Test]

0 commit comments

Comments
 (0)