Skip to content

Commit

Permalink
[TASK] Run PHP-CS-Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
eliashaeussler committed Jun 6, 2024
1 parent ef7d548 commit dc3c92d
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use EliasHaeussler\Typo3SitemapLocator;
use EliasHaeussler\Typo3Warming\Configuration;
use EliasHaeussler\Typo3Warming\Utility;
use Exception;
use TYPO3\CMS\Backend;
use TYPO3\CMS\Core;

Expand Down Expand Up @@ -171,12 +170,12 @@ private function initSubMenus(): void
if ($itemName === self::ITEM_MODE_SITE) {
$languages = array_filter(
$languages,
fn (Core\Site\Entity\SiteLanguage $siteLanguage): bool => $this->canWarmupCachesOfSite($siteLanguage)
fn(Core\Site\Entity\SiteLanguage $siteLanguage): bool => $this->canWarmupCachesOfSite($siteLanguage)
);
} else {
$languages = array_filter(
$languages,
fn (Core\Site\Entity\SiteLanguage $siteLanguage): bool => Utility\AccessUtility::canWarmupCacheOfPage(
fn(Core\Site\Entity\SiteLanguage $siteLanguage): bool => Utility\AccessUtility::canWarmupCacheOfPage(
(int)$this->identifier,
$siteLanguage->getLanguageId(),
)
Expand Down Expand Up @@ -254,7 +253,7 @@ private function canWarmupCachesOfSite(Core\Site\Entity\SiteLanguage $siteLangua
return true;
}
}
} catch (Exception) {
} catch (\Exception) {
// Unable to locate any sitemaps
}

Expand Down
7 changes: 3 additions & 4 deletions Classes/Command/WarmupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
use EliasHaeussler\Typo3Warming\Domain;
use EliasHaeussler\Typo3Warming\Http;
use EliasHaeussler\Typo3Warming\Utility;
use JsonException;
use Symfony\Component\Console;
use TYPO3\CMS\Core;

Expand Down Expand Up @@ -113,7 +112,7 @@ protected function configure(): void
' │ It can be defined via the extension configuration <info>strategy</info> or by using the <info>--strategy</info> option.',
' │ The following strategies are currently available:',
...array_map(
static fn (string $strategy) => ' │ * <info>' . $strategy . '</info>',
static fn(string $strategy) => ' │ * <info>' . $strategy . '</info>',
array_keys($this->crawlingStrategyFactory->getAll()),
),
' ├─ Default: <info>' . ($this->configuration->getStrategy() ?? 'none') . '</info>',
Expand Down Expand Up @@ -193,7 +192,7 @@ protected function configure(): void
/**
* @throws Console\Exception\ExceptionInterface
* @throws Core\Exception\SiteNotFoundException
* @throws JsonException
* @throws \JsonException
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output): int
{
Expand Down Expand Up @@ -226,7 +225,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
/**
* @return array<string, mixed>
* @throws Core\Exception\SiteNotFoundException
* @throws JsonException
* @throws \JsonException
* @throws Typo3SitemapLocator\Exception\BaseUrlIsNotSupported
* @throws Typo3SitemapLocator\Exception\SitemapIsMissing
*/
Expand Down
3 changes: 1 addition & 2 deletions Classes/Controller/CacheWarmupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
use EliasHaeussler\Typo3Warming\Service;
use EliasHaeussler\Typo3Warming\ValueObject;
use GuzzleHttp\Exception\GuzzleException;
use JsonException;
use Psr\Http\Message;
use Psr\Log;
use TYPO3\CMS\Core;
Expand All @@ -56,7 +55,7 @@ public function __construct(
* @throws CacheWarmup\Exception\Exception
* @throws Core\Exception\SiteNotFoundException
* @throws GuzzleException
* @throws JsonException
* @throws \JsonException
* @throws SSE\Exception\StreamIsActive
* @throws SSE\Exception\StreamIsClosed
* @throws SSE\Exception\StreamIsInactive
Expand Down
7 changes: 3 additions & 4 deletions Classes/Domain/Model/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

namespace EliasHaeussler\Typo3Warming\Domain\Model;

use DateTimeInterface;
use EliasHaeussler\Typo3Warming\Domain;
use TYPO3\CMS\Extbase;

Expand All @@ -39,7 +38,7 @@ class Log extends Extbase\DomainObject\AbstractEntity
final public const TABLE_NAME = 'tx_warming_domain_model_log';

protected string $requestId = '';
protected ?DateTimeInterface $date = null;
protected ?\DateTimeInterface $date = null;
protected string $url = '';
protected string $message = '';
protected ?Domain\Type\StateType $state = null;
Expand All @@ -58,12 +57,12 @@ public function setRequestId(string $requestId): self
return $this;
}

public function getDate(): ?DateTimeInterface
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}

