Skip to content

Commit 881e62f

Browse files
Merge pull request #38 from Laragear/analysis-1kwGo5
Apply fixes from StyleCI [ci skip] [skip ci]
2 parents 42c9c8c + ac47e76 commit 881e62f

17 files changed

Lines changed: 43 additions & 36 deletions

src/Alert.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Illuminate\Support\Traits\Tappable;
1515
use JsonSerializable;
1616
use RuntimeException;
17+
1718
use function app;
1819
use function data_get;
1920
use function data_set;
@@ -107,7 +108,7 @@ public function fill(iterable $attributes): static
107108
*/
108109
public function toHtml(): mixed
109110
{
110-
throw new RuntimeException('No view is assigned to render the [' . static::class . '] alert.');
111+
throw new RuntimeException('No view is assigned to render the ['.static::class.'] alert.');
111112
}
112113

113114
/**
@@ -155,7 +156,7 @@ protected function data($key = null, $default = null): mixed
155156
* @param TGetDefault|(\Closure(): TGetDefault) $default
156157
* @return mixed|TGetDefault
157158
*/
158-
public function get(string|null $key, mixed $default = null): mixed
159+
public function get(?string $key, mixed $default = null): mixed
159160
{
160161
return data_get($this->attributes, $key, $default);
161162
}
@@ -225,7 +226,7 @@ public function __unset(string $key): void
225226
*
226227
* @codeCoverageIgnore
227228
*
228-
* @return array{persistenceKey: string|null, index: int, attributes: mixed}
229+
* @return array{persistenceKey: string|null, index: int, attributes: mixed}
229230
*/
230231
public function __serialize(): array
231232
{
@@ -337,7 +338,7 @@ public function setIndex(int $index): static
337338
*/
338339
public function pushToBag(): static
339340
{
340-
if (!isset($this->index)) {
341+
if (! isset($this->index)) {
341342
app(Bag::class)->add($this);
342343
}
343344

src/AlertChannel.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Notifications\Notification;
77
use RuntimeException;
88
use TypeError;
9+
910
use function get_class;
1011
use function gettype;
1112
use function is_object;
@@ -27,22 +28,22 @@ public function __construct(protected Bag $bag, protected ?Request $request)
2728
public function send(object $notifiable, Notification $notification): void
2829
{
2930
// If we're outside the request lifecycle, do nothing.
30-
if (!$this->request) {
31+
if (! $this->request) {
3132
throw new RuntimeException('Cannot set an alert notification outside a request lifecycle.');
3233
}
3334

3435
$alert = $notification->toAlert($notifiable); // @phpstan-ignore-line
3536

36-
if (!$alert instanceof Alert) {
37+
if (! $alert instanceof Alert) {
3738
throw new TypeError(
3839
vsprintf('The toAlert() method must return a Laragear\Alert\Alert instance, %s issued.', [
39-
is_object($alert) ? get_class($alert) : gettype($alert)
40+
is_object($alert) ? get_class($alert) : gettype($alert),
4041
])
4142
);
4243
}
4344

4445
if ($alert->hasIndex()) {
45-
throw new RuntimeException('Alert #' . $alert->getIndex() . ' is already set in the bag.');
46+
throw new RuntimeException('Alert #'.$alert->getIndex().' is already set in the bag.');
4647
}
4748

4849
$this->bag->add($alert);

src/Bag.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Illuminate\Support\Collection;
66
use Illuminate\Support\Traits\Macroable;
7+
78
use function array_key_last;
89
use function is_iterable;
910

@@ -41,7 +42,7 @@ public function getPersisted(): array
4142
*/
4243
public function add(Alert|iterable $alert): static
4344
{
44-
if (!is_iterable($alert)) {
45+
if (! is_iterable($alert)) {
4546
$alert = [$alert];
4647
}
4748

src/Blade/Components/Container.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\View\Component;
77
use Laragear\Alerts\Alert;
88
use Laragear\Alerts\Bag;
9+
910
use function array_map;
1011
use function explode;
1112
use function get_class;
@@ -41,7 +42,7 @@ public function render(): mixed
4142
/**
4243
* Returns a list of filtered alerts.
4344
*
44-
* @return \Illuminate\Support\Collection<int, \Laragear\Alerts\Alert>
45+
* @return \Illuminate\Support\Collection<int, \Laragear\Alerts\Alert>
4546
*/
4647
protected function alerts(): Collection
4748
{

src/Console/Commands/AlertCreateCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Illuminate\Contracts\Console\PromptsForMissingInput;
77
use Illuminate\Support\Str;
88
use Symfony\Component\Console\Input\InputOption;
9+
910
use function app_path;
1011
use function dirname;
1112
use function file_exists;
@@ -81,7 +82,7 @@ protected function writeBladeView(): void
8182
$separator = '\\';
8283
}
8384

84-
$path = $this->viewPath(str_replace('.', $separator, 'alerts.'. $this->getViewName()).'.blade.php');
85+
$path = $this->viewPath(str_replace('.', $separator, 'alerts.'.$this->getViewName()).'.blade.php');
8586

8687
if (! $this->files->isDirectory(dirname($path))) {
8788
$this->files->makeDirectory(dirname($path), 0755, true);
@@ -112,7 +113,7 @@ protected function buildClass($name)
112113

113114
$replace = $this->withoutView()
114115
? 'parent::toHtml()'
115-
: 'view(\'alerts.'. $this->getViewName() .'\', $this->all())';
116+
: 'view(\'alerts.'.$this->getViewName().'\', $this->all())';
116117

117118
return str_replace('{{ view }}', $replace, $class);
118119
}

src/Facades/Alert.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* @method static bool abandon(string $key)
1717
* @method static bool hasPersistent(string $key)
1818
* @method static void flush()
19-
*
2019
* @method static \Laragear\Alerts\Bag getFacadeRoot()
2120
*/
2221
class Alert extends Facade

src/Http/Middleware/AddAlertsToInertia.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Inertia\ResponseFactory as Inertia;
88
use Laragear\Alerts\Bag;
99
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
10+
1011
use function config;
1112

1213
class AddAlertsToInertia

src/Http/Middleware/AddAlertsToJson.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Http\Request;
88
use Illuminate\Http\Response;
99
use Laragear\Alerts\Bag;
10+
1011
use function config;
1112
use function data_set;
1213

src/Http/Middleware/StoreAlertsInSession.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Http\Request;
88
use Laragear\Alerts\Alert;
99
use Laragear\Alerts\Bag;
10+
1011
use function array_merge;
1112
use function in_array;
1213

@@ -23,7 +24,7 @@ public function __construct(protected Bag $bag, protected string $key, protected
2324
/**
2425
* Handle an incoming request.
2526
*
26-
* @param \Closure(\Illuminate\Http\Request):(\Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Inertia\Response) $next
27+
* @param \Closure(\Illuminate\Http\Request):(\Illuminate\Http\Response|\Illuminate\Http\JsonResponse|\Inertia\Response) $next
2728
*/
2829
public function handle(Request $request, Closure $next): mixed
2930
{

src/Testing/Builder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Illuminate\Testing\Assert as PHPUnit;
88
use Laragear\Alerts\Alert;
99
use Laragear\Alerts\Testing\Fakes\BagFake;
10+
1011
use function in_array;
1112
use function is_array;
1213
use function is_string;
@@ -100,7 +101,7 @@ protected function is(Alert $alert): bool
100101
if ($value !== $alert->get($key)) {
101102
return false;
102103
}
103-
} else if (!$value($alert)) {
104+
} elseif (! $value($alert)) {
104105
return false;
105106
}
106107
}

0 commit comments

Comments
 (0)