diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 002547ccedd..8dca798b0b6 100755 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -13,12 +13,12 @@ email, or any other method with the owners of this repository before making a ch ## Making Changes * Create a topic branch from where you want to base your work. - * This is usually the master branch. + * This is usually the main branch. * Only target release branches if you are certain your fix must be on that branch. - * To quickly create a topic branch based on master; `git checkout -b - fix/master/my_contribution master`. Please avoid working directly on the - `master` branch. + * To quickly create a topic branch based on main; `git checkout -b + fix/main/my_contribution main`. Please avoid working directly on the + `main` branch. * Make commits of logical units. * Make sure your commit messages are in the proper format. Use either `[TASK]`, `[FEATURE]`, `[BUGFIX]` or `[DOC]` @@ -41,5 +41,5 @@ For changes of a trivial nature, it is not always necessary to create a new issu ## Additional resources -* [Documentation](https://github.com/lochmueller/staticfilecache/tree/master/Documentation) +* [Documentation](https://github.com/lochmueller/staticfilecache/tree/main/Documentation) * [How to Write a Git Commit Message](http://chris.beams.io/posts/git-commit/) diff --git a/Classes/Cache/StaticDatabaseBackend.php b/Classes/Cache/StaticDatabaseBackend.php index 36002aef2d2..1064a63bc30 100644 --- a/Classes/Cache/StaticDatabaseBackend.php +++ b/Classes/Cache/StaticDatabaseBackend.php @@ -74,10 +74,8 @@ public function getTableDefinitions() /** * Get the real life time. - * - * @param int $lifetime */ - protected function getRealLifetime($lifetime): int + protected function getRealLifetime(?int $lifetime): int { if (null === $lifetime) { $lifetime = $this->defaultLifetime; diff --git a/Classes/Cache/StaticFileBackend.php b/Classes/Cache/StaticFileBackend.php index 549eaf93720..591876d0abf 100644 --- a/Classes/Cache/StaticFileBackend.php +++ b/Classes/Cache/StaticFileBackend.php @@ -45,7 +45,7 @@ public function __construct($context, array $options = []) * Saves data in the cache. * * @param string $entryIdentifier An identifier for this specific cache entry - * @param ResponseInterface $data The data to be stored + * @param string $data The data to be stored * @param array $tags Tags to associate with this cache entry * @param int $lifetime Lifetime of this cache entry in seconds * @@ -54,6 +54,7 @@ public function __construct($context, array $options = []) */ public function set($entryIdentifier, $data, array $tags = [], $lifetime = null): void { + /** @var ResponseInterface $data */ $realLifetime = $this->getRealLifetime($lifetime); $time = (new DateTimeService())->getCurrentTime(); $databaseData = [ diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index 45ef1b8281d..f2e8cbc0d73 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -6,6 +6,7 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; +use SFC\Staticfilecache\Cache\UriFrontend; use TYPO3\CMS\Backend\Template\Components\Menu\Menu; use TYPO3\CMS\Backend\Template\Components\Menu\MenuItem; use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; @@ -33,7 +34,8 @@ class BackendController extends ActionController implements LoggerAwareInterface public function __construct( readonly protected QueueService $queueService, readonly protected ModuleTemplateFactory $moduleTemplateFactory, - readonly protected ConfigurationService $configurationService + readonly protected ConfigurationService $configurationService, + readonly protected CacheService $cacheService, ) {} public function listAction(string $filter = ''): ResponseInterface @@ -124,7 +126,8 @@ protected function getCachePagesEntries(string $filter): array $rows = []; try { - $cache = GeneralUtility::makeInstance(CacheService::class)->get(); + /** @var UriFrontend $cache */ + $cache = $this->cacheService->get(); } catch (\Exception $exception) { $this->logger->error('Problems by fetching the cache: ' . $exception->getMessage() . ' / ' . $exception->getFile() . ':' . $exception->getLine()); diff --git a/Classes/Domain/Repository/QueueRepository.php b/Classes/Domain/Repository/QueueRepository.php index 0722aba2d9e..775a41ae108 100644 --- a/Classes/Domain/Repository/QueueRepository.php +++ b/Classes/Domain/Repository/QueueRepository.php @@ -45,7 +45,7 @@ public function countOpenByIdentifier($identifier): int /** * Find old entries. - * @return iterable + * @return iterable */ public function findOldUids(): iterable { diff --git a/Classes/Middleware/GenerateMiddleware.php b/Classes/Middleware/GenerateMiddleware.php index bfe2cbb8221..744243c05d4 100644 --- a/Classes/Middleware/GenerateMiddleware.php +++ b/Classes/Middleware/GenerateMiddleware.php @@ -4,6 +4,7 @@ namespace SFC\Staticfilecache\Middleware; +use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Context\Context; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Http\Message\ResponseInterface; @@ -24,13 +25,14 @@ class GenerateMiddleware implements MiddlewareInterface { - protected ?UriFrontend $cache = null; + protected ?FrontendInterface $cache = null; protected ServerRequestInterface $request; public function __construct( readonly protected EventDispatcherInterface $eventDispatcher, readonly protected CookieService $cookieService, - readonly protected Typo3Version $typo3Version + readonly protected Typo3Version $typo3Version, + readonly protected CacheService $cacheService ) {} /** @@ -54,7 +56,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface } try { - $this->cache = GeneralUtility::makeInstance(CacheService::class)->get(); + $this->cache = $this->cacheService->get(); } catch (\Exception $exception) { return $this->removeSfcHeaders($response); } diff --git a/Classes/Service/CacheService.php b/Classes/Service/CacheService.php index 8e713fc703f..b9013b92d7e 100644 --- a/Classes/Service/CacheService.php +++ b/Classes/Service/CacheService.php @@ -9,6 +9,7 @@ use SFC\Staticfilecache\Domain\Repository\QueueRepository; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException; +use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -20,7 +21,7 @@ class CacheService * * @throws NoSuchCacheException */ - public function get(): UriFrontend + public function get(): FrontendInterface { return $this->getManager()->getCache('staticfilecache'); } diff --git a/Classes/Service/ClientService.php b/Classes/Service/ClientService.php index 9d2f584f780..720f8f4f65a 100644 --- a/Classes/Service/ClientService.php +++ b/Classes/Service/ClientService.php @@ -76,7 +76,7 @@ protected function getCallableClient(string $domain): Client $httpOptions['verify'] = filter_var($httpOptions['verify'], FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) ?? $httpOptions['verify']; if (isset($httpOptions['handler']) && \is_array($httpOptions['handler'])) { $stack = HandlerStack::create(); - foreach ($httpOptions['handler'] ?? [] as $handler) { + foreach ($httpOptions['handler'] as $handler) { $stack->push($handler); } $httpOptions['handler'] = $stack; diff --git a/Classes/Service/InlineAssets/InlineFavIcon.php b/Classes/Service/InlineAssets/InlineFavIcon.php index b822364a13d..76d38850d6a 100644 --- a/Classes/Service/InlineAssets/InlineFavIcon.php +++ b/Classes/Service/InlineAssets/InlineFavIcon.php @@ -14,7 +14,7 @@ class InlineFavIcon extends AbstractInlineAssets /** * FavIcon extensions. */ - private $favIconExtensions = ['svg', 'ico', 'png']; + private array $favIconExtensions = ['svg', 'ico', 'png']; /** * Check if the class can handle the file extension. diff --git a/Classes/Service/InlineAssets/InlineImages.php b/Classes/Service/InlineAssets/InlineImages.php index 7d3bc1f216e..2294942fd18 100644 --- a/Classes/Service/InlineAssets/InlineImages.php +++ b/Classes/Service/InlineAssets/InlineImages.php @@ -14,7 +14,7 @@ class InlineImages extends AbstractInlineAssets /** * Image extensions. */ - private $imageExtensions = ['png', 'jpg', 'jpeg']; + private array $imageExtensions = ['png', 'jpg', 'jpeg']; /** * Check if the class can handle the file extension. diff --git a/Classes/Service/InlineAssets/InlineStyles.php b/Classes/Service/InlineAssets/InlineStyles.php index 16e35097d3f..f472dff1f22 100644 --- a/Classes/Service/InlineAssets/InlineStyles.php +++ b/Classes/Service/InlineAssets/InlineStyles.php @@ -14,12 +14,12 @@ class InlineStyles extends AbstractInlineAssets /** * Image extensions. */ - private $imageExtensions = ['ico', 'png', 'jpg', 'jpeg']; + private array $imageExtensions = ['ico', 'png', 'jpg', 'jpeg']; /** * Font extensions. */ - private $fontExtensions = ['woff', 'woff2']; + private array $fontExtensions = ['woff', 'woff2']; /** * Check if the class can handle the file extension. diff --git a/phpstan.neon b/phpstan.neon index 504925c990f..7f692f5f0ee 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,5 +3,5 @@ includes: - .Build/vendor/andersundsehr/phpstan-git-files/extension.php parameters: - level: 2 + level: 5 reportUnmatchedIgnoredErrors: false