Skip to content

Commit

Permalink
Fixed code style
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Feb 19, 2024
1 parent fc39efb commit 53054ad
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
6 changes: 4 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

declare(strict_types=1);

use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PHPyh\CodingStandard\PhpCsFixerCodingStandard;

$finder = PhpCsFixer\Finder::create()
$finder = Finder::create()
->in([
__DIR__ . '/src',
__DIR__ . '/tests',
Expand All @@ -13,7 +15,7 @@
__FILE__,
]);

$config = (new PhpCsFixer\Config())
$config = (new Config())
->setFinder($finder)
->setCacheFile(__DIR__ . '/var/.php-cs-fixer.cache');

Expand Down
13 changes: 6 additions & 7 deletions src/TyphoonOPcache.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use Psr\SimpleCache\CacheInterface;
use Typhoon\Exporter\Exporter;

/** @psalm-suppress MixedArgument */
\define(
'TYPHOON_OPCACHE_ENABLED',
\function_exists('opcache_invalidate')
Expand All @@ -27,7 +26,7 @@ final class TyphoonOPcache implements CacheInterface

public function __construct(
private readonly string $directory,
private readonly \DateInterval|int|null $defaultTtl = null,
private readonly null|\DateInterval|int $defaultTtl = null,
private readonly LoggerInterface $logger = new NullLogger(),
private readonly ClockInterface $clock = new SystemClock(),
) {
Expand Down Expand Up @@ -65,7 +64,7 @@ private static function validateKey(string $key): void
*/
private static function handleErrors(\Closure $function): mixed
{
set_error_handler(static fn (int $level, string $message, string $file, int $line) => throw new CacheErrorException(
set_error_handler(static fn(int $level, string $message, string $file, int $line) => throw new CacheErrorException(
message: $message,
severity: $level,
filename: $file,
Expand All @@ -83,10 +82,10 @@ public function get(string $key, mixed $default = null): mixed
{
self::validateKey($key);

return self::handleErrors(fn (): mixed => $this->read($this->file($key), $default, $this->clock->now()));
return self::handleErrors(fn(): mixed => $this->read($this->file($key), $default, $this->clock->now()));
}

public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool
public function set(string $key, mixed $value, null|\DateInterval|int $ttl = null): bool
{
self::validateKey($key);

Expand Down Expand Up @@ -172,7 +171,7 @@ public function getMultiple(iterable $keys, mixed $default = null): array
});
}

public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool
public function setMultiple(iterable $values, null|\DateInterval|int $ttl = null): bool
{
return self::handleErrors(function () use ($values, $ttl): bool {
$expiryDate = $this->calculateExpiryDate($ttl);
Expand Down Expand Up @@ -314,7 +313,7 @@ private function file(string $key): string
return $this->directory . \DIRECTORY_SEPARATOR . $hash[0] . \DIRECTORY_SEPARATOR . $hash[1] . \DIRECTORY_SEPARATOR . substr($hash, 2);
}

private function calculateExpiryDate(\DateInterval|int|null $ttl): null|false|\DateTimeImmutable
private function calculateExpiryDate(null|\DateInterval|int $ttl): null|false|\DateTimeImmutable
{
$ttl ??= $this->defaultTtl;

Expand Down
2 changes: 1 addition & 1 deletion tests/TyphoonOPcacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ private function assertCacheDirIsEmpty(): void

private function getCurrentErrorHandler(): ?callable
{
$currentHandler = set_error_handler(static fn (): bool => true);
$currentHandler = set_error_handler(static fn(): bool => true);
restore_error_handler();

return $currentHandler;
Expand Down

0 comments on commit 53054ad

Please sign in to comment.