Skip to content

Commit

Permalink
refactor: phpstan (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Sep 14, 2024
1 parent 05e3ce3 commit 98a6c82
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/AssetElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ final class AssetElements extends Collection implements AssetElementsContract
public function js(): self
{
return $this->filter(
static fn (AssetElementContract $asset): int|bool => $asset instanceof Js
static fn (AssetElementContract $asset): bool => $asset instanceof Js
);
}

public function css(): self
{
return $this->filter(
static fn (AssetElementContract $asset): int|bool => $asset instanceof Css
static fn (AssetElementContract $asset): bool => $asset instanceof Css
);
}

public function inlineCss(): self
{
return $this->filter(
static fn (AssetElementContract $asset): int|bool => $asset instanceof InlineCss
static fn (AssetElementContract $asset): bool => $asset instanceof InlineCss
);
}

public function inlineJs(): self
{
return $this->filter(
static fn (AssetElementContract $asset): int|bool => $asset instanceof InlineJs
static fn (AssetElementContract $asset): bool => $asset instanceof InlineJs
);
}

Expand Down
5 changes: 3 additions & 2 deletions src/Css.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
use MoonShine\AssetManager\Traits\HasLink;
use MoonShine\AssetManager\Traits\WithVersion;
use MoonShine\Contracts\AssetManager\AssetElementContract;
use MoonShine\Contracts\UI\HasComponentAttributesContract;
use MoonShine\Support\Components\MoonShineComponentAttributeBag;
use MoonShine\Support\Traits\Makeable;
use MoonShine\Support\Traits\WithComponentAttributes;

/**
* @method static static make(string $link)
*/
final class Css implements AssetElementContract, HasLinkContact, HasVersionContact
final class Css implements AssetElementContract, HasComponentAttributesContract, HasLinkContact, HasVersionContact
{
use Makeable;
use WithVersion;
Expand Down Expand Up @@ -47,7 +48,7 @@ public function toHtml(): string
]);

return <<<HTML
<link {$this->getAttributes()}>
<link {$this->getAttributes()->toHtml()}>
HTML;
}

Expand Down
5 changes: 3 additions & 2 deletions src/InlineCss.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
namespace MoonShine\AssetManager;

use MoonShine\Contracts\AssetManager\AssetElementContract;
use MoonShine\Contracts\UI\HasComponentAttributesContract;
use MoonShine\Support\Components\MoonShineComponentAttributeBag;
use MoonShine\Support\Traits\Makeable;
use MoonShine\Support\Traits\WithComponentAttributes;

/**
* @method static static make(string $content)
*/
final class InlineCss implements AssetElementContract
final class InlineCss implements AssetElementContract, HasComponentAttributesContract
{
use Makeable;
use WithComponentAttributes;
Expand All @@ -31,7 +32,7 @@ public function getContent(): string
public function toHtml(): string
{
return <<<HTML
<style {$this->getAttributes()}>{$this->getContent()}</style>
<style {$this->getAttributes()->toHtml()}>{$this->getContent()}</style>
HTML;
}

Expand Down
5 changes: 3 additions & 2 deletions src/InlineJs.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

use MoonShine\AssetManager\Traits\WithVersion;
use MoonShine\Contracts\AssetManager\AssetElementContract;
use MoonShine\Contracts\UI\HasComponentAttributesContract;
use MoonShine\Support\Components\MoonShineComponentAttributeBag;
use MoonShine\Support\Traits\Makeable;
use MoonShine\Support\Traits\WithComponentAttributes;

/**
* @method static static make(string $content)
*/
final class InlineJs implements AssetElementContract
final class InlineJs implements AssetElementContract, HasComponentAttributesContract
{
use Makeable;
use WithComponentAttributes;
Expand All @@ -33,7 +34,7 @@ public function getContent(): string
public function toHtml(): string
{
return <<<HTML
<script {$this->getAttributes()}>{$this->getContent()}</script>
<script {$this->getAttributes()->toHtml()}>{$this->getContent()}</script>
HTML;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Js.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
use MoonShine\AssetManager\Traits\HasLink;
use MoonShine\AssetManager\Traits\WithVersion;
use MoonShine\Contracts\AssetManager\AssetElementContract;
use MoonShine\Contracts\UI\HasComponentAttributesContract;
use MoonShine\Support\Components\MoonShineComponentAttributeBag;
use MoonShine\Support\Traits\Makeable;
use MoonShine\Support\Traits\WithComponentAttributes;

/**
* @method static static make(string $link)
*/
final class Js implements AssetElementContract, HasLinkContact, HasVersionContact
final class Js implements AssetElementContract, HasComponentAttributesContract, HasLinkContact, HasVersionContact
{
use Makeable;
use WithVersion;
Expand Down Expand Up @@ -46,7 +47,7 @@ public function toHtml(): string
]);

return <<<HTML
<script {$this->getAttributes()}></script>
<script {$this->getAttributes()->toHtml()}></script>
HTML;
}

Expand Down

0 comments on commit 98a6c82

Please sign in to comment.