From a24b71dfc716f9957f5d2cb1689cd221170a0ddc Mon Sep 17 00:00:00 2001 From: David Brauer Date: Tue, 18 Apr 2023 14:29:09 +0200 Subject: [PATCH] [TASK] Manual fixes for v11 --- Classes/Analyzers/AbstractAnalyzer.php | 2 +- Classes/Analyzers/NewsAnalyzer.php | 5 +- Classes/Analyzers/PageContentAnalyzer.php | 5 +- .../AbstractCheckUrlGenerator.php | 4 +- Classes/CheckUrlGenerators/NewsDetail.php | 4 +- Classes/CheckUrlGenerators/Page.php | 2 +- Classes/CheckUrlGenerators/PageContent.php | 9 ++-- Classes/Command/PresetByPageUidCommand.php | 2 +- Classes/Controller/A11yCheckController.php | 51 +++++++++---------- .../Controller/ContentElementsController.php | 2 +- Classes/Domain/Model/Dto/CheckDemand.php | 15 ++++-- .../Domain/Model/Dto/SingleTableDemand.php | 8 ++- .../TypeConverter/PresetTypeConverter.php | 20 ++++---- Classes/Service/PresetService.php | 5 +- Classes/Service/ResultsService.php | 10 +--- Classes/Tests/AbstractTest.php | 10 ++-- Resources/Private/Partials/Results.html | 4 +- .../Tests/Utility/Tests/LinkUtilityTest.php | 6 --- composer.json | 5 +- 19 files changed, 76 insertions(+), 93 deletions(-) diff --git a/Classes/Analyzers/AbstractAnalyzer.php b/Classes/Analyzers/AbstractAnalyzer.php index 080e850..ed78799 100644 --- a/Classes/Analyzers/AbstractAnalyzer.php +++ b/Classes/Analyzers/AbstractAnalyzer.php @@ -18,7 +18,7 @@ abstract class AbstractAnalyzer implements AnalyzerInterface { final const TYPE_INTERNAL = 'internal'; - protected string $type = ''; + protected string $type = ''; /** * @var array diff --git a/Classes/Analyzers/NewsAnalyzer.php b/Classes/Analyzers/NewsAnalyzer.php index 179e450..bf70761 100644 --- a/Classes/Analyzers/NewsAnalyzer.php +++ b/Classes/Analyzers/NewsAnalyzer.php @@ -13,10 +13,7 @@ */ class NewsAnalyzer extends AbstractAnalyzer { - /** - * @var string - */ - protected $type = AbstractAnalyzer::TYPE_INTERNAL; + protected string $type = AbstractAnalyzer::TYPE_INTERNAL; /** * Return an aray of news record Uids to check diff --git a/Classes/Analyzers/PageContentAnalyzer.php b/Classes/Analyzers/PageContentAnalyzer.php index 0935ec2..c2a4ebb 100644 --- a/Classes/Analyzers/PageContentAnalyzer.php +++ b/Classes/Analyzers/PageContentAnalyzer.php @@ -9,10 +9,7 @@ */ class PageContentAnalyzer extends AbstractAnalyzer { - /** - * @var string - */ - protected $type = AbstractAnalyzer::TYPE_INTERNAL; + protected string $type = AbstractAnalyzer::TYPE_INTERNAL; /** * Return an aray of page record Uids to check diff --git a/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php b/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php index c80fe6a..ffa15b9 100644 --- a/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php +++ b/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php @@ -10,9 +10,9 @@ abstract class AbstractCheckUrlGenerator { /** - * @var array + * @var array[] */ - protected $requiredConfiguration = []; + protected array $requiredConfiguration = []; protected string $tableName = ''; diff --git a/Classes/CheckUrlGenerators/NewsDetail.php b/Classes/CheckUrlGenerators/NewsDetail.php index 3ac87c4..cc15c0a 100644 --- a/Classes/CheckUrlGenerators/NewsDetail.php +++ b/Classes/CheckUrlGenerators/NewsDetail.php @@ -12,9 +12,9 @@ class NewsDetail extends AbstractCheckUrlGenerator { /** - * @var array + * @var array[] */ - protected $requiredConfiguration = ['targetPid']; + protected array $requiredConfiguration = ['targetPid']; /** * @var int diff --git a/Classes/CheckUrlGenerators/Page.php b/Classes/CheckUrlGenerators/Page.php index dfb9138..51a7f33 100644 --- a/Classes/CheckUrlGenerators/Page.php +++ b/Classes/CheckUrlGenerators/Page.php @@ -13,7 +13,7 @@ class Page extends AbstractCheckUrlGenerator /** * Page constructor. * - * @param array $configuration + * @param array[] $configuration */ public function __construct(array $configuration) { diff --git a/Classes/CheckUrlGenerators/PageContent.php b/Classes/CheckUrlGenerators/PageContent.php index 0a90c36..28391e5 100644 --- a/Classes/CheckUrlGenerators/PageContent.php +++ b/Classes/CheckUrlGenerators/PageContent.php @@ -12,14 +12,11 @@ class PageContent extends AbstractCheckUrlGenerator { /** - * @var array + * @var array[] */ - protected $requiredConfiguration = ['targetPid']; + protected array $requiredConfiguration = ['targetPid']; - /** - * @var int - */ - protected $targetPid = 0; + protected int $targetPid = 0; protected array $ignoredContentTypes = []; diff --git a/Classes/Command/PresetByPageUidCommand.php b/Classes/Command/PresetByPageUidCommand.php index ea77c45..4e73480 100644 --- a/Classes/Command/PresetByPageUidCommand.php +++ b/Classes/Command/PresetByPageUidCommand.php @@ -3,6 +3,7 @@ declare(strict_types=1); namespace UniWue\UwA11yCheck\Command; +use TYPO3\CMS\Extbase\Object\ObjectManager; use UniWue\UwA11yCheck\Check\Preset; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -10,7 +11,6 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; use UniWue\UwA11yCheck\Check\Result\Impact; use UniWue\UwA11yCheck\Check\ResultSet; use UniWue\UwA11yCheck\Service\PresetService; diff --git a/Classes/Controller/A11yCheckController.php b/Classes/Controller/A11yCheckController.php index e59c169..ad2de09 100644 --- a/Classes/Controller/A11yCheckController.php +++ b/Classes/Controller/A11yCheckController.php @@ -17,7 +17,10 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\View\ViewInterface; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; +use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Extbase\Property\TypeConverter\PersistentObjectConverter; +use TYPO3\CMS\Extbase\Utility\DebuggerUtility; +use TYPO3\CMS\Fluid\View\TemplateView; use UniWue\UwA11yCheck\Domain\Model\Dto\CheckDemand; use UniWue\UwA11yCheck\Service\PresetService; use UniWue\UwA11yCheck\Service\ResultsService; @@ -30,12 +33,23 @@ class A11yCheckController extends ActionController final const LANG_CORE = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:'; final const LANG_LOCAL = 'LLL:EXT:uw_a11y_check/Resources/Private/Language/locallang.xlf:'; + protected PresetService $presetService; + + private ModuleTemplateFactory $moduleTemplateFactory; + + /** - * @var PresetService + * The current page uid */ - protected $presetService; - public function __construct(private ModuleTemplateFactory $moduleTemplateFactory) + protected int $pid = 0; + + protected IconFactory $iconFactory; + + protected ResultsService $resultsService; + + public function __construct(ModuleTemplateFactory $moduleTemplateFactory) { + $this->moduleTemplateFactory = $moduleTemplateFactory; } public function injectPresetService(PresetService $presetService): void @@ -43,23 +57,6 @@ public function injectPresetService(PresetService $presetService): void $this->presetService = $presetService; } - /** - * The current page uid - * - * @var int - */ - protected $pid = 0; - - /** - * @var IconFactory - */ - protected $iconFactory; - - /** - * @var ResultsService - */ - protected $resultsService; - /** * Set up the doc header properly here */ @@ -70,10 +67,10 @@ protected function initializeView(ViewInterface $view): void parent::initializeView($view); $this->iconFactory = GeneralUtility::makeInstance(IconFactory::class); - $this->resultsService = $this->objectManager->get(ResultsService::class); + $this->resultsService =GeneralUtility::makeInstance(ObjectManager::class)->get(ResultsService::class); $moduleTemplate->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); - if ($view instanceof BackendTemplateView) { + if ($view instanceof TemplateView) { $moduleTemplate->getPageRenderer()->addCssFile( 'EXT:uw_a11y_check/Resources/Public/Css/a11y_check.css' ); @@ -94,10 +91,9 @@ public function initializeAction(): void /** * Index action * - * @param CheckDemand $checkDemand * @IgnoreValidation("checkDemand") */ - public function indexAction($checkDemand = null): ResponseInterface + public function indexAction(CheckDemand $checkDemand = null): ResponseInterface { $moduleTemplate = $this->moduleTemplateFactory->create($this->request); if ($checkDemand === null) { @@ -115,7 +111,6 @@ public function indexAction($checkDemand = null): ResponseInterface ] ); } - $this->view->assignMultiple([ 'checkDemand' => $checkDemand, 'presets' => $this->presetService->getPresets(), @@ -197,7 +192,7 @@ public function acknowledgeResultAction(int $pageUid): ResponseInterface protected function createMenu(): void { $moduleTemplate = $this->moduleTemplateFactory->create($this->request); - $uriBuilder = $this->objectManager->get(UriBuilder::class); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->setRequest($this->request); $menu = $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu(); @@ -229,8 +224,8 @@ protected function createDefaultButtons(): void // Shortcut if ($this->getBackendUser()->mayMakeShortcut()) { $shortcutButton = $buttonBar->makeShortcutButton() - ->setModuleName('web_UwA11yCheckTxUwa11ycheckM1') - ->setGetVariables(['route', 'module', 'id']) + ->setRouteIdentifier('web_UwA11yCheckTxUwa11ycheckM1') + ->setArguments(['route', 'module', 'id']) ->setDisplayName('Shortcut'); $buttonBar->addButton($shortcutButton, ButtonBar::BUTTON_POSITION_RIGHT); } diff --git a/Classes/Controller/ContentElementsController.php b/Classes/Controller/ContentElementsController.php index b9c3e97..ab413d8 100644 --- a/Classes/Controller/ContentElementsController.php +++ b/Classes/Controller/ContentElementsController.php @@ -34,7 +34,7 @@ public function showAction(int $pageUid, string $ignoreContentTypes, string $hma $expectedHmac = GeneralUtility::hmac($hmacString, 'page_content'); if ($expectedHmac !== $hmac) { - throw new Exception('HMAC does not match', 1_572_608_738_828); + throw new Exception('HMAC does not match', 1572608738828); } $whereCondition = 'colPos >= 0'; diff --git a/Classes/Domain/Model/Dto/CheckDemand.php b/Classes/Domain/Model/Dto/CheckDemand.php index eac5cec..1f38daf 100644 --- a/Classes/Domain/Model/Dto/CheckDemand.php +++ b/Classes/Domain/Model/Dto/CheckDemand.php @@ -10,11 +10,20 @@ */ class CheckDemand extends AbstractEntity { - protected string $analyze = ''; + /** + * @var string + */ + protected $analyze = ''; - protected ?Preset $preset = null; + /** + * @var \UniWue\UwA11yCheck\Check\Preset|null + */ + protected $preset = null; - protected int $level = 0; + /** + * @var int + */ + protected $level = 0; public function getAnalyze(): string { diff --git a/Classes/Domain/Model/Dto/SingleTableDemand.php b/Classes/Domain/Model/Dto/SingleTableDemand.php index 954a1aa..9a2d069 100644 --- a/Classes/Domain/Model/Dto/SingleTableDemand.php +++ b/Classes/Domain/Model/Dto/SingleTableDemand.php @@ -11,13 +11,17 @@ class SingleTableDemand extends AbstractEntity { /** * The tablename for the query + * + * @var int */ - protected string $tableName = ''; + protected $tableName = ''; /** * Max results of records to return. Default is 50 + * + * @var int */ - protected int $maxResults = 50; + protected $maxResults = 50; public function getTableName(): string { diff --git a/Classes/Property/TypeConverter/PresetTypeConverter.php b/Classes/Property/TypeConverter/PresetTypeConverter.php index f2def8c..e0e954d 100644 --- a/Classes/Property/TypeConverter/PresetTypeConverter.php +++ b/Classes/Property/TypeConverter/PresetTypeConverter.php @@ -2,6 +2,7 @@ namespace UniWue\UwA11yCheck\Property\TypeConverter; +use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Error\Error; use TYPO3\CMS\Extbase\Property\PropertyMappingConfigurationInterface; use TYPO3\CMS\Extbase\Property\TypeConverter\AbstractTypeConverter; @@ -13,15 +14,8 @@ */ class PresetTypeConverter extends AbstractTypeConverter { - /** - * @var PresetService - */ - protected $presetService; + protected PresetService $presetService; - public function injectConfigurationService(PresetService $presetService): void - { - $this->presetService = $presetService; - } /** * @var array @@ -38,22 +32,26 @@ public function injectConfigurationService(PresetService $presetService): void */ protected $priority = 1; + public function injectConfigurationService(PresetService $presetService): void + { + $this->presetService = $presetService; + } + /** * @param mixed $source - * @param string $targetType * @param PropertyMappingConfigurationInterface|null $configuration * @return mixed|object|Error|Preset */ public function convertFrom( $source, - $targetType, + string $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null ): Error|Preset { $preset = $this->presetService->getPresetById($source); if (!$preset instanceof Preset) { - return $this->objectManager->get(Error::class, 'Preset not found', 1_573_053_017_102); + return GeneralUtility::makeInstance(Error::class, 'Preset not found', 1573053017102); } return $preset; diff --git a/Classes/Service/PresetService.php b/Classes/Service/PresetService.php index 6722c31..960cccd 100644 --- a/Classes/Service/PresetService.php +++ b/Classes/Service/PresetService.php @@ -22,10 +22,7 @@ */ class PresetService { - /** - * @var YamlFileLoader - */ - protected $yamlFileLoader; + protected YamlFileLoader $yamlFileLoader; protected ObjectManager $objectManager; diff --git a/Classes/Service/ResultsService.php b/Classes/Service/ResultsService.php index d389a08..729e06d 100644 --- a/Classes/Service/ResultsService.php +++ b/Classes/Service/ResultsService.php @@ -13,15 +13,9 @@ */ class ResultsService { - /** - * @var SerializationService - */ - protected $serializationService; + protected SerializationService $serializationService; - /** - * @var PresetService - */ - protected $presetService; + protected PresetService $presetService; public function injectSerializationService(SerializationService $serializationService): void { diff --git a/Classes/Tests/AbstractTest.php b/Classes/Tests/AbstractTest.php index 20b2fe5..8392f9f 100644 --- a/Classes/Tests/AbstractTest.php +++ b/Classes/Tests/AbstractTest.php @@ -13,15 +13,15 @@ */ abstract class AbstractTest implements TestInterface { - protected string $id = ''; + protected $id = ''; - protected string $description = ''; + protected $description = ''; - protected string $help = ''; + protected $help = ''; - protected string $helpUrl = ''; + protected $helpUrl = ''; - protected int $impact = 0; + protected $impact = 0; public function getId(): string { diff --git a/Resources/Private/Partials/Results.html b/Resources/Private/Partials/Results.html index 430c139..3ddba59 100644 --- a/Resources/Private/Partials/Results.html +++ b/Resources/Private/Partials/Results.html @@ -11,7 +11,7 @@

- \ No newline at end of file + diff --git a/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php b/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php index 8fac7b0..92849e8 100644 --- a/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php +++ b/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php @@ -196,12 +196,6 @@ public function linkImageAttributeNotBlacklistedTests(string $html, string $attr public function hasRedundantLinkNamesTestsDataProvider(): array { return [ - 'no links at all' => [ - [ - '' - ], - 0 - ], 'only one link' => [ [ 'Link 1' diff --git a/composer.json b/composer.json index e93edd3..b658b55 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,14 @@ "GPL-2.0+" ], "require": { + "php": "^7.4 || ^8.0", + "ext-dom": "*", "typo3/cms-core": "^11.5", "symfony/dom-crawler": "^5.2", "symfony/css-selector": "^5.2", "symfony/serializer": "^5.2", "symfony/property-access": "^5.2", - "symfony/property-info": "^5.2", - "ext-dom": "*" + "symfony/property-info": "^5.2" }, "replace": { "typo3-ter/uw-a11y-check": "self.version"