Skip to content

Commit

Permalink
Should fix static analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Jan 29, 2025
1 parent d19aba6 commit 2e754cb
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Assertion/Validator/Pipes/CheckPublicKeySignature.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function retrieveBinaryVerifiable(JsonTransport $request): string
$verifiable = ByteBuffer::decodeBase64Url($request->get('response.authenticatorData')).
hash('sha256', ByteBuffer::decodeBase64Url($request->get('response.clientDataJSON')), true);

return $verifiable
return $verifiable // @phpstan-ignore-line
?: throw AssertionException::make('Authenticator Data or Client Data JSON are empty or malformed.');
}

Expand Down
4 changes: 4 additions & 0 deletions src/Attestation/AuthenticatorData.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ protected static function readFlags(string $binFlag): object
/**
* Reads the attestation data.
*
* @param-out int $endOffset
*
* @return object{aaguid: string, credentialId: \Laragear\WebAuthn\ByteBuffer, credentialPublicKey: object}&\stdClass
*/
protected static function readAttestData(string $binary, int &$endOffset): object
Expand All @@ -392,6 +394,8 @@ protected static function readAttestData(string $binary, int &$endOffset): objec

/**
* Read COSE key-encoded elliptic curve public key in EC2 format.
*
* @param-out int $endOffset
*/
protected static function readCredentialPublicKey(string $binary, int $offset, int &$endOffset): object
{
Expand Down
1 change: 1 addition & 0 deletions src/Auth/WebAuthnUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected function validateWebAuthn(WebAuthnAuthenticatable $user, array $creden
*/
public function rehashPasswordIfRequired(UserContract $user, array $credentials, bool $force = false): void
{
// @phpstan-ignore-next-line
if (! $this->isSignedChallenge($credentials) && method_exists(get_parent_class($this), 'rehashPasswordIfRequired')) {
parent::rehashPasswordIfRequired($user, $credentials, $force);
}
Expand Down
2 changes: 1 addition & 1 deletion src/CborDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static function decode(ByteBuffer|string $encoded): ByteBuffer|array|bool
*
* @throws \Laragear\WebAuthn\Exceptions\DataException
*/
public static function decodePortion(ByteBuffer|string $bufOrBin, int $startOffset, ?int &$endOffset = null): ByteBuffer|array|bool|float|int|string|null
public static function decodePortion(ByteBuffer|string $bufOrBin, int $startOffset, ?int &$endOffset = null): ByteBuffer|array|bool|float|int|string|null // @phpstan-ignore-line
{
$buf = $bufOrBin instanceof ByteBuffer ? $bufOrBin : new ByteBuffer($bufOrBin);

Expand Down
4 changes: 0 additions & 4 deletions src/Contracts/WebAuthnAuthenticatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ public function makeWebAuthnCredential(array $properties): WebAuthnCredential;

/**
* Returns a queryable relationship for its WebAuthn Credentials.
*
* @phpstan-ignore-next-line
*
* @return \Illuminate\Database\Eloquent\Relations\MorphMany|\Laragear\WebAuthn\Models\WebAuthnCredential
*/
public function webAuthnCredentials(): MorphMany;
}
6 changes: 0 additions & 6 deletions src/Http/Requests/AssertedRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ public function hasRemember(): bool

/**
* Logs in the user for this assertion request.
*
* @param string|null $guard
*
* @phpstan-ignore-next-line
*
* @return \Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable|\Illuminate\Contracts\Auth\Authenticatable|null
*/
public function login(
?string $guard = null,
Expand Down
24 changes: 11 additions & 13 deletions src/Models/WebAuthnCredential.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
/**
* @mixin \Illuminate\Database\Eloquent\Builder
*
* @method \Illuminate\Database\Eloquent\Builder|\static newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\static query()
* @method \Illuminate\Database\Eloquent\Builder|static newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|static query()
* @method static \Laragear\WebAuthn\Models\WebAuthnCredential make(array $attributes = [])
* @method static \Laragear\WebAuthn\Models\WebAuthnCredential create(array $attributes = [])
* @method static \Laragear\WebAuthn\Models\WebAuthnCredential forceCreate(array $attributes)
Expand All @@ -33,14 +33,14 @@
* @method \Laragear\WebAuthn\Models\WebAuthnCredential createOrFirst(array $attributes, array $values = [])
* @method \Laragear\WebAuthn\Models\WebAuthnCredential sole($columns = ['*'])
* @method \Laragear\WebAuthn\Models\WebAuthnCredential findOrNew($id, $columns = ['*'])
* @method \Illuminate\Database\Eloquent\Collection<int, \static>|\static[]|\static|null find($id, $columns = ['*'])
* @method \Illuminate\Database\Eloquent\Collection<int, \static>|\static[]|\static findOrFail($id, $columns = ['*'])
* @method \Illuminate\Database\Eloquent\Collection<int, \static>|\static[]|\static findOr($id, $columns = ['*'], \Closure|null $callback = null)
* @method \Illuminate\Database\Eloquent\Collection<int, \static>|\static[] findMany($id, $columns = ['*'])
* @method \Illuminate\Database\Eloquent\Collection<int, \static>|\static[] fromQuery($query, $bindings = [])
* @method \Illuminate\Support\LazyCollection<int, \static>|\static[] lazy(int $chunkSize = 1000)
* @method \Illuminate\Support\LazyCollection<int, \static>|\static[] lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)
* @method \Illuminate\Support\LazyCollection<int, \static>|\static[] lazyByIdDesc(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)
* @method \Illuminate\Database\Eloquent\Collection<int, static>|static[]|static|null find($id, $columns = ['*'])
* @method \Illuminate\Database\Eloquent\Collection<int, static>|static[]|static findOrFail($id, $columns = ['*'])
* @method \Illuminate\Database\Eloquent\Collection<int, static>|static[]|static findOr($id, $columns = ['*'], \Closure|null $callback = null)
* @method \Illuminate\Database\Eloquent\Collection<int, static>|static[] findMany($id, $columns = ['*'])
* @method \Illuminate\Database\Eloquent\Collection<int, static>|static[] fromQuery($query, $bindings = [])
* @method \Illuminate\Support\LazyCollection<int, static>|static[] lazy(int $chunkSize = 1000)
* @method \Illuminate\Support\LazyCollection<int, static>|static[] lazyById(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)
* @method \Illuminate\Support\LazyCollection<int, static>|static[] lazyByIdDesc(int $chunkSize = 1000, string|null $column = null, string|null $alias = null)
*
* @property-read string $id
* @property-read string $user_id
Expand Down Expand Up @@ -101,9 +101,7 @@ class WebAuthnCredential extends Model
protected $visible = ['id', 'origin', 'alias', 'aaguid', 'attestation_format', 'disabled_at'];

/**
* @phpstan-ignore-next-line
*
* @return \Illuminate\Database\Eloquent\Relations\MorphTo|\Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable
* @return \Illuminate\Database\Eloquent\Relations\MorphTo<\Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable, $this>
*/
public function authenticatable(): MorphTo

Check failure on line 106 in src/Models/WebAuthnCredential.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static Analysis

Type Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable in generic type Illuminate\Database\Eloquent\Relations\MorphTo<Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable, $this(Laragear\WebAuthn\Models\WebAuthnCredential)> in PHPDoc tag @return is not subtype of template type TRelatedModel of Illuminate\Database\Eloquent\Model of class Illuminate\Database\Eloquent\Relations\MorphTo.

Check failure on line 106 in src/Models/WebAuthnCredential.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static Analysis

Type Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable in generic type Illuminate\Database\Eloquent\Relations\MorphTo<Laragear\WebAuthn\Contracts\WebAuthnAuthenticatable, $this(Laragear\WebAuthn\Models\WebAuthnCredential)> in PHPDoc tag @return is not subtype of template type TRelatedModel of Illuminate\Database\Eloquent\Model of class Illuminate\Database\Eloquent\Relations\MorphTo.
{
Expand Down
4 changes: 2 additions & 2 deletions src/WebAuthnServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function boot(): void
*/
protected function publishesPackageMigrations(array|string $paths, string $groups = 'migrations'): void
{
if (method_exists(static::class, 'publishesMigrations')) {
if (method_exists(static::class, 'publishesMigrations')) { // @phpstan-ignore-line
foreach ((array) $paths as $path) {
$this->publishesMigrations([$path => $this->app->databasePath('migrations/')], 'migrations');
}
Expand All @@ -88,7 +88,7 @@ protected function publishesPackageMigrations(array|string $paths, string $group
$files[$file->getRealPath()] = $this->app->databasePath("migrations/{$prefix}_$filename");
}

method_exists($this, 'publishesMigrations')
method_exists($this, 'publishesMigrations') // @phpstan-ignore-line
? $this->publishesMigrations($files, $groups)
: $this->publishes($files, $groups);
}
Expand Down

0 comments on commit 2e754cb

Please sign in to comment.