Skip to content

Commit

Permalink
[TASK] Apply rector ruleset for TYPO3 v13
Browse files Browse the repository at this point in the history
  • Loading branch information
fnagel committed Dec 29, 2024
1 parent b7d970f commit 6f539f5
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 52 deletions.
3 changes: 2 additions & 1 deletion Classes/Domain/Model/AbstractSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* LICENSE.txt file that was distributed with this source code.
*/

use TYPO3\CMS\Core\Crypto\HashService;
use FelixNagel\T3extblog\Validation\Validator\PrivacyPolicyValidator;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Annotation as Extbase;
Expand Down Expand Up @@ -87,7 +88,7 @@ protected function createCode(): void
/** @noinspection NonSecureUniqidUsageInspection */
$input = $this->email.$now->getTimestamp().uniqid();

$this->code = substr(GeneralUtility::hmac($input), 0, 32);
$this->code = substr(GeneralUtility::makeInstance(HashService::class)->hmac($input, ''), 0, 32);
}

public function hasPrivacyPolicyAccepted(): bool
Expand Down
7 changes: 6 additions & 1 deletion Classes/Utility/TcaUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,19 @@ public static function addFlexForm(string $pluginName, string $flexFormFilePath)
{
$pluginSignature = self::getPluginSignature($pluginName);


// @todo Remove this in TYPO3 v14!
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist'][$pluginSignature] = 'pi_flexform';
ExtensionManagementUtility::addPiFlexFormValue(
$pluginSignature,
'FILE:EXT:'.self::$packageKey.$flexFormFilePath
);
}


