Skip to content

Commit

Permalink
syntax updates for PHP 8.4 and strict phpstan rules
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst committed Nov 21, 2024
1 parent 7c9927d commit 524013a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/DependencyInjection/TablerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function load(array $configs, ContainerBuilder $container): void
$config = $this->processConfiguration($configuration, $configs);
$options = $this->getContextOptions($config);

if (!empty($config)) {
if (count($options) > 0) {
$container->setParameter('tabler_bundle.options', $options);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Event/NotificationEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function addNotification(NotificationV2Interface|NotificationInterface $n

public function removeNotification(NotificationInterface $notification): void
{
if (($key = array_search($notification, $this->notifications)) !== false) {
if (($key = array_search($notification, $this->notifications, true)) !== false) {
unset($this->notifications[$key]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/MenuItemModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public function addChild(MenuItemInterface $child): void

public function removeChild(MenuItemInterface $child): void
{
if (false !== ($key = array_search($child, $this->children))) {
if (false !== ($key = array_search($child, $this->children, true))) {
unset($this->children[$key]);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Model/NotificationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

use KevinPapst\TablerBundle\Helper\Constants;

class NotificationModel implements NotificationV2Interface
class NotificationModel implements NotificationV2Interface // @phpstan-ignore class.implementsDeprecatedInterface
{
private ?string $url = null;
private bool $active = false;
private bool $disabled = false;
private bool $withBadge = true;
private bool $badgeAnimated = true;
private bool $active = false;
private bool $disabled = false;
private bool $withBadge = true;
private bool $badgeAnimated = true;

private bool $html = false;

Expand Down
2 changes: 1 addition & 1 deletion src/Model/UserModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getIdentifier(): string

public function getUserIdentifier(): string
{
if (!empty($this->id)) {
if ($this->id !== '') {
return $this->id;
}

Expand Down
14 changes: 7 additions & 7 deletions src/Twig/RuntimeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ final class RuntimeExtension implements RuntimeExtensionInterface
* @param array<string, string> $icons
*/
public function __construct(
private EventDispatcherInterface $eventDispatcher,
private ContextHelper $helper,
private array $routes,
private array $icons
private readonly EventDispatcherInterface $eventDispatcher,
private readonly ContextHelper $helper,
private readonly array $routes,
private readonly array $icons
) {
}

Expand Down Expand Up @@ -67,7 +67,7 @@ public function containerClass(string $class = ''): string
$classList[] = 'container-fluid';
}

return trim(implode(' ', array_values($classList)));
return trim(implode(' ', $classList));
}

/**
Expand Down Expand Up @@ -115,12 +115,12 @@ public function getUserDetails(): ?UserDetailsEvent
return $userEvent;
}

public function createIcon(string $name, bool $withIconClass = false, string $default = null): string
public function createIcon(string $name, bool $withIconClass = false, ?string $default = null): string
{
return '<i class="' . $this->icon($name, $withIconClass, $default) . '"></i>';
}

public function icon(string $name, bool $withIconClass = false, string $default = null): string
public function icon(string $name, bool $withIconClass = false, ?string $default = null): string
{
return ($withIconClass ? 'icon ' : '') . ($this->icons[str_replace('-', '_', $name)] ?? ($default ?? $name));
}
Expand Down

0 comments on commit 524013a

Please sign in to comment.