Skip to content

Commit

Permalink
Fix PHPStan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Sep 29, 2024
1 parent ebd3f40 commit 830faee
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
6 changes: 5 additions & 1 deletion Classes/Generator/BrotliGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
namespace SFC\Staticfilecache\Generator;

use Psr\Http\Message\ResponseInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use SFC\Staticfilecache\Event\GeneratorCreate;
use SFC\Staticfilecache\Event\GeneratorRemove;
use SFC\Staticfilecache\Service\RemoveService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class BrotliGenerator extends AbstractGenerator
class BrotliGenerator extends AbstractGenerator implements LoggerAwareInterface
{
use LoggerAwareTrait;

public function generate(GeneratorCreate $generatorCreateEvent): void
{
if (!$this->checkAvailable()) {
Expand Down
19 changes: 14 additions & 5 deletions Classes/Middleware/GenerateMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use SFC\Staticfilecache\Service\ConfigurationService;
use SFC\Staticfilecache\Service\CookieService;
use SFC\Staticfilecache\Service\DateTimeService;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Event\AfterCachedPageIsPersistedEvent;
Expand All @@ -24,10 +25,12 @@
class GenerateMiddleware implements MiddlewareInterface
{
protected ?UriFrontend $cache = null;
protected ServerRequestInterface $request;

public function __construct(
protected EventDispatcherInterface $eventDispatcher,
protected CookieService $cookieService
readonly protected EventDispatcherInterface $eventDispatcher,
readonly protected CookieService $cookieService,
readonly protected Typo3Version $typo3Version
) {}

/**
Expand All @@ -39,6 +42,7 @@ public function __construct(
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$this->request = $request;
$response = $handler->handle($request);

if (!$response->hasHeader('X-SFC-Cachable')) {
Expand Down Expand Up @@ -90,9 +94,14 @@ protected function calculateLifetime(TypoScriptFrontendController $tsfe): int
// @todo migrate for v13 to Events
// Check ModifyCacheLifetimeForPageEvent & AfterCachedPageIsPersistedEvent

// @phpstan-ignore-next-line
// @todo check this Line!!!
$timeOutTime = $tsfe->get_cache_timeout();
if ($this->typo3Version->getMajorVersion() >= 13) {
/* @phpstan-ignore-next-line */
$timeOutTime = $tsfe->get_cache_timeout($this->request);
} else {
/* @phpstan-ignore-next-line */
$timeOutTime = $tsfe->get_cache_timeout();
}


// If page has a endtime before the current timeOutTime, use it instead:
if ($tsfe->page['endtime'] > 0 && ($tsfe->page['endtime'] - $GLOBALS['EXEC_TIME']) < $timeOutTime) {
Expand Down
6 changes: 5 additions & 1 deletion Classes/Service/ClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
use GuzzleHttp\Cookie\SetCookie;
use GuzzleHttp\HandlerStack;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use SFC\Staticfilecache\Event\BuildClientEvent;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class ClientService extends AbstractService
class ClientService extends AbstractService implements LoggerAwareInterface
{
use LoggerAwareTrait;

protected const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0';

public function __construct(protected EventDispatcherInterface $eventDispatcher) {}
Expand Down
6 changes: 5 additions & 1 deletion Classes/Service/CookieService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

namespace SFC\Staticfilecache\Service;

use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use SFC\Staticfilecache\Service\DateTimeService;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Handle cookie related stuff.
*/
class CookieService extends AbstractService
class CookieService extends AbstractService implements LoggerAwareInterface
{
use LoggerAwareTrait;

public const SESSION_LIFETIME = 0;

/**
Expand Down
6 changes: 5 additions & 1 deletion Classes/Service/QueueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace SFC\Staticfilecache\Service;

use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException;
use SFC\Staticfilecache\Command\BoostQueueCommand;
use SFC\Staticfilecache\Domain\Repository\QueueRepository;
Expand All @@ -13,8 +15,10 @@
*
* @see BoostQueueCommand
*/
class QueueService extends AbstractService
class QueueService extends AbstractService implements LoggerAwareInterface
{
use LoggerAwareTrait;

public const PRIORITY_HIGH = 2000;
public const PRIORITY_MEDIUM = 1000;
public const PRIORITY_LOW = 0;
Expand Down

0 comments on commit 830faee

Please sign in to comment.