Skip to content

Commit

Permalink
chore: preparations for typo3 v12
Browse files Browse the repository at this point in the history
  • Loading branch information
tlayh committed Jul 2, 2024
1 parent bbc84ed commit dd96faf
Show file tree
Hide file tree
Showing 31 changed files with 74 additions and 70 deletions.
18 changes: 5 additions & 13 deletions .code-quality/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ parameters:
message: "#^Comparison operation \"\\<\" between int\\<1, max\\> and 1 is always false\\.$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php
-
message: "#^Result of \\|\\| is always false\\.$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php
-
message: "#^Call to an undefined static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:sysLog\\(\\)\\.$#"
count: 1
Expand All @@ -32,22 +28,14 @@ parameters:
message: "#^Anonymous variable in a `\\$GLOBALS\\['TYPO3_REQUEST'\\]\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variable in a `\\$site\\-\\>getBase\\(\\)\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variables in a \"\\$GLOBALS\\['TSFE'\\]\\-\\>\\.\\.\\.\" property fetch can lead to false dead property\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variables in a \"\\$GLOBALS\\['TSFE'\\]\\-\\>tmpl\\-\\>\\.\\.\\.\" property fetch can lead to false dead property\\. Make sure the variable type is known$#"
count: 1
path: ../Classes/System/Configuration/TypoScriptConfiguration.php

-
message: "#^Anonymous variable in a `\\$GLOBALS\\['TSFE'\\]\\-\\>\\.\\.\\.\\(\\)` method call can lead to false dead methods\\. Make sure the variable type is known$#"
count: 2
Expand All @@ -59,4 +47,8 @@ parameters:
-
message: "#^On passing a constant, the method should have an enum type\\. See https\\://phpstan\\.org/writing\\-php\\-code/phpdoc\\-types\\#literals\\-and\\-constants$#"
count: 1
path: ../Classes/Api/Url.php
path: ../Classes/Api/Url.php
-
message: "#^Unable to resolve the template type T in call to method static method TYPO3\\\\CMS\\\\Core\\\\Utility\\\\GeneralUtility\\:\\:makeInstance\\(\\)$#"
count: 1
path: ../Classes/System/Factory/AbstractDeclarationBasedFactory.php
15 changes: 1 addition & 14 deletions .code-quality/rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,21 @@
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;
use Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector;
use Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector;
use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector;
use Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector;
use Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector;
use Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector;
use Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
use Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector;
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;
use Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector;
use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector;
use Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector;
Expand All @@ -58,7 +52,6 @@
SetList::EARLY_RETURN,
SetList::PRIVATIZATION,
SetList::TYPE_DECLARATION,
SetList::PHP_74,
SetList::PHP_80,
SetList::PHP_81,
SetList::PHP_82,
Expand All @@ -70,14 +63,8 @@
])
->withSkip([
RecastingRemovalRector::class,
PostIncDecToPreIncDecRector::class,
FinalizeClassesWithoutChildrenRector::class,
ChangeAndIfToEarlyReturnRector::class,
IssetOnPropertyObjectToPropertyExistsRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
RenameVariableToMatchNewTypeRector::class,
AddLiteralSeparatorToNumberRector::class,
RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class,
ClassPropertyAssignToConstructorPromotionRector::class,
ArgumentAdderRector::class,
RemoveExtraParametersRector::class,
Expand All @@ -87,4 +74,4 @@
])
->withAutoloadPaths([__DIR__ . '/../Classes'])
->withCache('.cache/rector/default')
->withImportNames(false);
->withImportNames(false);
3 changes: 0 additions & 3 deletions Classes/Content/Scraper/Html/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public function scrape(string $content): ?Collection
return $this->getAssets('img', 'src', $content)
->merge($this->getAssets('image', 'href', $content))
->merge($this->getAssets('link', 'href', $content, [
'type' => 'image/webp',
'type' => 'image/png',
'type' => 'image/jpeg',
'type' => 'image/gif',
]));
}
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function replaceAssets(): void
$distributionAlgorithmKey = '';
try {
$distributionAlgorithmKey = $this->configurationProvider->getDistributionAlgorithmKey();
} catch (Exception $exception) {
} catch (Exception) {
}

$distributionAlgorithm = $this->distributionAlgorithmFactory->buildDistributionAlgorithmFromKey($distributionAlgorithmKey);
Expand Down
23 changes: 7 additions & 16 deletions Classes/Domain/Model/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,12 @@ private function getProtocolPrefix(): string
$protocol = $this->getRequestProtocol();
}

switch ($protocol) {
case self::PROTOCOL_MARKER:
$protocolPrefix = $this->protocolMarker;
break;
case self::PROTOCOL_WILDCARD:
$protocolPrefix = '//';
break;
case self::PROTOCOL_HTTP:
$protocolPrefix = 'http://';
break;
case self::PROTOCOL_HTTPS:
$protocolPrefix = 'https://';
break;
}

return $protocolPrefix;
return match ($protocol) {
self::PROTOCOL_MARKER => $this->protocolMarker,
self::PROTOCOL_WILDCARD => '//',
self::PROTOCOL_HTTP => 'http://',
self::PROTOCOL_HTTPS => 'https://',
default => $protocolPrefix,
};
}
}
10 changes: 2 additions & 8 deletions Classes/Domain/Model/Server/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@ public function injectConfigurationProvider(Provider $configurationProvider): vo
{
try {
$this->protocolMarker = $configurationProvider->getServerProtocolMarker();
} catch (Exception $exception) {
} catch (Exception) {
$this->protocolMarker = '';
}
}

