Skip to content

Commit c2280af

Browse files
Fix depricated warning on PHP 8.4
1 parent d333c27 commit c2280af

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/Assets.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,24 @@ public function __construct(Repository $config, HtmlBuilder $htmlBuilder)
4444

4545
public function addScripts(array|string $assets): static
4646
{
47-
$this->scripts = array_merge($this->scripts, (array)$assets);
47+
$this->scripts = array_merge($this->scripts, (array) $assets);
4848

4949
return $this;
5050
}
5151

5252
public function addStyles(array|string $assets): static
5353
{
54-
$this->styles = array_merge($this->styles, (array)$assets);
54+
$this->styles = array_merge($this->styles, (array) $assets);
5555

5656
return $this;
5757
}
5858

5959
public function addStylesDirectly(array|string $assets, array $attributes = []): static
6060
{
61-
foreach ((array)$assets as &$item) {
61+
foreach ((array) $assets as &$item) {
6262
$item = ltrim(trim($item), '/');
6363

64-
if (!in_array($item, $this->appendedStyles)) {
64+
if (! in_array($item, $this->appendedStyles)) {
6565
$this->appendedStyles[$item] = [
6666
'src' => $item,
6767
'attributes' => $attributes,
@@ -77,10 +77,10 @@ public function addScriptsDirectly(
7777
string $location = self::ASSETS_SCRIPT_POSITION_FOOTER,
7878
array $attributes = []
7979
): static {
80-
foreach ((array)$assets as &$item) {
80+
foreach ((array) $assets as &$item) {
8181
$item = ltrim(trim($item), '/');
8282

83-
if (!in_array($item, $this->appendedScripts[$location])) {
83+
if (! in_array($item, $this->appendedScripts[$location])) {
8484
$this->appendedScripts[$location][$item] = [
8585
'src' => $item,
8686
'attributes' => $attributes,
@@ -97,7 +97,7 @@ public function removeStyles(array|string $assets): static
9797
return $this;
9898
}
9999

100-
foreach ((array)$assets as $rem) {
100+
foreach ((array) $assets as $rem) {
101101
$index = array_search($rem, $this->styles);
102102
if ($index === false) {
103103
continue;
@@ -115,7 +115,7 @@ public function removeScripts(array|string $assets): static
115115
return $this;
116116
}
117117

118-
foreach ((array)$assets as $rem) {
118+
foreach ((array) $assets as $rem) {
119119
$index = array_search($rem, $this->scripts);
120120
if ($index === false) {
121121
continue;
@@ -129,7 +129,7 @@ public function removeScripts(array|string $assets): static
129129

130130
public function removeItemDirectly(array|string $assets, ?string $location = null): static
131131
{
132-
foreach ((array)$assets as $item) {
132+
foreach ((array) $assets as $item) {
133133
$item = ltrim(trim($item), '/');
134134

135135
if (
@@ -158,7 +158,7 @@ public function getScripts(?string $location = null): array
158158
foreach ($this->scripts as $script) {
159159
$configName = 'resources.scripts.' . $script;
160160

161-
if (!empty($location) && $location !== Arr::get($this->config, $configName . '.location')) {
161+
if (! empty($location) && $location !== Arr::get($this->config, $configName . '.location')) {
162162
continue; // Skip assets that don't match this location
163163
}
164164

@@ -174,7 +174,7 @@ public function getScripts(?string $location = null): array
174174
public function getStyles(array $lastStyles = []): array
175175
{
176176
$styles = [];
177-
if (!empty($lastStyles)) {
177+
if (! empty($lastStyles)) {
178178
$this->styles = array_merge($this->styles, $lastStyles);
179179
}
180180

@@ -226,19 +226,19 @@ protected function itemToHtml(string $name, string $type = 'style'): string
226226
{
227227
$html = '';
228228

229-
if (!in_array($type, ['style', 'script'])) {
229+
if (! in_array($type, ['style', 'script'])) {
230230
return $html;
231231
}
232232

233233
$configName = 'resources.' . $type . 's.' . $name;
234234

235-
if (!Arr::has($this->config, $configName)) {
235+
if (! Arr::has($this->config, $configName)) {
236236
return $html;
237237
}
238238

239239
$src = $this->getSourceUrl($configName);
240240

241-
foreach ((array)$src as $item) {
241+
foreach ((array) $src as $item) {
242242
$html .= $this->htmlBuilder->{$type}($item, ['class' => 'hidden'])->toHtml();
243243
}
244244

@@ -250,7 +250,7 @@ protected function itemToHtml(string $name, string $type = 'style'): string
250250
*/
251251
protected function getSourceUrl(string $configName)
252252
{
253-
if (!Arr::has($this->config, $configName)) {
253+
if (! Arr::has($this->config, $configName)) {
254254
return '';
255255
}
256256

@@ -265,7 +265,7 @@ protected function getSourceUrl(string $configName)
265265

266266
protected function isUsingCdn(string $configName): bool
267267
{
268-
return Arr::get($this->config, $configName . '.use_cdn', false) && !$this->config['offline'];
268+
return Arr::get($this->config, $configName . '.use_cdn', false) && ! $this->config['offline'];
269269
}
270270

271271
protected function getSource(string $configName, ?string $location = null): array
@@ -278,8 +278,8 @@ protected function getSource(string $configName, ?string $location = null): arra
278278

279279
$scripts = [];
280280

281-
foreach ((array)$src as $s) {
282-
if (!$s) {
281+
foreach ((array) $src as $s) {
282+
if (! $s) {
283283
continue;
284284
}
285285

src/HtmlBuilder.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(UrlGenerator $urlGenerator)
1919
*/
2020
public function script(string $url, array $attributes = [], ?bool $secure = null): HtmlString
2121
{
22-
if (!$url) {
22+
if (! $url) {
2323
return new HtmlString();
2424
}
2525

@@ -33,7 +33,7 @@ public function script(string $url, array $attributes = [], ?bool $secure = null
3333
*/
3434
public function style(string $url, array $attributes = [], ?bool $secure = null): HtmlString
3535
{
36-
if (!$url) {
36+
if (! $url) {
3737
return new HtmlString();
3838
}
3939

@@ -57,7 +57,7 @@ public function attributes(array $attributes): string
5757
{
5858
$html = [];
5959

60-
foreach ((array)$attributes as $key => $value) {
60+
foreach ((array) $attributes as $key => $value) {
6161
$element = is_numeric($key) ? $key : $this->attributeElement($key, $value);
6262

6363
if (empty($element)) {
@@ -92,7 +92,7 @@ protected function attributeElement(string $key, array|bool|string|null $value)
9292
return 'class="' . implode(' ', $value) . '"';
9393
}
9494

95-
if (!empty($value)) {
95+
if (! empty($value)) {
9696
return $key . '="' . e($value, false) . '"';
9797
}
9898

0 commit comments

Comments
 (0)