Skip to content

Commit

Permalink
style: php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
mfn committed Feb 21, 2024
1 parent 090cd3f commit 1fa7f7d
Show file tree
Hide file tree
Showing 58 changed files with 186 additions and 401 deletions.
2 changes: 0 additions & 2 deletions src/Blacklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ public function getGracePeriod()

/**
* Get the unique key held within the blacklist.
*
* @return mixed
*/
public function getKey(Payload $payload)
{
Expand Down
3 changes: 0 additions & 3 deletions src/Claims/Audience.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@

class Audience extends Claim
{
/**
* {@inheritdoc}
*/
protected $name = 'aud';
}
18 changes: 3 additions & 15 deletions src/Claims/Claim.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use JsonSerializable;
use PHPOpenSourceSaver\JWTAuth\Contracts\Claim as ClaimContract;
use PHPOpenSourceSaver\JWTAuth\Exceptions\InvalidClaimException;

abstract class Claim implements Arrayable, ClaimContract, Jsonable, JsonSerializable
abstract class Claim implements Arrayable, ClaimContract, Jsonable, \JsonSerializable
{
/**
* The claim name.
Expand All @@ -29,14 +28,10 @@ abstract class Claim implements Arrayable, ClaimContract, Jsonable, JsonSerializ

/**
* The claim value.
*
* @var mixed
*/
private $value;

/**
* @param mixed $value
*
* @return void
*
* @throws InvalidClaimException
Expand All @@ -49,11 +44,9 @@ public function __construct($value)
/**
* Set the claim value, and call a validate method.
*
* @param mixed $value
* @return $this
*
* @throws InvalidClaimException
*
* @return $this
*/
public function setValue($value)
{
Expand All @@ -64,8 +57,6 @@ public function setValue($value)

/**
* Get the claim value.
*
* @return mixed
*/
public function getValue()
{
Expand Down Expand Up @@ -99,8 +90,6 @@ public function getName()
/**
* Validate the claim in a standalone Claim context.
*
* @param mixed $value
*
* @return bool
*/
public function validateCreate($value)
Expand Down Expand Up @@ -133,8 +122,7 @@ public function validateRefresh($refreshTTL)
/**
* Checks if the value matches the claim.
*
* @param mixed $value
* @param bool $strict
* @param bool $strict
*
* @return bool
*/
Expand Down
12 changes: 1 addition & 11 deletions src/Claims/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class Collection extends IlluminateCollection
/**
* Create a new collection.
*
* @param mixed $items
*
* @return void
*/
public function __construct($items = [])
Expand All @@ -33,11 +31,10 @@ public function __construct($items = [])
* Get a Claim instance by it's unique name.
*
* @param string $name
* @param mixed $default
*
* @return Claim
*/
public function getByClaimName($name, callable $callback = null, $default = null)
public function getByClaimName($name, ?callable $callback = null, $default = null)
{
return $this->filter(function (Claim $claim) use ($name) {
return $claim->getName() === $name;
Expand Down Expand Up @@ -69,8 +66,6 @@ public function validate($context = 'payload')
/**
* Determine if the Collection contains all of the given keys.
*
* @param mixed $claims
*
* @return bool
*/
public function hasAllClaims($claims)
Expand All @@ -90,9 +85,6 @@ public function toPlainArray()
})->toArray();
}

/**
* {@inheritdoc}
*/
protected function getArrayableItems($items)
{
return $this->sanitizeClaims($items);
Expand All @@ -101,8 +93,6 @@ protected function getArrayableItems($items)
/**
* Ensure that the given claims array is keyed by the claim name.
*
* @param mixed $items
*
* @return array
*/
private function sanitizeClaims($items)
Expand Down
1 change: 0 additions & 1 deletion src/Claims/Custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class Custom extends Claim
{
/**
* @param string $name
* @param mixed $value
*
* @return void
*
Expand Down
17 changes: 3 additions & 14 deletions src/Claims/DatetimeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

namespace PHPOpenSourceSaver\JWTAuth\Claims;

use DateInterval;
use DateTimeInterface;
use PHPOpenSourceSaver\JWTAuth\Exceptions\InvalidClaimException;
use PHPOpenSourceSaver\JWTAuth\Support\Utils;

Expand All @@ -29,28 +27,23 @@ trait DatetimeTrait
/**
* Set the claim value, and call a validate method.
*
* @param mixed $value
* @return $this
*
* @throws InvalidClaimException
*
* @return $this
*/
public function setValue($value)
{
if ($value instanceof DateInterval) {
if ($value instanceof \DateInterval) {
$value = Utils::now()->add($value);
}

if ($value instanceof DateTimeInterface) {
if ($value instanceof \DateTimeInterface) {
$value = $value->getTimestamp();
}

return parent::setValue($value);
}

/**
* {@inheritdoc}
*/
public function validateCreate($value)
{
if (!is_numeric($value)) {
Expand All @@ -63,8 +56,6 @@ public function validateCreate($value)
/**
* Determine whether the value is in the future.
*
* @param mixed $value
*
* @return bool
*/
protected function isFuture($value)
Expand All @@ -75,8 +66,6 @@ protected function isFuture($value)
/**
* Determine whether the value is in the past.
*
* @param mixed $value
*
* @return bool
*/
protected function isPast($value)
Expand Down
6 changes: 0 additions & 6 deletions src/Claims/Expiration.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,8 @@ class Expiration extends Claim
{
use DatetimeTrait;

/**
* {@inheritdoc}
*/
protected $name = 'exp';

/**
* {@inheritdoc}
*/
public function validatePayload()
{
if ($this->isPast($this->getValue())) {
Expand Down
1 change: 0 additions & 1 deletion src/Claims/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public function __construct(Request $request)
* Get the instance of the claim when passing the name and value.
*
* @param string $name
* @param mixed $value
*
* @return Claim
*
Expand Down
12 changes: 0 additions & 12 deletions src/Claims/IssuedAt.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,8 @@ class IssuedAt extends Claim
validateCreate as commonValidateCreate;
}

/**
* {@inheritdoc}
*/
protected $name = 'iat';

/**
* {@inheritdoc}
*/
public function validateCreate($value)
{
$this->commonValidateCreate($value);
Expand All @@ -41,19 +35,13 @@ public function validateCreate($value)
return $value;
}

/**
* {@inheritdoc}
*/
public function validatePayload()
{
if ($this->isFuture($this->getValue())) {
throw new TokenInvalidException('Issued At (iat) timestamp cannot be in the future');
}
}

/**
* {@inheritdoc}
*/
public function validateRefresh($refreshTTL)
{
if ($this->isPast($this->getValue() + $refreshTTL * 60)) {
Expand Down
3 changes: 0 additions & 3 deletions src/Claims/Issuer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@

class Issuer extends Claim
{
/**
* {@inheritdoc}
*/
protected $name = 'iss';
}
3 changes: 0 additions & 3 deletions src/Claims/JwtId.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@

class JwtId extends Claim
{
/**
* {@inheritdoc}
*/
protected $name = 'jti';
}
5 changes: 0 additions & 5 deletions src/Claims/NotBefore.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@ class NotBefore extends Claim
{
use DatetimeTrait;

/**
* {@inheritdoc}
*/
protected $name = 'nbf';

/**
* {@inheritdoc}
*
* @throws TokenInvalidException
*/
public function validatePayload()
Expand Down
3 changes: 0 additions & 3 deletions src/Claims/Subject.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@

class Subject extends Claim
{
/**
* {@inheritdoc}
*/
protected $name = 'sub';
}
3 changes: 1 addition & 2 deletions src/Console/EnvHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

namespace PHPOpenSourceSaver\JWTAuth\Console;

use Closure;
use Illuminate\Support\Str;

trait EnvHelperTrait
Expand All @@ -30,7 +29,7 @@ protected function envFileExists(): bool
*
* @param string|int $value
*/
public function updateEnvEntry(string $key, $value, Closure $confirmOnExisting = null): bool
public function updateEnvEntry(string $key, $value, ?\Closure $confirmOnExisting = null): bool
{
$filepath = $this->envPath();

Expand Down
8 changes: 1 addition & 7 deletions src/Contracts/Claim.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@ interface Claim
/**
* Set the claim value, and call a validate method.
*
* @param mixed $value
* @return $this
*
* @throws InvalidClaimException
*
* @return $this
*/
public function setValue($value);

/**
* Get the claim value.
*
* @return mixed
*/
public function getValue();

Expand All @@ -53,8 +49,6 @@ public function getName();
/**
* Validate the Claim value.
*
* @param mixed $value
*
* @return bool
*/
public function validateCreate($value);
Expand Down
2 changes: 0 additions & 2 deletions src/Contracts/JWTSubject.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ interface JWTSubject
{
/**
* Get the identifier that will be stored in the subject claim of the JWT.
*
* @return mixed
*/
public function getJWTIdentifier();

Expand Down
8 changes: 0 additions & 8 deletions src/Contracts/Providers/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,16 @@ interface Auth
{
/**
* Check a user's credentials.
*
* @return mixed
*/
public function byCredentials(array $credentials);

/**
* Authenticate a user via the id.
*
* @param mixed $id
*
* @return mixed
*/
public function byId($id);

/**
* Get the currently authenticated user.
*
* @return mixed
*/
public function user();
}
Loading

0 comments on commit 1fa7f7d

Please sign in to comment.