Skip to content

Commit

Permalink
Apply php7.4 in Rector preset
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Sep 4, 2024
1 parent 06c2ecd commit 78d0cd9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 36 deletions.
2 changes: 1 addition & 1 deletion rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@
RemoveEmptyClassMethodRector::class,
RemoveUnusedPromotedPropertyRector::class,
])
->withPhpSets(php73: true)
->withPhpSets(php74: true)
->withPreparedSets(deadCode: true);
16 changes: 7 additions & 9 deletions src/Boot/src/BootloadManager/Initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,13 @@ private function getBootloadConfig(
}
$attr = $this->getBootloadConfigAttribute($bootloader);

$getArgument = static function (string $key, bool $override, mixed $default = []) use ($config, $attr): mixed {
return match (true) {
$config instanceof BootloadConfig && $override => $config->{$key},
$config instanceof BootloadConfig && !$override && \is_array($default) =>
$config->{$key} + ($attr->{$key} ?? []),
$config instanceof BootloadConfig && !$override && \is_bool($default) => $config->{$key},
\is_array($config) && $config !== [] && $key === 'args' => $config,
default => $attr->{$key} ?? $default,
};
$getArgument = static fn (string $key, bool $override, mixed $default = []): mixed => match (true) {
$config instanceof BootloadConfig && $override => $config->{$key},
$config instanceof BootloadConfig && !$override && \is_array($default) =>
$config->{$key} + ($attr->{$key} ?? []),
$config instanceof BootloadConfig && !$override && \is_bool($default) => $config->{$key},
\is_array($config) && $config !== [] && $key === 'args' => $config,
default => $attr->{$key} ?? $default,
};

$override = $config instanceof BootloadConfig ? $config->override : true;
Expand Down
19 changes: 6 additions & 13 deletions src/Broadcasting/src/Bootloader/WebsocketsBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,11 @@ final class WebsocketsBootloader extends Bootloader

public function boot(BinderInterface $binder): void
{
$binder->bindSingleton(AuthorizationMiddleware::class, static function (
BroadcastInterface $broadcast,
ResponseFactoryInterface $responseFactory,
BroadcastConfig $config,
?EventDispatcherInterface $dispatcher = null
): AuthorizationMiddleware {
return new AuthorizationMiddleware(
$broadcast,
$responseFactory,
$config->getAuthorizationPath(),
$dispatcher
);
});
$binder->bindSingleton(AuthorizationMiddleware::class, static fn (BroadcastInterface $broadcast, ResponseFactoryInterface $responseFactory, BroadcastConfig $config, ?EventDispatcherInterface $dispatcher = null): AuthorizationMiddleware => new AuthorizationMiddleware(
$broadcast,
$responseFactory,
$config->getAuthorizationPath(),
$dispatcher
));
}
}
4 changes: 1 addition & 3 deletions src/Router/src/Loader/PhpFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public function load(mixed $resource, string $type = null): RouteCollection
throw new LoaderLoadException(\sprintf('File [%s] does not exist.', $resource));
}

$load = static function (string $path) {
return include $path;
};
$load = static fn (string $path) => include $path;

$callback = $load($resource);

Expand Down
8 changes: 4 additions & 4 deletions src/Translator/src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public function getCatalogueManager(): CatalogueManagerInterface
*/
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string
{
$domain = $domain ?? $this->config->getDefaultDomain();
$locale = $locale ?? $this->locale;
$domain ??= $this->config->getDefaultDomain();
$locale ??= $this->locale;

$message = $this->get($locale, $domain, $id);

Expand All @@ -91,8 +91,8 @@ public function transChoice(
string $domain = null,
string $locale = null
): string {
$domain = $domain ?? $this->config->getDefaultDomain();
$locale = $locale ?? $this->locale;
$domain ??= $this->config->getDefaultDomain();
$locale ??= $this->locale;

try {
$message = $this->get($locale, $domain, $id);
Expand Down
10 changes: 4 additions & 6 deletions src/Views/src/ViewManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ public function addEngine(EngineInterface $engine): void
{
$this->engines[] = $engine->withLoader($this->loader);

\uasort($this->engines, static function (EngineInterface $a, EngineInterface $b) {
return \strcmp(
$a->getLoader()->getExtension() ?? '',
$b->getLoader()->getExtension() ?? ''
);
});
\uasort($this->engines, static fn (EngineInterface $a, EngineInterface $b) => \strcmp(
$a->getLoader()->getExtension() ?? '',
$b->getLoader()->getExtension() ?? ''
));

$this->engines = \array_values($this->engines);
}
Expand Down

0 comments on commit 78d0cd9

Please sign in to comment.