/**
* @param string $identifier
* @param string $domain
* @param string $protocol
* @return \Aoe\Asdis\Domain\Model\Server
*/
public function createServer($identifier, $domain, $protocol)
public function createServer(string $identifier, string $domain, string $protocol): Server
{
$server = GeneralUtility::makeInstance(Server::class);
$server->setIdentifier($identifier);
Expand Down
2 changes: 1 addition & 1 deletion Classes/System/Configuration/TypoScriptConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getSetting($key, $validateType = '', $hasSubkeys = false)
}

$parts = explode('.', $key);
if (!is_array($parts) || count($parts) < 1) {
if (count($parts) < 1) {
throw new TypoScriptSettingNotExists($key, 1_372_050_700_894);
}

Expand Down
2 changes: 1 addition & 1 deletion Classes/System/Uri/Filter/ChainFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private function initialize(): void
}

/**
* @return \Aoe\Asdis\System\Uri\Filter\FilterInterface
* @return FilterInterface
*/
private function buildFilter(string $filterKey)
{
Expand Down
2 changes: 1 addition & 1 deletion Classes/System/Uri/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function normalizePath(string $path): string
{
// Fix for wildcard protocol URLs, as parse_url (until PHP 5.4.7) requires the protocol to be set
// @see http://www.php.net/manual/en/function.parse-url.php
if (substr($path, 0, 2) === '//') {
if (str_starts_with($path, '//')) {
$path = 'http:' . $path;
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Replacement/MapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class MapTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->map = new Map();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Replacement/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ProcessorTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->processor = new Processor();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Scraper/Css/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class UrlTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->url = new Url();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Scraper/Extractor/XmlTagAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class XmlTagAttributeTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->extractor = new XmlTagAttribute();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Scraper/Html/Css3ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class Css3ImageTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$xmlTagAttributeExtractor = new XmlTagAttribute();
$factory = new Factory();

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Scraper/Html/CssAttributeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CssAttributeTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->cssAttribute = new CssAttribute();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Scraper/Html/CssInlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CssInlineTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->scraper = new CssInline();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Content/Scraper/Html/SrcsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class SrcsetTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$xmlTagAttributeExtractor = new XmlTagAttribute();
$factory = new Factory();

Expand Down
2 changes: 2 additions & 0 deletions Tests/Domain/Model/AssetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class AssetTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->asset = new Asset();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class HashBasedGroupsTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->algorithm = new HashBasedGroups();
}

Expand Down Expand Up @@ -42,8 +44,8 @@ public function testDistribute(): void

$this->algorithm->distribute($assets, $servers);

$this->assertSame(Server::class, $asset1->getServer() !== null ? get_class($asset1->getServer()) : self::class);
$this->assertSame(Server::class, $asset2->getServer() !== null ? get_class($asset2->getServer()) : self::class);
$this->assertSame(Server::class, $asset3->getServer() !== null ? get_class($asset3->getServer()) : self::class);
$this->assertSame(Server::class, $asset1->getServer() !== null ? $asset1->getServer()::class : self::class);
$this->assertSame(Server::class, $asset2->getServer() !== null ? $asset2->getServer()::class : self::class);
$this->assertSame(Server::class, $asset3->getServer() !== null ? $asset3->getServer()::class : self::class);
}
}
2 changes: 2 additions & 0 deletions Tests/Domain/Model/DistributionAlgorithm/RoundRobinTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class RoundRobinTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->algorithm = new RoundRobin();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Domain/Model/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ServerTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->server = new Server();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/Domain/Repository/ServerRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class ServerRepositoryTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->serverRepository = new ServerRepository();
}

Expand Down
7 changes: 5 additions & 2 deletions Tests/System/Configuration/TypoScriptConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@
use Aoe\Asdis\System\Configuration\Exception\InvalidTypoScriptSetting;
use Aoe\Asdis\System\Configuration\Exception\TypoScriptSettingNotExists;
use Aoe\Asdis\System\Configuration\TypoScriptConfiguration;
use PHPUnit\Framework\MockObject\MockObject;
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;

class TypoScriptConfigurationTest extends UnitTestCase
{
/**
* @var (\PHPUnit\Framework\MockObject\MockObject & \TypoScriptConfiguration)
* @var @var MockObject&\TypoScriptConfiguration
*/
private \PHPUnit\Framework\MockObject\MockObject $typoScriptConfiguration;
private MockObject $typoScriptConfiguration;

/**
* (non-PHPdoc)
*/
protected function setUp(): void
{
parent::setUp();

$this->typoScriptConfiguration = $this->getMockBuilder(TypoScriptConfiguration::class)
->onlyMethods(['getTypoScriptConfigurationArray'])
->getMock();
Expand Down
2 changes: 2 additions & 0 deletions Tests/System/Uri/Filter/BubblingPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class BubblingPathTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->filter = new BubblingPath();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/System/Uri/Filter/ChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ChainTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->chain = new Chain();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/System/Uri/Filter/ContainsInlineDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ContainsInlineDataTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->filter = new ContainsInlineData();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/System/Uri/Filter/ContainsProtocolTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ContainsProtocolTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->filter = new ContainsProtocol();
}

Expand Down
2 changes: 2 additions & 0 deletions Tests/System/Uri/Filter/TooShortTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class TooShortTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();

$this->filter = new TooShort();
}

Expand Down
Loading

0 comments on commit dd96faf

Please sign in to comment.