public function setDate(?DateTimeInterface $date): self
public function setDate(?\DateTimeInterface $date): self
{
$this->date = $date;

Expand Down
3 changes: 1 addition & 2 deletions Classes/Domain/Type/StateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
namespace EliasHaeussler\Typo3Warming\Domain\Type;

use EliasHaeussler\Typo3Warming\Enums;
use Stringable;
use TYPO3\CMS\Core;

/**
Expand All @@ -33,7 +32,7 @@
* @author Elias Häußler <[email protected]>
* @license GPL-2.0-or-later
*/
final class StateType implements Core\Type\TypeInterface, Stringable
final class StateType implements Core\Type\TypeInterface, \Stringable
{
private readonly Enums\WarmupState $state;

Expand Down
2 changes: 1 addition & 1 deletion Classes/Http/Message/Event/WarmupFinishedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private function buildMessages(Enums\WarmupState $state): array
}

// Remove invalid messages
$messages = array_filter($messages, static fn (string $message) => \trim($message) !== '');
$messages = array_filter($messages, static fn(string $message) => \trim($message) !== '');

// Handle no cache warmup
if ($messages === []) {
Expand Down
10 changes: 4 additions & 6 deletions Classes/Http/Message/Handler/StreamResponseHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
use EliasHaeussler\CacheWarmup;
use EliasHaeussler\SSE;
use EliasHaeussler\Typo3Warming\Http;
use JsonException;
use Psr\Http\Message;
use Throwable;

/**
* StreamResponseHandler
Expand All @@ -54,7 +52,7 @@ public function __construct(
) {}

/**
* @throws JsonException
* @throws \JsonException
* @throws SSE\Exception\StreamIsClosed
* @throws SSE\Exception\StreamIsInactive
*/
Expand All @@ -66,19 +64,19 @@ public function onSuccess(Message\ResponseInterface $response, Message\UriInterf
}

/**
* @throws JsonException
* @throws \JsonException
* @throws SSE\Exception\StreamIsClosed
* @throws SSE\Exception\StreamIsInactive
*/
public function onFailure(Throwable $exception, Message\UriInterface $uri): void
public function onFailure(\Throwable $exception, Message\UriInterface $uri): void
{
$this->failedUrls[] = (string)$uri;

$this->sendEvent($uri);
}

/**
* @throws JsonException
* @throws \JsonException
* @throws SSE\Exception\StreamIsClosed
* @throws SSE\Exception\StreamIsInactive
*/
Expand Down
4 changes: 2 additions & 2 deletions Classes/Result/CacheWarmupResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getCrawlingResultsBySite(
'successful' => array_values(
array_filter(
$this->result->getSuccessful(),
fn (CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterBySite(
fn(CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterBySite(
$crawlingResult,
$site,
$siteLanguage,
Expand All @@ -74,7 +74,7 @@ public function getCrawlingResultsBySite(
'failed' => array_values(
array_filter(
$this->result->getFailed(),
fn (CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterBySite(
fn(CacheWarmup\Result\CrawlingResult $crawlingResult) => $this->filterBySite(
$crawlingResult,
$site,
$siteLanguage,
Expand Down
2 changes: 1 addition & 1 deletion Classes/Service/CacheWarmupService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function warmup(
$sitemaps = $this->sitemapLocator->locateBySite($siteWarmupRequest->getSite(), $siteLanguage);
$cacheWarmer->addSitemaps(
array_map(
static fn (Typo3SitemapLocator\Domain\Model\Sitemap $sitemap) => Domain\Model\SiteAwareSitemap::fromLocatedSitemap($sitemap),
static fn(Typo3SitemapLocator\Domain\Model\Sitemap $sitemap) => Domain\Model\SiteAwareSitemap::fromLocatedSitemap($sitemap),
$sitemaps,
),
);
Expand Down
3 changes: 1 addition & 2 deletions Classes/UserFunc/LogTableFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

namespace EliasHaeussler\Typo3Warming\UserFunc;

use DateTimeImmutable;
use EliasHaeussler\Typo3Warming\Domain;
use TYPO3\CMS\Backend;

Expand All @@ -47,7 +46,7 @@ public function formatTitle(array &$parameters): void
$record = Backend\Utility\BackendUtility::getRecord(Domain\Model\Log::TABLE_NAME, $parameters['row']['uid']);

if ($record !== null) {
$date = DateTimeImmutable::createFromFormat('U', (string)$record['date']);
$date = \DateTimeImmutable::createFromFormat('U', (string)$record['date']);
$parameters['title'] = sprintf(
self::TEMPLATE,
$record['request_id'],
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use EliasHaeussler\CacheWarmup;
use Symfony\Component\DependencyInjection;

return static function(
return static function (
DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator,
DependencyInjection\ContainerBuilder $container,
): void {
Expand Down
6 changes: 3 additions & 3 deletions Tests/Acceptance/Support/Helper/PageTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function openContextMenu(array $path): void
$contextMenu = $context->findElement(WebDriver\WebDriverBy::cssSelector(self::$treeItemAnchorSelector));
}

$I->executeInSelenium(function(WebDriver\Remote\RemoteWebDriver $webDriver) use ($contextMenu): void {
$I->executeInSelenium(function (WebDriver\Remote\RemoteWebDriver $webDriver) use ($contextMenu): void {
$webDriver->getMouse()->contextClick($contextMenu->getCoordinates());
});
$I->waitForElementVisible(Tests\Acceptance\Support\Enums\Selectors::ContextMenuGroup->value);
Expand All @@ -89,7 +89,7 @@ public function selectInContextMenu(array $path): void

$I->waitForElementVisible($contextMenuId, 5);
$I->executeInSelenium(
function(WebDriver\Remote\RemoteWebDriver $webDriver) use ($contextMenuId, $selector): void {
function (WebDriver\Remote\RemoteWebDriver $webDriver) use ($contextMenuId, $selector): void {
$contextMenu = $webDriver->findElement(WebDriver\WebDriverBy::cssSelector($contextMenuId));
$items = $contextMenu->findElements(WebDriver\WebDriverBy::tagName('li'));

Expand Down Expand Up @@ -119,7 +119,7 @@ protected function ensureTreeNodeIsOpen(

/** @var WebDriver\Remote\RemoteWebElement $context */
$context = $I->executeInSelenium(
static fn () => $context->findElement(
static fn() => $context->findElement(
WebDriver\WebDriverBy::xpath('//*[text()=\'' . $nodeText . '\']/../../..'),
),
);
Expand Down
2 changes: 1 addition & 1 deletion Tests/Build/Configuration/system/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use Symfony\Component\DependencyInjection;
use TYPO3\CMS\Core;

return static function(DependencyInjection\ContainerBuilder $containerBuilder): void {
return static function (DependencyInjection\ContainerBuilder $containerBuilder): void {
$cachePath = Core\Core\Environment::getVarPath() . '/cache/data/di/DependencyInjectionContainer.xml';

$containerBuilder->addCompilerPass(
Expand Down
2 changes: 1 addition & 1 deletion Tests/CGL/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
use Rector\Symfony\Symfony61\Rector\Class_\CommandPropertyToAttributeRector;
use Rector\ValueObject\PhpVersion;

return static function(RectorConfig $rectorConfig): void {
return static function (RectorConfig $rectorConfig): void {
$rootPath = dirname(__DIR__, 2);

require $rootPath . '/.Build/vendor/autoload.php';
Expand Down
3 changes: 1 addition & 2 deletions Tests/Functional/BufferedConsoleOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

namespace EliasHaeussler\Typo3Warming\Tests\Functional;

use RuntimeException;
use Symfony\Component\Console;

/**
Expand Down Expand Up @@ -91,7 +90,7 @@ private function createStream()
$stream = fopen('php://temp', 'w+');

if ($stream === false) {
throw new RuntimeException('Unable to create resource stream.', 1688464796);
throw new \RuntimeException('Unable to create resource stream.', 1688464796);
}

return $stream;
Expand Down
17 changes: 8 additions & 9 deletions Tests/Functional/Configuration/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

use EliasHaeussler\CacheWarmup;
use EliasHaeussler\Typo3Warming as Src;
use Generator;
use PHPUnit\Framework;
use TYPO3\CMS\Core;
use TYPO3\TestingFramework;
Expand Down Expand Up @@ -406,38 +405,38 @@ public function getUserAgentReturnsCorrectlyGeneratedUserAgent(): void
}

/**
* @return Generator<string, array{string|bool}>
* @return \Generator<string, array{string|bool}>
*/
public static function getCrawlerReturnsDefaultCrawlerIfConfiguredCrawlerIsInvalidDataProvider(): Generator
public static function getCrawlerReturnsDefaultCrawlerIfConfiguredCrawlerIsInvalidDataProvider(): \Generator
{
yield 'empty string' => [''];
yield 'invalid type' => [false];
yield 'invalid class name' => ['foo'];
}

/**
* @return Generator<string, array{string|bool}>
* @return \Generator<string, array{string|bool}>
*/
public static function getVerboseCrawlerReturnsDefaultVerboseCrawlerIfConfiguredVerboseCrawlerIsInvalidDataProvider(): Generator
public static function getVerboseCrawlerReturnsDefaultVerboseCrawlerIfConfiguredVerboseCrawlerIsInvalidDataProvider(): \Generator
{
yield 'empty string' => [''];
yield 'invalid type' => [false];
yield 'invalid class name' => ['foo'];
}

/**
* @return Generator<string, array{bool}>
* @return \Generator<string, array{bool}>
*/
public static function isEnabledInPageTreeReturnsConfiguredValueDataProvider(): Generator
public static function isEnabledInPageTreeReturnsConfiguredValueDataProvider(): \Generator
{
yield 'enabled' => [true];
yield 'disabled' => [false];
}

/**
* @return Generator<string, array{bool}>
* @return \Generator<string, array{bool}>
*/
public static function isEnabledInToolbarReturnsConfiguredValueDataProvider(): Generator
public static function isEnabledInToolbarReturnsConfiguredValueDataProvider(): \Generator
{
yield 'enabled' => [true];
yield 'disabled' => [false];
Expand Down
3 changes: 1 addition & 2 deletions Tests/Functional/Crawler/ConcurrentUserAgentCrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use EliasHaeussler\TransientLogger;
use EliasHaeussler\Typo3Warming as Src;
use EliasHaeussler\Typo3Warming\Tests;
use Exception;
use PHPUnit\Framework;
use TYPO3\CMS\Core;
use TYPO3\TestingFramework;
Expand Down Expand Up @@ -152,7 +151,7 @@ public function crawlLogsCrawlingResults(): void

$this->guzzleClientFactory->handler->append(
new Core\Http\Response(),
new Exception()
new \Exception()
);

$urls = [
Expand Down
3 changes: 1 addition & 2 deletions Tests/Functional/Crawler/OutputtingUserAgentCrawlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use EliasHaeussler\TransientLogger;
use EliasHaeussler\Typo3Warming as Src;
use EliasHaeussler\Typo3Warming\Tests;
use Exception;
use PHPUnit\Framework;
use Symfony\Component\Console;
use TYPO3\CMS\Core;
Expand Down Expand Up @@ -160,7 +159,7 @@ public function crawlLogsCrawlingResults(): void

$this->guzzleClientFactory->handler->append(
new Core\Http\Response(),
new Exception()
new \Exception()
);

$urls = [
Expand Down
Loading

0 comments on commit dc3c92d

Please sign in to comment.