Skip to content

Commit

Permalink
Improved type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Jan 26, 2025
1 parent 589178f commit 3649762
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/Access/Impersonation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

namespace Orchid\Access;

use Illuminate\Auth\SessionGuard;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\StatefulGuard;
use Illuminate\Support\Facades\Auth;

class Impersonation
Expand Down Expand Up @@ -75,9 +74,9 @@ public static function isImpersonating(): bool
/**
* Returns the authentication guard.
*
* @return \Illuminate\Contracts\Auth\Guard|\Illuminate\Contracts\Auth\StatefulGuard
* @return SessionGuard
*/
protected static function getAuth(): Guard|StatefulGuard
protected static function getAuth(): SessionGuard
{
// Get the authentication guard specified in the config file
return Auth::guard(config('platform.guard'));
Expand Down
9 changes: 7 additions & 2 deletions src/Attachment/Engines/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

class Generator implements Engine
{
protected const UNKNOWN = 'unknown';

/**
* The uploaded file instance.
*
Expand Down Expand Up @@ -118,13 +120,16 @@ public function time(): int

/**
* Get the file extension.
*
* @psalm-suppress InvalidNullableReturnType
* @psalm-suppress NullableReturnStatement
*/
public function extension(): string
{
$extension = $this->file->getClientOriginalExtension();

return empty($extension)
? $this->mimes->getExtension($this->file->getClientMimeType(), 'unknown')
? $this->mimes->getExtension($this->file->getClientMimeType(), static::UNKNOWN)
: $extension;
}

Expand All @@ -135,6 +140,6 @@ public function mime(): string
{
return $this->mimes->getMimeType($this->extension())
?? $this->mimes->getMimeType($this->file->getClientMimeType())
?? 'unknown';
?? static::UNKNOWN;
}
}

0 comments on commit 3649762

Please sign in to comment.