/**
* @todo Remove this in TYPO3 v14!
* @deprecated in TYPO3 13.4
*/
protected static function disablePluginDefaultFields(string $pluginSignature): void
{
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist'][$pluginSignature] = 'pages, recursive';
Expand Down
21 changes: 8 additions & 13 deletions Classes/ViewHelpers/Backend/LocalizationViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,15 @@
use FelixNagel\T3extblog\Domain\Model\AbstractEntity;
use FelixNagel\T3extblog\Exception\Exception;
use TYPO3\CMS\Backend\Configuration\TranslationConfigurationProvider;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;

/**
* Get localized records view helper.
*/
class LocalizationViewHelper extends AbstractBackendViewHelper
{
use CompileWithRenderStatic;

protected $escapeOutput = false;

protected static ?TranslationConfigurationProvider $translateTools = null;
Expand All @@ -45,25 +40,25 @@ public function initializeArguments()
$this->registerArgument('object', 'object', 'Object to process', true);
}

public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
public function render(): string
{
$translations = $arguments['translations'];
$table = $arguments['table'];
$object = $arguments['object'];
$translations = $this->arguments['translations'];
$table = $this->arguments['table'];
$object = $this->arguments['object'];

if (!$object instanceof AbstractEntity) {
throw new Exception('Invalid object given!', 1592862844);
}

$content = '';
$templateVariableContainer = $renderingContext->getVariableProvider();

$templateVariableContainer = $this->renderingContext->getVariableProvider();
self::$systemLanguages = self::getTranslateTools()->getSystemLanguages($object->getPid());

if (count(self::$systemLanguages) > 2) {
$records = self::getLocalizedRecords($table, $object->toArray());

$templateVariableContainer->add($translations, $records);
$content = $renderChildrenClosure();
$content = $this->renderChildren();
$templateVariableContainer->remove($translations);
}

Expand All @@ -84,7 +79,7 @@ public static function getLocalizedRecords(string $table, array $row): array
$translations = self::getTranslateTools()->translationInfo($table, $row['uid'], 0, $row);

if (is_array($translations) && is_array($translations['translations'])) {
foreach ($translations['translations'] as $sysLanguageUid => $_) {
foreach (array_keys($translations['translations']) as $sysLanguageUid) {
if (!$GLOBALS['BE_USER']->checkLanguageAccess($sysLanguageUid)) {
continue;
}
Expand Down
14 changes: 4 additions & 10 deletions Classes/ViewHelpers/Frontend/BackendUserAvatarViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,13 @@
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;

/**
* Get avatar for backend user.
*/
class BackendUserAvatarViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;

public function initializeArguments()
{
$this->registerArgument('uid', 'string', 'Uid of the backend user');
Expand All @@ -33,14 +29,12 @@ public function initializeArguments()

/**
* Render the avatar image.
*
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
public function render(): string
{
$uid = $arguments['uid'];
$size = $arguments['size'];
$default = $arguments['default'];
$uid = $this->arguments['uid'];
$size = $this->arguments['size'];
$default = $this->arguments['default'];
$url = self::getAvatarUrl($uid, $size);

if ($url !== null) {
Expand Down
12 changes: 3 additions & 9 deletions Classes/ViewHelpers/Frontend/TitleTagViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,30 @@

use FelixNagel\T3extblog\Seo\PageTitleProvider;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
use TYPO3\CMS\Core\Http\ApplicationType;

/**
* ViewHelper to render the page title.
*/
class TitleTagViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;

public function initializeArguments()
{
$this->registerArgument('prepend', 'bool', 'Prepend to the existing page path title', false, true);
}

/**
* Override the title tag.
*
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
public function render(): void
{
if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isBackend()) {
return;
}

$prepend = $arguments['prepend'];
$content = $renderChildrenClosure();
$prepend = $this->arguments['prepend'];
$content = $this->renderChildren();

if (!empty($content)) {
$titleProvider = GeneralUtility::makeInstance(PageTitleProvider::class);
Expand Down
16 changes: 5 additions & 11 deletions Classes/ViewHelpers/Frontend/Uri/ActionViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;

/**
* A view helper for creating URIs to extbase actions.
Expand All @@ -28,8 +27,6 @@
*/
class ActionViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;

public function initializeArguments(): void
{
$this->registerArgument('action', 'string', 'Target action');
Expand All @@ -49,21 +46,18 @@ public function initializeArguments(): void
$this->registerArgument('argumentsToBeExcludedFromQueryString', 'array', 'arguments to be removed from the URI. Only active if $addQueryString = TRUE', false, []);
}

/**
* @SuppressWarnings("PHPMD.UnusedFormalParameter")
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string
public function render(): string
{
/** @var RenderingContext $renderingContext */
$request = $renderingContext->getRequest();
$request = $this->renderingContext->getRequest();
if (!$request instanceof RequestInterface) {
throw new Exception(
'ViewHelper t3b:uri.action can be used only in extbase context and needs a request implementing extbase RequestInterface.',
1639819692
);
}

return self::renderStaticFrontend($arguments, $renderingContext);
return self::renderFrontend($this->arguments, $this->renderingContext);
}

/**
Expand All @@ -75,10 +69,10 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl
* @SuppressWarnings("PHPMD.NPathComplexity")
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @see \TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper::renderStatic
* @see \TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper::render
* @return string
*/
protected static function renderStaticFrontend(array $arguments, RenderingContext $renderingContext)
protected static function renderFrontend(array $arguments, RenderingContextInterface $renderingContext)
{
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.5",
"friendsofphp/php-cs-fixer": "^3.12",
"phpmd/phpmd": "^2.8",
"friendsofphp/php-cs-fixer": "^3.64",
"phpmd/phpmd": "^2.15",
"php-parallel-lint/php-parallel-lint": "^1.3",
"helmich/typo3-typoscript-lint": "^3.2",
"ssch/typo3-rector": "^2.3"
"ssch/typo3-rector": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down
6 changes: 2 additions & 4 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Rector\ValueObject\PhpVersion;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
use Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
Expand All @@ -26,9 +25,9 @@
$rectorConfig->sets([
SetList::CODING_STYLE,
SetList::CODE_QUALITY,
LevelSetList::UP_TO_PHP_82,
LevelSetList::UP_TO_PHP_83,

Typo3LevelSetList::UP_TO_TYPO3_12,
Typo3LevelSetList::UP_TO_TYPO3_13,
Typo3SetList::TYPO3_13,
]);

Expand All @@ -42,7 +41,6 @@
CountArrayToEmptyArrayComparisonRector::class,
AddLiteralSeparatorToNumberRector::class,
SymplifyQuoteEscapeRector::class,
FinalizePublicClassConstantRector::class,
CatchExceptionNameMatchingTypeRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
NullToStrictStringFuncCallArgRector::class,
Expand Down

0 comments on commit 6f539f5

Please sign in to comment.