diff --git a/Classes/Analyzers/AbstractAnalyzer.php b/Classes/Analyzers/AbstractAnalyzer.php index 0911834..ed78799 100644 --- a/Classes/Analyzers/AbstractAnalyzer.php +++ b/Classes/Analyzers/AbstractAnalyzer.php @@ -2,6 +2,7 @@ namespace UniWue\UwA11yCheck\Analyzers; +use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Client; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Core\Database\QueryGenerator; @@ -15,31 +16,21 @@ */ abstract class AbstractAnalyzer implements AnalyzerInterface { - const TYPE_INTERNAL = 'internal'; + final const TYPE_INTERNAL = 'internal'; - /** - * @var string - */ - protected $type = ''; + protected string $type = ''; /** * @var array */ protected $pageUids = []; - /** - * @return string - */ - public function getType() + public function getType(): string { return $this->type; } /** * Runs all tests for the given preset and recordUid - * - * @param Preset $preset - * @param int $recordUid - * @return ResultSet */ public function runTests(Preset $preset, int $recordUid): ResultSet { @@ -58,7 +49,7 @@ public function runTests(Preset $preset, int $recordUid): ResultSet $result = $test->run($html, $recordUid); $results[] = $result; } - } catch (\GuzzleHttp\Exception\ClientException $e) { + } catch (ClientException $e) { $resultSet->setFailed(true); $resultSet->setFailedMessage($e->getMessage()); } @@ -75,9 +66,6 @@ public function runTests(Preset $preset, int $recordUid): ResultSet /** * Initializes the pageUids to check - * - * @param int $pageUid - * @param int $levels */ public function initializePageUids(int $pageUid, int $levels = 0): void { @@ -93,10 +81,6 @@ public function initializePageUids(int $pageUid, int $levels = 0): void /** * Returns the PID of the record - * - * @param string $table - * @param int $recordUid - * @return int */ protected function getPidByRecordUid(string $table, int $recordUid): int { @@ -110,9 +94,6 @@ protected function getPidByRecordUid(string $table, int $recordUid): int /** * Fetches the resulting HTML from the given URL - * - * @param string $url - * @return string */ protected function fetchHtml(string $url): string { diff --git a/Classes/Analyzers/NewsAnalyzer.php b/Classes/Analyzers/NewsAnalyzer.php index a6152bf..bf70761 100644 --- a/Classes/Analyzers/NewsAnalyzer.php +++ b/Classes/Analyzers/NewsAnalyzer.php @@ -13,16 +13,12 @@ */ 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 * - * @param Preset $preset - * @return array + * @return mixed[] */ public function getCheckRecordUids(Preset $preset): array { @@ -44,10 +40,9 @@ public function getCheckRecordUids(Preset $preset): array /** * Returns all news UIDs matching the given demand * - * @param SingleTableDemand $demand - * @return array + * @return mixed[] */ - protected function getNewsRecordUids(SingleTableDemand $demand) + protected function getNewsRecordUids(SingleTableDemand $demand): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable($demand->getTableName()); diff --git a/Classes/Analyzers/PageContentAnalyzer.php b/Classes/Analyzers/PageContentAnalyzer.php index 212e950..c2a4ebb 100644 --- a/Classes/Analyzers/PageContentAnalyzer.php +++ b/Classes/Analyzers/PageContentAnalyzer.php @@ -9,16 +9,12 @@ */ 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 * - * @param Preset $preset - * @return array + * @return mixed[] */ public function getCheckRecordUids(Preset $preset): array { diff --git a/Classes/Check/A11yCheck.php b/Classes/Check/A11yCheck.php index de2d0fc..5450e99 100644 --- a/Classes/Check/A11yCheck.php +++ b/Classes/Check/A11yCheck.php @@ -7,27 +7,17 @@ */ class A11yCheck { - /** - * @var Preset - */ - protected $preset; - /** * A11yCheck constructor. - * - * @param Preset $preset */ - public function __construct(Preset $preset) + public function __construct(protected Preset $preset) { - $this->preset = $preset; } /** * Executes the check and returns the result as objectStorage * - * @param int $id - * @param int $levels - * @return array + * @return ResultSet[] */ public function executeCheck(int $id, int $levels = 0): array { diff --git a/Classes/Check/Preset.php b/Classes/Check/Preset.php index adc1041..2804c18 100644 --- a/Classes/Check/Preset.php +++ b/Classes/Check/Preset.php @@ -10,96 +10,35 @@ */ class Preset { - /** - * @var string - */ - protected $id = ''; - - /** - * @var string - */ - protected $name = ''; - - /** - * @var string - */ - protected $description = ''; - - /** - * @var AbstractAnalyzer - */ - protected $analyzer; - - /** - * @var AbstractCheckUrlGenerator - */ - protected $checkUrlGenerator; - - /** - * @var TestSuite - */ - protected $testSuite; + protected string $description = ''; /** * Preset constructor. - * - * @param string $id - * @param string $name - * @param AbstractAnalyzer $analyzer - * @param AbstractCheckUrlGenerator $checkUrlGenerator - * @param TestSuite $testSuite - * @param array $configuration */ - public function __construct( - string $id, - string $name, - AbstractAnalyzer $analyzer, - AbstractCheckUrlGenerator $checkUrlGenerator, - TestSuite $testSuite, - array $configuration - ) { - $this->id = $id; - $this->name = $name; - $this->analyzer = $analyzer; - $this->checkUrlGenerator = $checkUrlGenerator; - $this->testSuite = $testSuite; + public function __construct(protected string $id, protected string $name, protected AbstractAnalyzer $analyzer, protected AbstractCheckUrlGenerator $checkUrlGenerator, protected TestSuite $testSuite, array $configuration) + { } - /** - * @return string - */ - public function getId() + public function getId(): string { return $this->id; } - /** - * @return string - */ - public function getName() + public function getName(): string { return $this->name; } - /** - * @return string - */ public function getDescription(): string { return $this->description; } - /** - * @return string - */ public function getCheckTableName(): string { return $this->checkUrlGenerator->getTableName(); } - /** - * @return string - */ public function getEditRecordTableName(): string { return $this->checkUrlGenerator->getEditRecordTable(); @@ -107,18 +46,12 @@ public function getEditRecordTableName(): string /** * Returns the check URL - * - * @param int $id - * @return string */ public function getCheckUrl(int $id): string { return $this->checkUrlGenerator->getCheckUrl($id); } - /** - * @return TestSuite - */ public function getTestSuite(): TestSuite { return $this->testSuite; @@ -127,11 +60,9 @@ public function getTestSuite(): TestSuite /** * Executes the testSuite configured in the preset by the given page UID and recursive levels * - * @param int $pageUid - * @param int $levels - * @return array + * @return ResultSet[] */ - public function executeTestSuiteByPageUid(int $pageUid, int $levels) + public function executeTestSuiteByPageUid(int $pageUid, int $levels): array { $result = []; $this->analyzer->initializePageUids($pageUid, $levels); @@ -146,8 +77,7 @@ public function executeTestSuiteByPageUid(int $pageUid, int $levels) /** * Executes the testSuite configured in the preset by the given array of record UIDs * - * @param array $recordUids - * @return array + * @return ResultSet[] */ public function executeTestSuiteByRecordUids(array $recordUids): array { diff --git a/Classes/Check/Result.php b/Classes/Check/Result.php index 329e8f2..0cd8025 100644 --- a/Classes/Check/Result.php +++ b/Classes/Check/Result.php @@ -10,203 +10,126 @@ */ class Result { - /** - * @var int|null - */ - protected $status; + protected ?int $status = null; - /** - * @var string - */ - protected $description = ''; + protected string $description = ''; - /** - * @var string - */ - protected $help = ''; + protected string $help = ''; - /** - * @var string - */ - protected $helpUrl = ''; + protected string $helpUrl = ''; - /** - * @var int|null - */ - protected $impact; + protected ?int $impact = null; /** * @var array */ protected $nodes = []; - /** - * @var string - */ - protected $testId = ''; + protected string $testId = ''; - /** - * @return int|null - */ public function getStatus(): ?int { return $this->status; } - /** - * @param int|null $status - */ public function setStatus(?int $status): void { $this->status = $status; } - /** - * @return string - */ public function getDescription(): string { return $this->description; } - /** - * @param string $description - */ public function setDescription(string $description): void { $this->description = $description; } - /** - * @return string - */ public function getHelp(): string { return $this->help; } - /** - * @param string $help - */ public function setHelp(string $help): void { $this->help = $help; } - /** - * @return string - */ public function getHelpUrl(): string { return $this->helpUrl; } - /** - * @param string $helpUrl - */ public function setHelpUrl(string $helpUrl): void { $this->helpUrl = $helpUrl; } - /** - * @return int|null - */ public function getImpact(): ?int { return $this->impact; } - /** - * @param int|null $impact - */ public function setImpact(?int $impact): void { $this->impact = $impact; } /** - * @return array + * @return mixed[] */ public function getNodes(): array { return $this->nodes; } - /** - * @param Node $node - */ - public function addNode(Node $node) + public function addNode(Node $node): void { $this->nodes[] = $node; } /** - * @param array $nodes + * @param mixed[] $nodes */ public function setNodes(array $nodes): void { $this->nodes = $nodes; } - /** - * @return string - */ public function getTestId(): string { return $this->testId; } - /** - * @param string $testId - */ public function setTestId(string $testId): void { $this->testId = $testId; } - /** - * @return bool - */ public function getHasErrors(): bool { - return count($this->nodes) > 0; + return $this->nodes !== []; } /** * Returns the state of the result used in Fluid - * - * @return int */ public function getState(): int { - switch ($this->status) { - case 0: - $state = 0; - break; - case 1: - if ($this->getImpact() >= 3) { - $state = 2; - } else { - $state = 1; - } - break; - case 2: - $state = -1; - break; - default: - $state = 1; - } - - return $state; + return match ($this->status) { + 0 => 0, + 1 => $this->getImpact() >= 3 ? 2 : 1, + 2 => -1, + default => 1, + }; } /** * Returns the title for the check used in Fluid - * - * @return string */ - public function getTitle(): string + public function getTitle(): ?string { $status = $this->status ?? 1; return LocalizationUtility::translate( diff --git a/Classes/Check/Result/Impact.php b/Classes/Check/Result/Impact.php index cf0a67e..dc0ade7 100644 --- a/Classes/Check/Result/Impact.php +++ b/Classes/Check/Result/Impact.php @@ -7,10 +7,10 @@ */ class Impact { - const FAILED = 0; - const NONE = 1; - const MINOR = 2; - const MODERATE = 3; - const SERIOUS = 4; - const CRITICAL = 5; + final const FAILED = 0; + final const NONE = 1; + final const MINOR = 2; + final const MODERATE = 3; + final const SERIOUS = 4; + final const CRITICAL = 5; } diff --git a/Classes/Check/Result/Node.php b/Classes/Check/Result/Node.php index 534e634..78b4020 100644 --- a/Classes/Check/Result/Node.php +++ b/Classes/Check/Result/Node.php @@ -7,87 +7,51 @@ */ class Node { - /** - * @var string - */ - protected $html = ''; + protected string $html = ''; - /** - * @var Impact|null - */ - protected $impact; + protected ?Impact $impact = null; - /** - * @var string - */ - protected $target = ''; + protected string $target = ''; - /** - * @var int - */ - protected $uid = 0; + protected int $uid = 0; - /** - * @return string - */ public function getHtml(): string { return $this->html; } - /** - * @param string $html - */ public function setHtml(string $html): void { $this->html = $html; } - /** - * @return Impact|null - */ public function getImpact(): ?Impact { return $this->impact; } - /** - * @param Impact|null $impact - */ public function setImpact(?Impact $impact): void { $this->impact = $impact; } - /** - * @return string - */ public function getTarget(): string { // @extensionScannerIgnoreLine False positive return $this->target; } - /** - * @param string $target - */ public function setTarget(string $target): void { // @extensionScannerIgnoreLine False positive $this->target = $target; } - /** - * @return int - */ public function getUid(): int { return $this->uid; } - /** - * @param int $uid - */ public function setUid(int $uid): void { $this->uid = $uid; diff --git a/Classes/Check/Result/Status.php b/Classes/Check/Result/Status.php index 052f0bc..8130dd7 100644 --- a/Classes/Check/Result/Status.php +++ b/Classes/Check/Result/Status.php @@ -7,8 +7,8 @@ */ class Status { - const PASSES = 0; - const VIOLATIONS = 1; - const INAPPLICABLE = 2; - const INCOMPLETE = 3; + final const PASSES = 0; + final const VIOLATIONS = 1; + final const INAPPLICABLE = 2; + final const INCOMPLETE = 3; } diff --git a/Classes/Check/ResultSet.php b/Classes/Check/ResultSet.php index d392cc5..10d97eb 100644 --- a/Classes/Check/ResultSet.php +++ b/Classes/Check/ResultSet.php @@ -9,64 +9,37 @@ */ class ResultSet { - /** - * @var int - */ - protected $pid = 0; + protected int $pid = 0; - /** - * @var int - */ - protected $uid = 0; + protected int $uid = 0; - /** - * @var string - */ - protected $table = ''; + protected string $table = ''; - /** - * @var string - */ - protected $editRecordTable = ''; + protected string $editRecordTable = ''; - /** - * @var bool - */ - protected $failed = false; + protected bool $failed = false; - /** - * @var string - */ - protected $failedMessage = ''; + protected string $failedMessage = ''; - /** - * @var string - */ - protected $checkedUrl = ''; + protected string $checkedUrl = ''; /** * @var array */ protected $results = []; - /** - * @return int - */ public function getPid(): int { return $this->pid; } - /** - * @param int $pid - */ public function setPid(int $pid): void { $this->pid = $pid; } /** - * @return array + * @return mixed[] */ public function getResults(): array { @@ -74,88 +47,58 @@ public function getResults(): array } /** - * @param array $results + * @param mixed[] $results */ public function setResults(array $results): void { $this->results = $results; } - /** - * @return int - */ public function getUid(): int { return $this->uid; } - /** - * @param int $uid - */ public function setUid(int $uid): void { $this->uid = $uid; } - /** - * @return string - */ public function getTable(): string { return $this->table; } - /** - * @param string $table - */ public function setTable(string $table): void { $this->table = $table; } - /** - * @return bool - */ public function getFailed(): bool { return $this->failed; } - /** - * @param bool $failed - */ public function setFailed(bool $failed): void { $this->failed = $failed; } - /** - * @return string - */ public function getFailedMessage(): string { return $this->failedMessage; } - /** - * @param string $failedMessage - */ public function setFailedMessage(string $failedMessage): void { $this->failedMessage = $failedMessage; } - /** - * @return string - */ public function getEditRecordTable(): string { return $this->editRecordTable; } - /** - * @param string $editRecordTable - */ public function setEditRecordTable(string $editRecordTable): void { $this->editRecordTable = $editRecordTable; @@ -163,8 +106,6 @@ public function setEditRecordTable(string $editRecordTable): void /** * Returns the highest impact of all results - * - * @return int */ public function getImpact(): int { @@ -176,24 +117,18 @@ public function getImpact(): int /** @var Result $result */ foreach ($this->results as $result) { - if (count($result->getNodes()) > 0 && $result->getImpact() > $impact) { + if ($result->getNodes() !== [] && $result->getImpact() > $impact) { $impact = $result->getImpact(); } } return $impact; } - /** - * @return string - */ public function getCheckedUrl(): string { return $this->checkedUrl; } - /** - * @param string $checkedUrl - */ public function setCheckedUrl(string $checkedUrl): void { $this->checkedUrl = $checkedUrl; diff --git a/Classes/Check/TestSuite.php b/Classes/Check/TestSuite.php index a70f9bc..699baab 100644 --- a/Classes/Check/TestSuite.php +++ b/Classes/Check/TestSuite.php @@ -14,26 +14,23 @@ class TestSuite */ protected $tests = []; - /** - * @param TestInterface $test - */ - public function addTest(TestInterface $test) + public function addTest(TestInterface $test): void { $this->tests[] = $test; } /** - * @return array + * @return mixed[] */ - public function getTests() + public function getTests(): array { return $this->tests; } /** - * @param array $tests + * @param mixed[] $tests */ - public function setTests(array $tests) + public function setTests(array $tests): void { $this->tests = $tests; } diff --git a/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php b/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php index 35823a2..ffa15b9 100644 --- a/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php +++ b/Classes/CheckUrlGenerators/AbstractCheckUrlGenerator.php @@ -10,47 +10,31 @@ abstract class AbstractCheckUrlGenerator { /** - * @var array + * @var array[] */ - protected $requiredConfiguration = []; + protected array $requiredConfiguration = []; - /** - * @var string - */ - protected $tableName = ''; + protected string $tableName = ''; - /** - * @var string - */ - protected $editRecordTable = ''; + protected string $editRecordTable = ''; /** * AbstractCheckUrlGenerator constructor. - * @param array $configuration */ public function __construct(array $configuration) { $this->checkRequiredConfiguration($configuration); } - /** - * @param int $pageUid - */ public function getCheckUrl(int $pageUid): string { } - /** - * @return string - */ public function getTableName(): string { return $this->tableName; } - /** - * @return string - */ public function getEditRecordTable(): string { return $this->editRecordTable; @@ -58,16 +42,14 @@ public function getEditRecordTable(): string /** * Checks, if all required configuration settings are available and if not, throws an exception - * - * @param array $configuration */ protected function checkRequiredConfiguration(array $configuration) { foreach ($this->requiredConfiguration as $configurationKey) { if (!isset($configuration[$configurationKey])) { throw new MissingConfigurationException( - 'Missing configuration key "' . $configurationKey . '" in ' . __CLASS__, - 1573565583355 + 'Missing configuration key "' . $configurationKey . '" in ' . self::class, + 1_573_565_583_355 ); } } diff --git a/Classes/CheckUrlGenerators/NewsDetail.php b/Classes/CheckUrlGenerators/NewsDetail.php index e683967..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 @@ -38,7 +38,6 @@ public function __construct(array $configuration) /** * Returns the check URL * - * @param int $newsUid * @return string|void */ public function getCheckUrl(int $newsUid): string diff --git a/Classes/CheckUrlGenerators/Page.php b/Classes/CheckUrlGenerators/Page.php index 10c8ff1..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) { @@ -26,7 +26,6 @@ public function __construct(array $configuration) /** * Returns the check URL * - * @param int $pageUid * @return string|void */ public function getCheckUrl(int $pageUid): string diff --git a/Classes/CheckUrlGenerators/PageContent.php b/Classes/CheckUrlGenerators/PageContent.php index 381e937..28391e5 100644 --- a/Classes/CheckUrlGenerators/PageContent.php +++ b/Classes/CheckUrlGenerators/PageContent.php @@ -12,19 +12,13 @@ class PageContent extends AbstractCheckUrlGenerator { /** - * @var array + * @var array[] */ - protected $requiredConfiguration = ['targetPid']; + protected array $requiredConfiguration = ['targetPid']; - /** - * @var int - */ - protected $targetPid = 0; + protected int $targetPid = 0; - /** - * @var array - */ - protected $ignoredContentTypes = []; + protected array $ignoredContentTypes = []; /** * PageContent constructor. @@ -47,7 +41,6 @@ public function __construct(array $configuration) /** * Returns the check URL * - * @param int $pageUid * @return string|void */ public function getCheckUrl(int $pageUid): string diff --git a/Classes/Command/AbstractCheckCommand.php b/Classes/Command/AbstractCheckCommand.php index 087b118..6280343 100644 --- a/Classes/Command/AbstractCheckCommand.php +++ b/Classes/Command/AbstractCheckCommand.php @@ -3,6 +3,7 @@ declare(strict_types=1); namespace UniWue\UwA11yCheck\Command; +use PDO; use Symfony\Component\Console\Command\Command; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -15,10 +16,7 @@ */ abstract class AbstractCheckCommand extends Command { - /** - * @var SerializationService - */ - protected $serializationService; + protected SerializationService $serializationService; /** * AbstractCheckCommand constructor. @@ -33,9 +31,6 @@ public function __construct(string $name = null) /** * Saves the given results - * - * @param Preset $preset - * @param array $results */ public function saveResults(Preset $preset, array $results): void { @@ -48,9 +43,6 @@ public function saveResults(Preset $preset, array $results): void /** * Saves a single result to the database - * - * @param Preset $preset - * @param ResultSet $resultSet */ protected function saveResult(Preset $preset, ResultSet $resultSet): void { @@ -73,9 +65,6 @@ protected function saveResult(Preset $preset, ResultSet $resultSet): void /** * Cleans up old check results in the database - * - * @param Preset $preset - * @param ResultSet $resultSet */ protected function cleanupOldResults(Preset $preset, ResultSet $resultSet): void { @@ -87,11 +76,11 @@ protected function cleanupOldResults(Preset $preset, ResultSet $resultSet): void ->where( $queryBuilder->expr()->eq( 'pid', - $queryBuilder->createNamedParameter($resultSet->getPid(), \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($resultSet->getPid(), PDO::PARAM_INT) ), $queryBuilder->expr()->eq( 'record_uid', - $queryBuilder->createNamedParameter($resultSet->getUid(), \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($resultSet->getUid(), PDO::PARAM_INT) ), $queryBuilder->expr()->eq( 'preset_id', diff --git a/Classes/Command/PresetByPageUidCommand.php b/Classes/Command/PresetByPageUidCommand.php index 6f22e53..4e73480 100644 --- a/Classes/Command/PresetByPageUidCommand.php +++ b/Classes/Command/PresetByPageUidCommand.php @@ -3,13 +3,14 @@ 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; use Symfony\Component\Console\Input\InputOption; 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; @@ -22,7 +23,7 @@ class PresetByPageUidCommand extends AbstractCheckCommand /** * Configuring the command options */ - public function configure() + public function configure(): void { $this ->setDescription('a11y check for the given preset and page uid (recursive by "levels" if set)') @@ -47,11 +48,9 @@ public function configure() /** * Execute the command * - * @param InputInterface $input - * @param OutputInterface $output - * @return int|void|null + * @return int|void */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $presetService = $objectManager->get(PresetService::class); @@ -65,7 +64,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $preset = $presetService->getPresetById($presetId); - if (!$preset) { + if (!$preset instanceof Preset) { // @extensionScannerIgnoreLine False positive $io->error('Preset "' . $presetId . '" not found or contains errors (check classNames!).'); return 1; diff --git a/Classes/Command/PresetByRecordUidsCommand.php b/Classes/Command/PresetByRecordUidsCommand.php index 944f396..f76c6ac 100644 --- a/Classes/Command/PresetByRecordUidsCommand.php +++ b/Classes/Command/PresetByRecordUidsCommand.php @@ -3,6 +3,7 @@ declare(strict_types=1); namespace UniWue\UwA11yCheck\Command; +use UniWue\UwA11yCheck\Check\Preset; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -21,7 +22,7 @@ class PresetByRecordUidsCommand extends AbstractCheckCommand /** * Configuring the command options */ - public function configure() + public function configure(): void { $this ->setDescription( @@ -42,11 +43,9 @@ public function configure() /** * Execute the command * - * @param InputInterface $input - * @param OutputInterface $output - * @return int|void|null + * @return int|void */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $presetService = $objectManager->get(PresetService::class); @@ -58,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $recordUids = GeneralUtility::intExplode(',', $input->getArgument('uids'), true); $preset = $presetService->getPresetById($presetId); - if (!$preset) { + if (!$preset instanceof Preset) { // @extensionScannerIgnoreLine False positive $io->error('Preset "' . $presetId . '" not found or contains errors (check classNames!).'); return 1; diff --git a/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php b/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php index 803f4bd..ab531ab 100644 --- a/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php +++ b/Classes/Component/PropertyInfo/Extractor/ResultSetExtractor.php @@ -14,10 +14,7 @@ */ class ResultSetExtractor implements PropertyTypeExtractorInterface { - /** - * @var ReflectionExtractor - */ - private $reflectionExtractor; + private readonly ReflectionExtractor $reflectionExtractor; /** * ResultSetExtractor constructor. @@ -30,10 +27,9 @@ public function __construct() /** * @param string $class * @param string $property - * @param array $context * @return array|Type[]|null */ - public function getTypes($class, $property, array $context = []) + public function getTypes($class, $property, array $context = []): ?array { if (is_a($class, ResultSet::class, true) && 'results' === $property) { return [ diff --git a/Classes/Controller/A11yCheckController.php b/Classes/Controller/A11yCheckController.php index b1fb071..ad2de09 100644 --- a/Classes/Controller/A11yCheckController.php +++ b/Classes/Controller/A11yCheckController.php @@ -2,6 +2,11 @@ namespace UniWue\UwA11yCheck\Controller; +use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; +use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use TYPO3\CMS\Extbase\Annotation\IgnoreValidation; +use Psr\Http\Message\ResponseInterface; +use DateTime; use TYPO3\CMS\Backend\Template\Components\ButtonBar; use TYPO3\CMS\Backend\Template\Components\Menu\Menu; use TYPO3\CMS\Backend\View\BackendTemplateView; @@ -12,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; @@ -20,71 +28,50 @@ /** * Class A11yCheckController */ -class A11yCheckController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController +class A11yCheckController extends ActionController { - const LANG_CORE = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:'; - const LANG_LOCAL = 'LLL:EXT:uw_a11y_check/Resources/Private/Language/locallang.xlf:'; + 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:'; - /** - * @var PresetService - */ - protected $presetService; + protected PresetService $presetService; - /** - * @param PresetService $presetService - */ - public function injectPresetService(PresetService $presetService) - { - $this->presetService = $presetService; - } + private ModuleTemplateFactory $moduleTemplateFactory; - /** - * Backend Template Container - * - * @var string - */ - protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class; /** * The current page uid - * - * @var int */ - protected $pid = 0; + protected int $pid = 0; - /** - * BackendTemplateContainer - * - * @var BackendTemplateView - */ - protected $view; + protected IconFactory $iconFactory; - /** - * @var IconFactory - */ - protected $iconFactory; + protected ResultsService $resultsService; - /** - * @var ResultsService - */ - protected $resultsService; + public function __construct(ModuleTemplateFactory $moduleTemplateFactory) + { + $this->moduleTemplateFactory = $moduleTemplateFactory; + } + + public function injectPresetService(PresetService $presetService): void + { + $this->presetService = $presetService; + } /** * Set up the doc header properly here - * - * @param ViewInterface $view */ - protected function initializeView(ViewInterface $view) + protected function initializeView(ViewInterface $view): void { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); /** @var BackendTemplateView $view */ 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); - $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); - if ($view instanceof BackendTemplateView) { - $view->getModuleTemplate()->getPageRenderer()->addCssFile( + $moduleTemplate->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); + if ($view instanceof TemplateView) { + $moduleTemplate->getPageRenderer()->addCssFile( 'EXT:uw_a11y_check/Resources/Public/Css/a11y_check.css' ); } @@ -96,7 +83,7 @@ protected function initializeView(ViewInterface $view) /** * Initialize action */ - public function initializeAction() + public function initializeAction(): void { $this->pid = (int)GeneralUtility::_GET('id'); } @@ -104,12 +91,12 @@ public function initializeAction() /** * Index action * - * @param \UniWue\UwA11yCheck\Domain\Model\Dto\CheckDemand $checkDemand - * @TYPO3\CMS\Extbase\Annotation\IgnoreValidation("checkDemand") + * @IgnoreValidation("checkDemand") */ - public function indexAction($checkDemand = null): void + public function indexAction(CheckDemand $checkDemand = null): ResponseInterface { - if (!$checkDemand) { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); + if ($checkDemand === null) { $checkDemand = new CheckDemand(); } @@ -124,13 +111,14 @@ public function indexAction($checkDemand = null): void ] ); } - $this->view->assignMultiple([ 'checkDemand' => $checkDemand, 'presets' => $this->presetService->getPresets(), 'levelSelectorOptions' => $this->getLevelSelectorOptions(), 'savedResultsCount' => $this->resultsService->getSavedResultsCount($this->pid), ]); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** @@ -153,54 +141,61 @@ public function initializeCheckAction(): void /** * Check action * - * @param \UniWue\UwA11yCheck\Domain\Model\Dto\CheckDemand $checkDemand - * @TYPO3\CMS\Extbase\Annotation\IgnoreValidation("checkDemand") + * @IgnoreValidation("checkDemand") */ - public function checkAction(CheckDemand $checkDemand): void + public function checkAction(CheckDemand $checkDemand): ResponseInterface { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $preset = $checkDemand->getPreset(); $results = $preset->executeTestSuiteByPageUid($this->pid, $checkDemand->getLevel()); $this->view->assignMultiple([ 'checkDemand' => $checkDemand, 'results' => $results, - 'date' => new \DateTime() + 'date' => new DateTime() ]); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** * Results action */ - public function resultsAction(): void + public function resultsAction(): ResponseInterface { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $this->createAcknowledgeButton($this->pid); $resultsArray = $this->resultsService->getResultsArrayByPid($this->pid); $this->view->assignMultiple([ 'resultsArray' => $resultsArray ]); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** * AcknowledgeResult Action - * - * @param int $pageUid */ - public function acknowledgeResultAction(int $pageUid) + public function acknowledgeResultAction(int $pageUid): ResponseInterface { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $this->resultsService->deleteSavedResults($pageUid); $this->redirect('index'); + $moduleTemplate->setContent($this->view->render()); + return $this->htmlResponse($moduleTemplate->renderContent()); } /** * Create menu */ - protected function createMenu() + protected function createMenu(): void { - $uriBuilder = $this->objectManager->get(UriBuilder::class); + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); + $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->setRequest($this->request); - $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu(); + $menu = $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->makeMenu(); $menu->setIdentifier('uw_a11y_check'); $actions = ['index', 'results']; @@ -214,7 +209,7 @@ protected function createMenu() } if ($menu instanceof Menu) { - $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu); + $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu); } } @@ -223,13 +218,14 @@ protected function createMenu() */ protected function createDefaultButtons(): void { - $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); + $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar(); // 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); } @@ -237,15 +233,14 @@ protected function createDefaultButtons(): void /** * Creates the acknowledge button - * - * @param int $pid */ protected function createAcknowledgeButton(int $pid): void { + $moduleTemplate = $this->moduleTemplateFactory->create($this->request); $uriBuilder = $this->objectManager->get(UriBuilder::class); $uriBuilder->setRequest($this->request); - $buttonBar = $this->view->getModuleTemplate()->getDocHeaderComponent()->getButtonBar(); + $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar(); $title = $this->getLanguageService()->sL(self::LANG_LOCAL . 'labels.acknowledgeResults'); $button = $buttonBar->makeLinkButton(); @@ -263,7 +258,7 @@ protected function createAcknowledgeButton(int $pid): void } /** - * @return array + * @return string[] */ protected function getLevelSelectorOptions(): array { diff --git a/Classes/Controller/ContentElementsController.php b/Classes/Controller/ContentElementsController.php index 9e7a7b8..ab413d8 100644 --- a/Classes/Controller/ContentElementsController.php +++ b/Classes/Controller/ContentElementsController.php @@ -2,6 +2,9 @@ namespace UniWue\UwA11yCheck\Controller; +use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; +use Exception; +use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Security\Cryptography\HashService; @@ -10,34 +13,28 @@ * * Plugin is used to render a given list of content element uids using RECORDS content element */ -class ContentElementsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController +class ContentElementsController extends ActionController { /** * @var HashService */ protected $hashService; - /** - * @param HashService $hashService - */ - public function injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService) + public function injectHashService(HashService $hashService): void { $this->hashService = $hashService; } /** - * @param int $pageUid - * @param string $ignoreContentTypes - * @param string $hmac - * @throws \Exception + * @throws Exception */ - public function showAction(int $pageUid, string $ignoreContentTypes, string $hmac) + public function showAction(int $pageUid, string $ignoreContentTypes, string $hmac): ResponseInterface { $hmacString = $pageUid . $ignoreContentTypes; $expectedHmac = GeneralUtility::hmac($hmacString, 'page_content'); if ($expectedHmac !== $hmac) { - throw new \Exception('HMAC does not match', 1572608738828); + throw new Exception('HMAC does not match', 1572608738828); } $whereCondition = 'colPos >= 0'; @@ -53,5 +50,6 @@ public function showAction(int $pageUid, string $ignoreContentTypes, string $hma 'pageUid' => $pageUid, 'where' => $whereCondition, ]); + return $this->htmlResponse(); } } diff --git a/Classes/Domain/Model/Dto/CheckDemand.php b/Classes/Domain/Model/Dto/CheckDemand.php index e319c43..1f38daf 100644 --- a/Classes/Domain/Model/Dto/CheckDemand.php +++ b/Classes/Domain/Model/Dto/CheckDemand.php @@ -18,65 +18,47 @@ class CheckDemand extends AbstractEntity /** * @var \UniWue\UwA11yCheck\Check\Preset|null */ - protected $preset; + protected $preset = null; /** * @var int */ protected $level = 0; - /** - * @return string - */ public function getAnalyze(): string { return $this->analyze; } - /** - * @param string $analyze - */ public function setAnalyze(string $analyze): void { $this->analyze = $analyze; } - /** - * @return \UniWue\UwA11yCheck\Check\Preset|null - */ public function getPreset(): ?Preset { return $this->preset; } - /** - * @param \UniWue\UwA11yCheck\Check\Preset|null $preset - */ public function setPreset(?Preset $preset): void { $this->preset = $preset; } - /** - * @return int - */ public function getLevel(): int { return $this->level; } - /** - * @param int $level - */ public function setLevel(int $level): void { $this->level = $level; } /** - * @return array + * @return array{analyze: string, preset: string, level: int} */ - public function toArray() + public function toArray(): array { return [ 'analyze' => $this->getAnalyze(), diff --git a/Classes/Domain/Model/Dto/SingleTableDemand.php b/Classes/Domain/Model/Dto/SingleTableDemand.php index 8d92cad..9a2d069 100644 --- a/Classes/Domain/Model/Dto/SingleTableDemand.php +++ b/Classes/Domain/Model/Dto/SingleTableDemand.php @@ -12,7 +12,7 @@ class SingleTableDemand extends AbstractEntity /** * The tablename for the query * - * @var string + * @var int */ protected $tableName = ''; @@ -23,33 +23,21 @@ class SingleTableDemand extends AbstractEntity */ protected $maxResults = 50; - /** - * @return string - */ public function getTableName(): string { return $this->tableName; } - /** - * @param string $tableName - */ public function setTableName(string $tableName): void { $this->tableName = $tableName; } - /** - * @return int - */ public function getMaxResults(): int { return $this->maxResults; } - /** - * @param int $maxResults - */ public function setMaxResults(int $maxResults): void { $this->maxResults = $maxResults; diff --git a/Classes/Property/TypeConverter/PresetTypeConverter.php b/Classes/Property/TypeConverter/PresetTypeConverter.php index 2d015af..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,18 +14,8 @@ */ class PresetTypeConverter extends AbstractTypeConverter { - /** - * @var PresetService - */ - protected $presetService; + protected PresetService $presetService; - /** - * @param PresetService $presetService - */ - public function injectConfigurationService(PresetService $presetService) - { - $this->presetService = $presetService; - } /** * @var array @@ -41,23 +32,26 @@ public function injectConfigurationService(PresetService $presetService) */ protected $priority = 1; + public function injectConfigurationService(PresetService $presetService): void + { + $this->presetService = $presetService; + } + /** * @param mixed $source - * @param string $targetType - * @param array $convertedChildProperties * @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) { - return $this->objectManager->get(Error::class, 'Preset not found', 1573053017102); + if (!$preset instanceof Preset) { + return GeneralUtility::makeInstance(Error::class, 'Preset not found', 1573053017102); } return $preset; diff --git a/Classes/Service/PresetService.php b/Classes/Service/PresetService.php index e69c91d..960cccd 100644 --- a/Classes/Service/PresetService.php +++ b/Classes/Service/PresetService.php @@ -2,6 +2,8 @@ namespace UniWue\UwA11yCheck\Service; +use Exception; +use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Configuration\Loader\YamlFileLoader; use TYPO3\CMS\Core\Messaging\FlashMessage; use TYPO3\CMS\Core\Messaging\FlashMessageService; @@ -20,20 +22,11 @@ */ class PresetService { - /** - * @var YamlFileLoader - */ - protected $yamlFileLoader; + protected YamlFileLoader $yamlFileLoader; - /** - * @var ObjectManager - */ - protected $objectManager; + protected ObjectManager $objectManager; - /** - * @var FlashMessageService - */ - protected $flashMessageService; + protected FlashMessageService $flashMessageService; /** * PresetService constructor. @@ -44,10 +37,7 @@ public function __construct() $this->flashMessageService = $this->objectManager->get(FlashMessageService::class); } - /** - * @param YamlFileLoader $yamlFileLoader - */ - public function injectYamlFileLoader(YamlFileLoader $yamlFileLoader) + public function injectYamlFileLoader(YamlFileLoader $yamlFileLoader): void { $this->yamlFileLoader = $yamlFileLoader; } @@ -55,7 +45,7 @@ public function injectYamlFileLoader(YamlFileLoader $yamlFileLoader) /** * Returns all presets * - * @return array + * @return Preset[] */ public function getPresets(): array { @@ -87,11 +77,11 @@ public function getPresets(): array $configuration = $presetData['configuration'] ?? []; $presets[] = new Preset($id, $name, $analyzer, $checkUrlGenerator, $testSuite, $configuration); - } catch (\Exception $exception) { + } catch (Exception $exception) { $message = new FlashMessage( $exception->getMessage(), 'Class not found in preset "' . $name . '"', - FlashMessage::ERROR, + AbstractMessage::ERROR, true ); // @extensionScannerIgnoreLine False positive @@ -106,9 +96,6 @@ public function getPresets(): array /** * Returns a preset by the ID - * - * @param string $id - * @return Preset|null */ public function getPresetById(string $id): ?Preset { @@ -126,13 +113,8 @@ public function getPresetById(string $id): ?Preset /** * Returns an analyzer by the ID - * - * @param string $id - * @param array $yamlData - * @param array $configuration - * @return AbstractAnalyzer|null */ - protected function getAnalyzerById(string $id, array $yamlData, array $configuration): ?AbstractAnalyzer + protected function getAnalyzerById(string $id, array $yamlData, array $configuration): ?object { $analyzer = null; foreach ($yamlData['analyzers'] as $analyzerId => $analyzerConfig) { @@ -149,17 +131,12 @@ protected function getAnalyzerById(string $id, array $yamlData, array $configura /** * Returns a CheckUrlGenerator by ID - * - * @param string $id - * @param array $yamlData - * @param array $configuration - * @return AbstractCheckUrlGenerator|null */ protected function getCheckUrlGeneratorById( string $id, array $yamlData, array $configuration - ): ?AbstractCheckUrlGenerator { + ): ?object { $checkUrlGenerator = null; foreach ($yamlData['checkUrlGenerators'] as $checkUrlGeneratorId => $checkUrlGeneratorConfig) { if ($checkUrlGeneratorId === $id) { @@ -178,11 +155,6 @@ protected function getCheckUrlGeneratorById( /** * Returns a testsuite by the ID - * - * @param string $id - * @param array $yamlData - * @param array $configuration - * @return TestSuite */ protected function getTestSuiteById(string $id, array $yamlData, array $configuration): TestSuite { @@ -208,10 +180,7 @@ protected function getTestSuiteById(string $id, array $yamlData, array $configur /** * Merges local and global configuration and returns the result for the given type * - * @param array $presetData - * @param string $type - * @param array $yamlData - * @return array + * @return mixed[] */ protected function getConfiguration(array $presetData, string $type, array $yamlData): array { @@ -233,7 +202,7 @@ protected function getConfigurationFile() if (!file_exists(GeneralUtility::getFileAbsFileName($file))) { throw new ConfigurationFileNotFoundException( 'Configured yaml "' . $file . '" configuration does not exist.', - 1573216092216 + 1_573_216_092_216 ); } diff --git a/Classes/Service/ResultsService.php b/Classes/Service/ResultsService.php index dff2dbe..729e06d 100644 --- a/Classes/Service/ResultsService.php +++ b/Classes/Service/ResultsService.php @@ -2,6 +2,8 @@ namespace UniWue\UwA11yCheck\Service; +use DateTime; +use PDO; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; use UniWue\UwA11yCheck\Check\ResultSet; @@ -11,28 +13,16 @@ */ class ResultsService { - /** - * @var SerializationService - */ - protected $serializationService; + protected SerializationService $serializationService; - /** - * @var PresetService - */ - protected $presetService; + protected PresetService $presetService; - /** - * @param SerializationService $serializationService - */ - public function injectSerializationService(\UniWue\UwA11yCheck\Service\SerializationService $serializationService) + public function injectSerializationService(SerializationService $serializationService): void { $this->serializationService = $serializationService; } - /** - * @param PresetService $presetService - */ - public function injectPresetService(PresetService $presetService) + public function injectPresetService(PresetService $presetService): void { $this->presetService = $presetService; } @@ -41,8 +31,7 @@ public function injectPresetService(PresetService $presetService) * Returns all saved results from the database. An array is returned containing both the presets and * the check results. * - * @param int $pid - * @return array + * @return array */ public function getResultsArrayByPid(int $pid): array { @@ -55,7 +44,7 @@ public function getResultsArrayByPid(int $pid): array ->where( $queryBuilder->expr()->eq( 'pid', - $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($pid, PDO::PARAM_INT) ) )->orderBy('preset_id', 'asc'); @@ -73,7 +62,7 @@ public function getResultsArrayByPid(int $pid): array $presetId = $result['preset_id']; if (!isset($dbResults[$presetId])) { - $checkDate = new \DateTime(); + $checkDate = new DateTime(); $checkDate->setTimestamp($result['check_date']); $dbResults[$presetId] = [ 'preset' => $this->presetService->getPresetById($presetId) ?? 'Unknown', @@ -90,9 +79,6 @@ public function getResultsArrayByPid(int $pid): array /** * Returns the amount of saved DB check results - * - * @param int $pid - * @return int */ public function getSavedResultsCount(int $pid): int { @@ -105,7 +91,7 @@ public function getSavedResultsCount(int $pid): int ->where( $queryBuilder->expr()->eq( 'pid', - $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($pid, PDO::PARAM_INT) ) )->orderBy('preset_id', 'asc'); @@ -114,8 +100,6 @@ public function getSavedResultsCount(int $pid): int /** * Deleted the saved result for the given PID - * - * @param int $pid */ public function deleteSavedResults(int $pid): void { @@ -127,7 +111,7 @@ public function deleteSavedResults(int $pid): void ->where( $queryBuilder->expr()->eq( 'pid', - $queryBuilder->createNamedParameter($pid, \PDO::PARAM_INT) + $queryBuilder->createNamedParameter($pid, PDO::PARAM_INT) ) ); diff --git a/Classes/Service/SerializationService.php b/Classes/Service/SerializationService.php index e4263b9..8998602 100644 --- a/Classes/Service/SerializationService.php +++ b/Classes/Service/SerializationService.php @@ -16,7 +16,7 @@ class SerializationService /** * @var Serializer */ - protected $serializer; + protected Serializer $serializer; /** * SerializationService constructor. diff --git a/Classes/Tests/AbstractTest.php b/Classes/Tests/AbstractTest.php index b323c0e..8392f9f 100644 --- a/Classes/Tests/AbstractTest.php +++ b/Classes/Tests/AbstractTest.php @@ -2,6 +2,9 @@ namespace UniWue\UwA11yCheck\Tests; +use UniWue\UwA11yCheck\Check\Result\Status; +use DOMElement; +use TYPO3\CMS\Core\Localization\LanguageService; use UniWue\UwA11yCheck\Check\Result; use UniWue\UwA11yCheck\Utility\Tests\ElementUtility; @@ -10,71 +13,36 @@ */ abstract class AbstractTest implements TestInterface { - /** - * @var string - */ protected $id = ''; - /** - * @var string - */ protected $description = ''; - /** - * @var string - */ protected $help = ''; - /** - * @var string - */ protected $helpUrl = ''; - /** - * @var int - */ protected $impact = 0; - /** - * @var array - */ - protected $configuration = []; - - /** - * @return string - */ public function getId(): string { return $this->id; } - /** - * @return string - */ public function getDescription(): string { return htmlspecialchars($this->description); } - /** - * @return string - */ public function getHelp(): string { return $this->help; } - /** - * @return string - */ public function getHelpUrl(): string { return $this->helpUrl; } - /** - * @return int - */ public function getImpact(): int { return $this->impact; @@ -83,12 +51,10 @@ public function getImpact(): int /** * AbstractTest constructor. * - * @param array $configuration + * @param mixed[] $configuration */ - public function __construct(array $configuration = []) + public function __construct(protected array $configuration = []) { - $this->configuration = $configuration; - if ($this->description === '') { $this->description = $this->translateLabel($this->id . '.description'); } @@ -97,9 +63,6 @@ public function __construct(array $configuration = []) } } - /** - * @return Result - */ public function initResultWithMetaDataFromTest(): Result { $result = new Result(); @@ -108,19 +71,15 @@ public function initResultWithMetaDataFromTest(): Result $result->setHelp($this->help); $result->setHelpUrl($this->helpUrl); $result->setImpact($this->impact); - $result->setStatus(Result\Status::INAPPLICABLE); + $result->setStatus(Status::INAPPLICABLE); return $result; } /** * Returns the element UID in the node. If no UID could be determined, the fallbackElementUid is returned - * - * @param \DOMElement $node - * @param int $fallbackElementUid - * @return int */ - public function getElementUid(\DOMElement $node, int $fallbackElementUid): int + public function getElementUid(DOMElement $node, int $fallbackElementUid): int { $elementUid = ElementUtility::determineElementUid($node); if ($elementUid === 0) { @@ -129,10 +88,6 @@ public function getElementUid(\DOMElement $node, int $fallbackElementUid): int return $elementUid; } - /** - * @param string $label - * @return string - */ protected function translateLabel(string $label): string { $langId = 'LLL:EXT:uw_a11y_check/Resources/Private/Language/locallang.xlf:'; @@ -141,10 +96,8 @@ protected function translateLabel(string $label): string /** * Returns LanguageService - * - * @return \TYPO3\CMS\Lang\LanguageService */ - protected function getLanguageService() + protected function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } diff --git a/Classes/Tests/Internal/HeadingOrderTest.php b/Classes/Tests/Internal/HeadingOrderTest.php index f580b67..3e9a704 100644 --- a/Classes/Tests/Internal/HeadingOrderTest.php +++ b/Classes/Tests/Internal/HeadingOrderTest.php @@ -2,6 +2,10 @@ namespace UniWue\UwA11yCheck\Tests\Internal; +use UniWue\UwA11yCheck\Check\Result\Impact; +use DOMElement; +use UniWue\UwA11yCheck\Check\Result\Node; +use UniWue\UwA11yCheck\Check\Result\Status; use Symfony\Component\DomCrawler\Crawler; use UniWue\UwA11yCheck\Check\Result; use UniWue\UwA11yCheck\Tests\AbstractTest; @@ -26,7 +30,7 @@ class HeadingOrderTest extends AbstractTest /** * @var int */ - protected $impact = Result\Impact::MODERATE; + protected $impact = Impact::MODERATE; /** * If set, the test only checks elements in the given array of colPos ids @@ -48,10 +52,6 @@ public function __construct(array $configuration) /** * Runs the test - * - * @param string $html - * @param int $fallbackElementUid - * @return Result */ public function run(string $html, int $fallbackElementUid): Result { @@ -62,10 +62,10 @@ public function run(string $html, int $fallbackElementUid): Result $previousHeader = null; - /** @var \DOMElement $header */ + /** @var DOMElement $header */ foreach ($headers as $header) { // Always skip the first header - if (!$previousHeader) { + if ($previousHeader === null) { $previousHeader = $header; continue; } @@ -77,19 +77,19 @@ public function run(string $html, int $fallbackElementUid): Result } if (!$colPosExcluded && !HeaderUtility::headersSequentiallyDescending($previousHeader, $header)) { - $node = new Result\Node(); + $node = new Node(); $node->setHtml($header->ownerDocument->saveHTML($header)); $node->setUid($this->getElementUid($header, $fallbackElementUid)); $result->addNode($node); - $result->setStatus(Result\Status::VIOLATIONS); + $result->setStatus(Status::VIOLATIONS); } $previousHeader = $header; } // If all found nodes passed, set status to passes - if ($headers->count() > 0 && count($result->getNodes()) === 0) { - $result->setStatus(Result\Status::PASSES); + if ($headers->count() > 0 && $result->getNodes() === []) { + $result->setStatus(Status::PASSES); } return $result; diff --git a/Classes/Tests/Internal/ImageAltTest.php b/Classes/Tests/Internal/ImageAltTest.php index 747b967..65d358f 100644 --- a/Classes/Tests/Internal/ImageAltTest.php +++ b/Classes/Tests/Internal/ImageAltTest.php @@ -2,6 +2,10 @@ namespace UniWue\UwA11yCheck\Tests\Internal; +use UniWue\UwA11yCheck\Check\Result\Impact; +use DOMElement; +use UniWue\UwA11yCheck\Check\Result\Node; +use UniWue\UwA11yCheck\Check\Result\Status; use Symfony\Component\DomCrawler\Crawler; use UniWue\UwA11yCheck\Check\Result; use UniWue\UwA11yCheck\Tests\AbstractTest; @@ -25,14 +29,10 @@ class ImageAltTest extends AbstractTest /** * @var int */ - protected $impact = Result\Impact::CRITICAL; + protected $impact = Impact::CRITICAL; /** * Runs the test - * - * @param string $html - * @param int $fallbackElementUid - * @return Result */ public function run(string $html, int $fallbackElementUid): Result { @@ -41,7 +41,7 @@ public function run(string $html, int $fallbackElementUid): Result $crawler = new Crawler($html); $images = $crawler->filter('img'); - /** @var \DOMElement $image */ + /** @var DOMElement $image */ foreach ($images as $image) { $checkResult = SharedUtility::elementHasAlt($image) || SharedUtility::elementHasAriaLabelValue($image) || @@ -50,17 +50,17 @@ public function run(string $html, int $fallbackElementUid): Result SharedUtility::elementHasRoleNone($image); if (!$checkResult) { - $node = new Result\Node(); + $node = new Node(); $node->setHtml($image->ownerDocument->saveHTML($image)); $node->setUid($this->getElementUid($image, $fallbackElementUid)); $result->addNode($node); - $result->setStatus(Result\Status::VIOLATIONS); + $result->setStatus(Status::VIOLATIONS); } } // If all found nodes passed, set status to passes - if ($images->count() > 0 && count($result->getNodes()) === 0) { - $result->setStatus(Result\Status::PASSES); + if ($images->count() > 0 && $result->getNodes() === []) { + $result->setStatus(Status::PASSES); } return $result; diff --git a/Classes/Tests/Internal/LinkNameTest.php b/Classes/Tests/Internal/LinkNameTest.php index 45a2f72..7c485e2 100644 --- a/Classes/Tests/Internal/LinkNameTest.php +++ b/Classes/Tests/Internal/LinkNameTest.php @@ -2,6 +2,10 @@ namespace UniWue\UwA11yCheck\Tests\Internal; +use UniWue\UwA11yCheck\Check\Result\Impact; +use DOMElement; +use UniWue\UwA11yCheck\Check\Result\Node; +use UniWue\UwA11yCheck\Check\Result\Status; use Symfony\Component\DomCrawler\Crawler; use UniWue\UwA11yCheck\Check\Result; use UniWue\UwA11yCheck\Tests\AbstractTest; @@ -26,14 +30,10 @@ class LinkNameTest extends AbstractTest /** * @var int */ - protected $impact = Result\Impact::SERIOUS; + protected $impact = Impact::SERIOUS; /** * Runs the test - * - * @param string $html - * @param int $fallbackElementUid - * @return Result */ public function run(string $html, int $fallbackElementUid): Result { @@ -42,7 +42,7 @@ public function run(string $html, int $fallbackElementUid): Result $crawler = new Crawler($html); $links = $crawler->filter('a[href]'); - /** @var \DOMElement $link */ + /** @var DOMElement $link */ foreach ($links as $link) { $checkResult = SharedUtility::elementHasVisibleText($link) || SharedUtility::elementHasAriaLabelValue($link) || @@ -52,17 +52,17 @@ public function run(string $html, int $fallbackElementUid): Result LinkUtility::linkHasImageWithAlt($link); if (!$checkResult) { - $node = new Result\Node(); + $node = new Node(); $node->setHtml($link->ownerDocument->saveHTML($link)); $node->setUid($this->getElementUid($link, $fallbackElementUid)); $result->addNode($node); - $result->setStatus(Result\Status::VIOLATIONS); + $result->setStatus(Status::VIOLATIONS); } } // If all found nodes passed, set status to passes - if ($links->count() > 0 && count($result->getNodes()) === 0) { - $result->setStatus(Result\Status::PASSES); + if ($links->count() > 0 && $result->getNodes() === []) { + $result->setStatus(Status::PASSES); } return $result; diff --git a/Classes/Tests/Internal/LinkTextBlacklistedTest.php b/Classes/Tests/Internal/LinkTextBlacklistedTest.php index a096ae1..2dc158c 100644 --- a/Classes/Tests/Internal/LinkTextBlacklistedTest.php +++ b/Classes/Tests/Internal/LinkTextBlacklistedTest.php @@ -2,6 +2,10 @@ namespace UniWue\UwA11yCheck\Tests\Internal; +use UniWue\UwA11yCheck\Check\Result\Impact; +use DOMElement; +use UniWue\UwA11yCheck\Check\Result\Node; +use UniWue\UwA11yCheck\Check\Result\Status; use Symfony\Component\DomCrawler\Crawler; use UniWue\UwA11yCheck\Check\Result; use UniWue\UwA11yCheck\Tests\AbstractTest; @@ -26,7 +30,7 @@ class LinkTextBlacklistedTest extends AbstractTest /** * @var int */ - protected $impact = Result\Impact::MODERATE; + protected $impact = Impact::MODERATE; /** * @var array @@ -50,20 +54,15 @@ public function __construct(array $configuration) /** * Initializes the blacklist end ensures text is lowercase * - * @param array $blacklist - * @return array + * @return string[] */ - protected function initBlacklist(array $blacklist) + protected function initBlacklist(array $blacklist): array { return array_map('mb_strtolower', $blacklist); } /** * Runs the test - * - * @param string $html - * @param int $fallbackElementUid - * @return Result */ public function run(string $html, int $fallbackElementUid): Result { @@ -72,7 +71,7 @@ public function run(string $html, int $fallbackElementUid): Result $crawler = new Crawler($html); $elements = $crawler->filter('a'); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ foreach ($elements as $element) { $checkResult = (LinkUtility::linkTextNotBlacklisted($element, $this->blacklist) && SharedUtility::elementAttributeValueNotBlacklisted($element, 'title', $this->blacklist) && @@ -83,17 +82,17 @@ public function run(string $html, int $fallbackElementUid): Result SharedUtility::elementHasRoleNone($element); if (!$checkResult) { - $node = new Result\Node(); + $node = new Node(); $node->setHtml($element->ownerDocument->saveHTML($element)); $node->setUid($this->getElementUid($element, $fallbackElementUid)); $result->addNode($node); - $result->setStatus(Result\Status::VIOLATIONS); + $result->setStatus(Status::VIOLATIONS); } } // If all found nodes passed, set status to passes - if ($elements->count() > 0 && count($result->getNodes()) === 0) { - $result->setStatus(Result\Status::PASSES); + if ($elements->count() > 0 && $result->getNodes() === []) { + $result->setStatus(Status::PASSES); } return $result; diff --git a/Classes/Tests/Internal/RedundantLinkTest.php b/Classes/Tests/Internal/RedundantLinkTest.php index d4de9f0..7e71afb 100644 --- a/Classes/Tests/Internal/RedundantLinkTest.php +++ b/Classes/Tests/Internal/RedundantLinkTest.php @@ -2,6 +2,10 @@ namespace UniWue\UwA11yCheck\Tests\Internal; +use UniWue\UwA11yCheck\Check\Result\Impact; +use UniWue\UwA11yCheck\Check\Result\Node; +use UniWue\UwA11yCheck\Check\Result\Status; +use DOMElement; use Symfony\Component\DomCrawler\Crawler; use UniWue\UwA11yCheck\Check\Result; use UniWue\UwA11yCheck\Tests\AbstractTest; @@ -21,14 +25,10 @@ class RedundantLinkTest extends AbstractTest /** * @var int */ - protected $impact = Result\Impact::MINOR; + protected $impact = Impact::MINOR; /** * Runs the test - * - * @param string $html - * @param int $fallbackElementUid - * @return Result */ public function run(string $html, int $fallbackElementUid): Result { @@ -39,19 +39,19 @@ public function run(string $html, int $fallbackElementUid): Result $redundantLinks = $this->getRedundantLinks($elements); - if (count($redundantLinks) > 0) { + if ($redundantLinks !== []) { foreach ($redundantLinks as $element) { - $node = new Result\Node(); + $node = new Node(); $node->setHtml($element->ownerDocument->saveHTML($element)); $node->setUid($this->getElementUid($element, $fallbackElementUid)); $result->addNode($node); - $result->setStatus(Result\Status::VIOLATIONS); + $result->setStatus(Status::VIOLATIONS); } } // If all found nodes passed, set status to passes - if ($elements->count() > 0 && count($result->getNodes()) === 0) { - $result->setStatus(Result\Status::PASSES); + if ($elements->count() > 0 && $result->getNodes() === []) { + $result->setStatus(Status::PASSES); } return $result; @@ -61,7 +61,7 @@ public function run(string $html, int $fallbackElementUid): Result * Returns an array of all redundant links for the given object of elements * * @param Crawler $elements - * @return array + * @return mixed[] */ protected function getRedundantLinks(Crawler $elements): array { @@ -70,7 +70,7 @@ protected function getRedundantLinks(Crawler $elements): array foreach ($groupedLinks as $elementArray) { $redundantLinkNames = LinkUtility::getRedundantLinkNames($elementArray); - if (count($elementArray) > 1 && count($redundantLinkNames) >= 1) { + if ((is_countable($elementArray) ? count($elementArray) : 0) > 1 && count($redundantLinkNames) >= 1) { $result = array_merge($result, $redundantLinkNames); } } @@ -82,13 +82,13 @@ protected function getRedundantLinks(Crawler $elements): array * Returns an array of links grouped by its href * * @param Crawler $element - * @return array + * @return array */ protected function groupLinksByHref(Crawler $elements): array { $allLinks = []; - /** @var \DOMElement $element */ + /** @var DOMElement $element */ foreach ($elements as $element) { if (!$element->hasAttribute('href') || SharedUtility::elementHasRolePresentation($element) || diff --git a/Classes/Tests/Internal/RedundantTitleTest.php b/Classes/Tests/Internal/RedundantTitleTest.php index 6c59585..cfac4d8 100644 --- a/Classes/Tests/Internal/RedundantTitleTest.php +++ b/Classes/Tests/Internal/RedundantTitleTest.php @@ -2,6 +2,10 @@ namespace UniWue\UwA11yCheck\Tests\Internal; +use UniWue\UwA11yCheck\Check\Result\Impact; +use DOMElement; +use UniWue\UwA11yCheck\Check\Result\Node; +use UniWue\UwA11yCheck\Check\Result\Status; use Symfony\Component\DomCrawler\Crawler; use UniWue\UwA11yCheck\Check\Result; use UniWue\UwA11yCheck\Tests\AbstractTest; @@ -20,14 +24,10 @@ class RedundantTitleTest extends AbstractTest /** * @var int */ - protected $impact = Result\Impact::MINOR; + protected $impact = Impact::MINOR; /** * Runs the test - * - * @param string $html - * @param int $fallbackElementUid - * @return Result */ public function run(string $html, int $fallbackElementUid): Result { @@ -36,22 +36,22 @@ public function run(string $html, int $fallbackElementUid): Result $crawler = new Crawler($html); $elements = $crawler->filter('a, img'); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ foreach ($elements as $element) { $checkResult = SharedUtility::elementTitleNotRedundant($element); if (!$checkResult) { - $node = new Result\Node(); + $node = new Node(); $node->setHtml($element->ownerDocument->saveHTML($element)); $node->setUid($this->getElementUid($element, $fallbackElementUid)); $result->addNode($node); - $result->setStatus(Result\Status::VIOLATIONS); + $result->setStatus(Status::VIOLATIONS); } } // If all found nodes passed, set status to passes - if ($elements->count() > 0 && count($result->getNodes()) === 0) { - $result->setStatus(Result\Status::PASSES); + if ($elements->count() > 0 && $result->getNodes() === []) { + $result->setStatus(Status::PASSES); } return $result; diff --git a/Classes/Utility/ContentElementUtility.php b/Classes/Utility/ContentElementUtility.php index 1fe70b6..dab2ef5 100644 --- a/Classes/Utility/ContentElementUtility.php +++ b/Classes/Utility/ContentElementUtility.php @@ -14,11 +14,9 @@ class ContentElementUtility /** * Returns an array of content element UIDs for the given page uid * - * @param int $pageUid - * @param array $ignoredContentTypes - * @return array + * @return mixed[] */ - public static function getContentElementUidsByPage(int $pageUid, array $ignoredContentTypes = []) + public static function getContentElementUidsByPage(int $pageUid, array $ignoredContentTypes = []): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('tt_content'); diff --git a/Classes/Utility/Exception/ConfigurationFileNotFoundException.php b/Classes/Utility/Exception/ConfigurationFileNotFoundException.php index ee77cf5..074a94f 100644 --- a/Classes/Utility/Exception/ConfigurationFileNotFoundException.php +++ b/Classes/Utility/Exception/ConfigurationFileNotFoundException.php @@ -3,9 +3,10 @@ declare(strict_types=1); namespace UniWue\UwA11yCheck\Utility\Exception; +use RuntimeException; /** * Exception thrown if the configuration yaml file is not found */ -class ConfigurationFileNotFoundException extends \RuntimeException +class ConfigurationFileNotFoundException extends RuntimeException { } diff --git a/Classes/Utility/Exception/MissingConfigurationException.php b/Classes/Utility/Exception/MissingConfigurationException.php index 664dc28..d346a04 100644 --- a/Classes/Utility/Exception/MissingConfigurationException.php +++ b/Classes/Utility/Exception/MissingConfigurationException.php @@ -3,9 +3,10 @@ declare(strict_types=1); namespace UniWue\UwA11yCheck\Utility\Exception; +use RuntimeException; /** * Exception thrown if the configuration does not contain an expected entry */ -class MissingConfigurationException extends \RuntimeException +class MissingConfigurationException extends RuntimeException { } diff --git a/Classes/Utility/Tests/ElementUtility.php b/Classes/Utility/Tests/ElementUtility.php index 7b778a8..7096a86 100644 --- a/Classes/Utility/Tests/ElementUtility.php +++ b/Classes/Utility/Tests/ElementUtility.php @@ -2,6 +2,7 @@ namespace UniWue\UwA11yCheck\Utility\Tests; +use DOMElement; /** * Class ElementUtility */ @@ -9,15 +10,12 @@ class ElementUtility { /** * Returns the UID of the element provided by the data-attribute "data-uid" - * - * @param \DOMElement $element - * @return int */ - public static function determineElementUid(\DOMElement $element): int + public static function determineElementUid(DOMElement $element): int|string { if (!$element->hasAttribute('data-uid') && $element->parentNode && - $element->parentNode instanceof \DOMElement + $element->parentNode instanceof DOMElement ) { return self::determineElementUid($element->parentNode); } @@ -30,15 +28,12 @@ public static function determineElementUid(\DOMElement $element): int /** * Returns the colPos of the element in the node by looking up for data-colPos. * If no colPos is found, null is returned - * - * @param \DOMElement $element - * @return int|null */ - public static function determineElementColPos(\DOMElement $element): ?int + public static function determineElementColPos(DOMElement $element): ?int { if (!$element->hasAttribute('data-colpos') && $element->parentNode && - $element->parentNode instanceof \DOMElement + $element->parentNode instanceof DOMElement ) { return self::determineElementColPos($element->parentNode); } diff --git a/Classes/Utility/Tests/HeaderUtility.php b/Classes/Utility/Tests/HeaderUtility.php index 344d5dd..5444f1c 100644 --- a/Classes/Utility/Tests/HeaderUtility.php +++ b/Classes/Utility/Tests/HeaderUtility.php @@ -2,6 +2,7 @@ namespace UniWue\UwA11yCheck\Utility\Tests; +use DOMElement; /** * Class HeaderUtility */ @@ -9,12 +10,8 @@ class HeaderUtility { /** * Returns, if the given current header ins a descend of the given parent header - * - * @param \DOMElement $previousHeader - * @param \DOMElement $currentHeader - * @return bool */ - public static function headersSequentiallyDescending(\DOMElement $previousHeader, \DOMElement $currentHeader): bool + public static function headersSequentiallyDescending(DOMElement $previousHeader, DOMElement $currentHeader): bool { $result = false; diff --git a/Classes/Utility/Tests/LinkUtility.php b/Classes/Utility/Tests/LinkUtility.php index fa711d7..fa6a3af 100644 --- a/Classes/Utility/Tests/LinkUtility.php +++ b/Classes/Utility/Tests/LinkUtility.php @@ -2,16 +2,13 @@ namespace UniWue\UwA11yCheck\Utility\Tests; +use DOMElement; /** * Class LinkUtility */ class LinkUtility { - /** - * @param \DOMElement $element - * @return bool - */ - public static function linkHasImageWithAlt(\DOMElement $element): bool + public static function linkHasImageWithAlt(DOMElement $element): bool { $result = false; $images = $element->getElementsByTagName('img'); @@ -21,7 +18,7 @@ public static function linkHasImageWithAlt(\DOMElement $element): bool return false; } - /** @var \DOMElement $image */ + /** @var DOMElement $image */ foreach ($images as $image) { if ($image->getAttribute('alt') !== '') { $result = true; @@ -32,29 +29,18 @@ public static function linkHasImageWithAlt(\DOMElement $element): bool return $result; } - /** - * @param \DOMElement $element - * @param array $blacklist - * @return bool - */ - public static function linkTextNotBlacklisted(\DOMElement $element, array $blacklist): bool + public static function linkTextNotBlacklisted(DOMElement $element, array $blacklist): bool { if (empty($blacklist) || StringUtility::stripNewLines($element->textContent) === '') { return true; } $content = StringUtility::clearString($element->textContent); - return in_array(strtolower($content), $blacklist, true) === false; + return !in_array(strtolower($content), $blacklist, true); } - /** - * @param \DOMElement $element - * @param string $attribute - * @param array $blacklist - * @return bool - */ public static function linkImageAttributeNotBlacklisted( - \DOMElement $element, + DOMElement $element, string $attribute, array $blacklist ): bool { @@ -69,7 +55,7 @@ public static function linkImageAttributeNotBlacklisted( return true; } - /** @var \DOMElement $image */ + /** @var DOMElement $image */ foreach ($images as $image) { if (!SharedUtility::elementAttributeValueNotBlacklisted($image, $attribute, $blacklist)) { return false; @@ -84,15 +70,14 @@ public static function linkImageAttributeNotBlacklisted( * Checks, if the link name for the given array of link DOMElements is redundant and if so, returns an array * of link affected DOMElements * - * @param array $elements - * @return array + * @return array */ public static function getRedundantLinkNames(array $elements): array { $linkNames = []; $redundantLinks = []; - /** @var \DOMElement $element */ + /** @var DOMElement $element */ foreach ($elements as $element) { if (StringUtility::stripNewLines($element->textContent) !== '' && !in_array($element->textContent, $linkNames) diff --git a/Classes/Utility/Tests/SharedUtility.php b/Classes/Utility/Tests/SharedUtility.php index 9d3a469..0c6dac4 100644 --- a/Classes/Utility/Tests/SharedUtility.php +++ b/Classes/Utility/Tests/SharedUtility.php @@ -2,6 +2,7 @@ namespace UniWue\UwA11yCheck\Utility\Tests; +use DOMElement; use Symfony\Component\DomCrawler\Crawler; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -10,57 +11,35 @@ */ class SharedUtility { - /** - * @param \DOMElement $link - * @return bool - */ - public static function elementHasVisibleText(\DOMElement $link): bool + public static function elementHasVisibleText(DOMElement $link): string { return StringUtility::stripNewLines($link->textContent); } - /** - * @param \DOMElement $element - * @return bool - */ - public static function elementIsLinkWithHref(\DOMElement $element): bool + public static function elementIsLinkWithHref(DOMElement $element): bool { return $element->tagName === 'a' && $element->hasAttribute('href'); } - /** - * @param \DOMElement $element - * @return bool - */ - public static function elementHasRolePresentation(\DOMElement $element): bool + public static function elementHasRolePresentation(DOMElement $element): bool { return $element->hasAttribute('role') && strtolower($element->getAttribute('role')) === 'presentation'; } - /** - * @param \DOMElement $element - * @return bool - */ - public static function elementHasRoleNone(\DOMElement $element): bool + public static function elementHasRoleNone(DOMElement $element): bool { return $element->hasAttribute('role') && strtolower($element->getAttribute('role')) === 'none'; } - /** - * @param \DOMElement $element - * @return bool - */ - public static function elementHasAriaLabelValue(\DOMElement $element): bool + public static function elementHasAriaLabelValue(DOMElement $element): bool { return $element->hasAttribute('aria-label') && $element->getAttribute('aria-label') !== ''; } /** - * @param \DOMElement $element * @param Crawler $crawler - * @return bool */ - public static function elementAriaLabelledByValueExistsAndNotEmpty(\DOMElement $element, Crawler $crawler): bool + public static function elementAriaLabelledByValueExistsAndNotEmpty(DOMElement $element, Crawler $crawler): bool { $result = false; if (!$element->hasAttribute('aria-labelledby')) { @@ -80,29 +59,17 @@ public static function elementAriaLabelledByValueExistsAndNotEmpty(\DOMElement $ return $result; } - /** - * @param \DOMElement $element - * @return bool - */ - public static function elementHasNonEmptyTitle(\DOMElement $element): bool + public static function elementHasNonEmptyTitle(DOMElement $element): bool { return $element->hasAttribute('title') && $element->getAttribute('title') !== ''; } - /** - * @param \DOMElement $image - * @return bool - */ - public static function elementHasAlt(\DOMElement $image): bool + public static function elementHasAlt(DOMElement $image): bool { return $image->hasAttribute('alt'); } - /** - * @param \DOMElement $element - * @return bool - */ - public static function elementTitleNotRedundant(\DOMElement $element): bool + public static function elementTitleNotRedundant(DOMElement $element): bool { if (($element->tagName === 'a' && $element->textContent === '') || ($element->tagName === 'img' && !$element->hasAttribute('alt')) || @@ -112,32 +79,22 @@ public static function elementTitleNotRedundant(\DOMElement $element): bool return true; } - if ($element->tagName === 'a') { - $content = $element->textContent; - } else { - $content = $element->getAttribute('alt'); - } + $content = $element->tagName === 'a' ? $element->textContent : $element->getAttribute('alt'); return mb_strtolower($content) !== mb_strtolower($element->getAttribute('title')); } - /** - * @param \DOMElement $element - * @param string $attribute - * @param array $blacklist - * @return bool - */ public static function elementAttributeValueNotBlacklisted( - \DOMElement $element, + DOMElement $element, string $attribute, array $blacklist - ) { + ): bool { if (!$element->hasAttribute($attribute)) { return true; } $content = StringUtility::clearString($element->getAttribute($attribute)); - return in_array(strtolower($content), $blacklist, true) === false; + return !in_array(strtolower($content), $blacklist, true); } } diff --git a/Classes/Utility/Tests/StringUtility.php b/Classes/Utility/Tests/StringUtility.php index ef4e009..dc7a09d 100644 --- a/Classes/Utility/Tests/StringUtility.php +++ b/Classes/Utility/Tests/StringUtility.php @@ -9,9 +9,6 @@ class StringUtility { /** * Removes a fixed set of special chars from the given string - * - * @param string $string - * @return string */ public static function clearString(string $string): string { @@ -21,9 +18,6 @@ public static function clearString(string $string): string /** * Removes all new lines from the given string - * - * @param string|null $text - * @return string */ public static function stripNewLines(?string $text): string { diff --git a/Classes/ViewHelpers/Be/Security/IsAdminViewHelper.php b/Classes/ViewHelpers/Be/Security/IsAdminViewHelper.php index 29de938..d540fc7 100644 --- a/Classes/ViewHelpers/Be/Security/IsAdminViewHelper.php +++ b/Classes/ViewHelpers/Be/Security/IsAdminViewHelper.php @@ -2,20 +2,20 @@ namespace UniWue\UwA11yCheck\ViewHelpers\Be\Security; +use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; /** * Class isAdminViewHelper * * Returns, if the current backend user is admin */ -class IsAdminViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper +class IsAdminViewHelper extends AbstractConditionViewHelper { /** * Checks if the current backend user is admin * * @param array $arguments - * @return bool */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { return $GLOBALS['BE_USER']->isAdmin(); } diff --git a/Configuration/TCA/Overrides/sys_template.php b/Configuration/TCA/Overrides/sys_template.php index b0f0c4a..0ce26eb 100644 --- a/Configuration/TCA/Overrides/sys_template.php +++ b/Configuration/TCA/Overrides/sys_template.php @@ -1,11 +1,12 @@ +@import 'EXT:uw_a11y_check/Configuration/TypoScript/ContentElement/Helper/DynamicA11yContent.typoscript' #============================================== # BE-module configuration for EXT:uw_a11y_check 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/HeaderUtilityTest.php b/Tests/Unit/Tests/Utility/Tests/HeaderUtilityTest.php index 9b55876..0ea84e4 100644 --- a/Tests/Unit/Tests/Utility/Tests/HeaderUtilityTest.php +++ b/Tests/Unit/Tests/Utility/Tests/HeaderUtilityTest.php @@ -20,9 +20,9 @@ class HeaderUtilityTest extends BaseTestCase { /** - * @return array + * @return array> */ - public function headersSequentiallyDescendingTestsDataProvider() + public function headersSequentiallyDescendingTestsDataProvider(): array { return [ 'h1 followed by h2' => [ @@ -55,7 +55,7 @@ public function headersSequentiallyDescendingTestsDataProvider() * @param $htmlHeader2 * @param $expected */ - public function headersSequentiallyDescendingTests($htmlHeader1, $htmlHeader2, $expected) + public function headersSequentiallyDescendingTests(string $htmlHeader1, string $htmlHeader2, bool $expected): void { $previousDocument = new DOMDocument(); $previousDocument->loadHTML($htmlHeader1); diff --git a/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php b/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php index 50aa04f..92849e8 100644 --- a/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php +++ b/Tests/Unit/Tests/Utility/Tests/LinkUtilityTest.php @@ -8,7 +8,7 @@ * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ - +use DOMElement; use DOMDocument; use TYPO3\TestingFramework\Core\BaseTestCase; use UniWue\UwA11yCheck\Utility\Tests\LinkUtility; @@ -19,9 +19,9 @@ class LinkUtilityTest extends BaseTestCase { /** - * @return array + * @return array> */ - public function linkHasImageWithAltTestsDataProvider() + public function linkHasImageWithAltTestsDataProvider(): array { return [ 'link with no image' => [ @@ -53,12 +53,12 @@ public function linkHasImageWithAltTestsDataProvider() * @param $html * @param $expected */ - public function linkHasImageWithAltTests($html, $expected) + public function linkHasImageWithAltTests(string $html, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('a')->item(0); $result = LinkUtility::linkHasImageWithAlt($element); @@ -66,9 +66,9 @@ public function linkHasImageWithAltTests($html, $expected) } /** - * @return array + * @return array */ - public function linkTextNotBlacklistedTestsDataProvider() + public function linkTextNotBlacklistedTestsDataProvider(): array { return [ 'text not blacklisted' => [ @@ -110,13 +110,14 @@ public function linkTextNotBlacklistedTestsDataProvider() * @param $html * @param $blacklist * @param $expected + * @param string[]|mixed[] $blacklist */ - public function linkTextNotBlacklistedTests($html, $blacklist, $expected) + public function linkTextNotBlacklistedTests(string $html, array $blacklist, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('a')->item(0); $result = LinkUtility::linkTextNotBlacklisted($element, $blacklist); @@ -124,9 +125,9 @@ public function linkTextNotBlacklistedTests($html, $blacklist, $expected) } /** - * @return array + * @return array */ - public function linkImageAttributeNotBlacklistedTestsDataProvider() + public function linkImageAttributeNotBlacklistedTestsDataProvider(): array { return [ 'no blacklist' => [ @@ -175,13 +176,14 @@ public function linkImageAttributeNotBlacklistedTestsDataProvider() * @param $attribute * @param $blacklist * @param $expected + * @param mixed[]|string[] $blacklist */ - public function linkImageAttributeNotBlacklistedTests($html, $attribute, $blacklist, $expected) + public function linkImageAttributeNotBlacklistedTests(string $html, string $attribute, array $blacklist, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('a')->item(0); $result = LinkUtility::linkImageAttributeNotBlacklisted($element, $attribute, $blacklist); @@ -189,17 +191,11 @@ public function linkImageAttributeNotBlacklistedTests($html, $attribute, $blackl } /** - * @return array + * @return array> */ - public function hasRedundantLinkNamesTestsDataProvider() + public function hasRedundantLinkNamesTestsDataProvider(): array { return [ - 'no links at all' => [ - [ - '' - ], - 0 - ], 'only one link' => [ [ 'Link 1' @@ -236,8 +232,9 @@ public function hasRedundantLinkNamesTestsDataProvider() * @dataProvider hasRedundantLinkNamesTestsDataProvider * @param $html * @param $expected + * @param string[] $htmlArray */ - public function hasRedundantLinkNamesTests($htmlArray, $expected) + public function hasRedundantLinkNamesTests(array $htmlArray, int $expected): void { $elements = []; @@ -248,7 +245,7 @@ public function hasRedundantLinkNamesTests($htmlArray, $expected) $elements[] = $element; } - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $result = LinkUtility::getRedundantLinkNames($elements); self::assertEquals($expected, count($result)); diff --git a/Tests/Unit/Tests/Utility/Tests/SharedUtilityTest.php b/Tests/Unit/Tests/Utility/Tests/SharedUtilityTest.php index 20b9157..a3e7b39 100644 --- a/Tests/Unit/Tests/Utility/Tests/SharedUtilityTest.php +++ b/Tests/Unit/Tests/Utility/Tests/SharedUtilityTest.php @@ -8,7 +8,7 @@ * For the full copyright and license information, please read the * LICENSE.txt file that was distributed with this source code. */ - +use DOMElement; use DOMDocument; use Symfony\Component\DomCrawler\Crawler; use TYPO3\TestingFramework\Core\BaseTestCase; @@ -20,9 +20,9 @@ class SharedUtilityTest extends BaseTestCase { /** - * @return array + * @return array> */ - public function elementHasRolePresentationTestsDataProvider() + public function elementHasRolePresentationTestsDataProvider(): array { return [ 'role presentation present' => [ @@ -42,14 +42,14 @@ public function elementHasRolePresentationTestsDataProvider() * @param $role * @param $expected */ - public function elementHasRolePresentationTests($role, $expected) + public function elementHasRolePresentationTests(string $role, bool $expected): void { $html = '
Test
'; $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('div')->item(0); $result = SharedUtility::elementHasRolePresentation($element); @@ -57,9 +57,9 @@ public function elementHasRolePresentationTests($role, $expected) } /** - * @return array + * @return array> */ - public function elementHasRoleNoneTestsDataProvider() + public function elementHasRoleNoneTestsDataProvider(): array { return [ 'role none present' => [ @@ -79,14 +79,14 @@ public function elementHasRoleNoneTestsDataProvider() * @param $role * @param $expected */ - public function elementHasRoleNoneTests($role, $expected) + public function elementHasRoleNoneTests(string $role, bool $expected): void { $html = '
Test
'; $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('div')->item(0); $result = SharedUtility::elementHasRoleNone($element); @@ -94,9 +94,9 @@ public function elementHasRoleNoneTests($role, $expected) } /** - * @return array + * @return array> */ - public function elementHasAriaLabelValueDataProvider() + public function elementHasAriaLabelValueDataProvider(): array { return [ 'no aria label' => [ @@ -120,12 +120,12 @@ public function elementHasAriaLabelValueDataProvider() * @param $html * @param $expected */ - public function elementHasAriaLabelTests($html, $expected) + public function elementHasAriaLabelTests(string $html, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('div')->item(0); $result = SharedUtility::elementHasAriaLabelValue($element); @@ -133,9 +133,9 @@ public function elementHasAriaLabelTests($html, $expected) } /** - * @return array + * @return array> */ - public function elementAriaLabelledByValueExistsAndNotEmptyTestsDataProvider() + public function elementAriaLabelledByValueExistsAndNotEmptyTestsDataProvider(): array { return [ 'labelledby element does not exist' => [ @@ -163,11 +163,11 @@ public function elementAriaLabelledByValueExistsAndNotEmptyTestsDataProvider() * @param $html * @param $expected */ - public function elementAriaLabelledByValueExistsAndNotEmptyTests($html, $expected) + public function elementAriaLabelledByValueExistsAndNotEmptyTests(string $html, bool $expected): void { $crawler = new Crawler($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $crawler->filter('#labelledByElement')->first()->getNode(0); $result = SharedUtility::elementAriaLabelledByValueExistsAndNotEmpty($element, $crawler); @@ -175,9 +175,9 @@ public function elementAriaLabelledByValueExistsAndNotEmptyTests($html, $expecte } /** - * @return array + * @return array> */ - public function elementHasVisibleTextTestsDataProvider() + public function elementHasVisibleTextTestsDataProvider(): array { return [ 'no text in div' => [ @@ -209,12 +209,12 @@ public function elementHasVisibleTextTestsDataProvider() * @param $html * @param $expected */ - public function elementHasVisibleTextTests($html, $expected) + public function elementHasVisibleTextTests(string $html, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('div')->item(0); $result = SharedUtility::elementHasVisibleText($element); @@ -222,9 +222,9 @@ public function elementHasVisibleTextTests($html, $expected) } /** - * @return array + * @return array> */ - public function elementHasNonEmptyTitleTestsDataProvider() + public function elementHasNonEmptyTitleTestsDataProvider(): array { return [ 'no title' => [ @@ -252,12 +252,12 @@ public function elementHasNonEmptyTitleTestsDataProvider() * @param $html * @param $expected */ - public function elementHasNonEmptyTitleTests($html, $expected) + public function elementHasNonEmptyTitleTests(string $html, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('div')->item(0); $result = SharedUtility::elementHasNonEmptyTitle($element); @@ -265,9 +265,9 @@ public function elementHasNonEmptyTitleTests($html, $expected) } /** - * @return array + * @return array> */ - public function elementHasAltTestsDataProvider() + public function elementHasAltTestsDataProvider(): array { return [ 'image with no alt' => [ @@ -291,12 +291,12 @@ public function elementHasAltTestsDataProvider() * @param $html * @param $expected */ - public function elementHasAltTests($html, $expected) + public function elementHasAltTests(string $html, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('img')->item(0); $result = SharedUtility::elementHasAlt($element); @@ -304,9 +304,9 @@ public function elementHasAltTests($html, $expected) } /** - * @return array + * @return array> */ - public function elementTitleNotRedundantTestsDataProvider() + public function elementTitleNotRedundantTestsDataProvider(): array { return [ 'link has no title' => [ @@ -359,12 +359,12 @@ public function elementTitleNotRedundantTestsDataProvider() * @param $elementTag * @param $expected */ - public function elementTitleNotRedundantTests($html, $elementTag, $expected) + public function elementTitleNotRedundantTests(string $html, string $elementTag, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName($elementTag)->item(0); $result = SharedUtility::elementTitleNotRedundant($element); @@ -372,9 +372,9 @@ public function elementTitleNotRedundantTests($html, $elementTag, $expected) } /** - * @return array + * @return array> */ - public function elementAttributeValueNotBlacklistedTestsDataProvider() + public function elementAttributeValueNotBlacklistedTestsDataProvider(): array { return [ 'attibute not found' => [ @@ -405,13 +405,14 @@ public function elementAttributeValueNotBlacklistedTestsDataProvider() * @param $attribute * @param $blacklist * @param $expected + * @param string[] $blacklist */ - public function elementAttributeValueNotBlacklistedTests($html, $attribute, $blacklist, $expected) + public function elementAttributeValueNotBlacklistedTests(string $html, string $attribute, array $blacklist, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName('a')->item(0); $result = SharedUtility::elementAttributeValueNotBlacklisted($element, $attribute, $blacklist); @@ -419,9 +420,9 @@ public function elementAttributeValueNotBlacklistedTests($html, $attribute, $bla } /** - * @return array + * @return array> */ - public function elementIsLinkWithHrefTestsDataProvider() + public function elementIsLinkWithHrefTestsDataProvider(): array { return [ 'no link' => [ @@ -454,12 +455,12 @@ public function elementIsLinkWithHrefTestsDataProvider() * @param $tag * @param $expected */ - public function elementIsLinkWithHrefTests($html, $tag, $expected) + public function elementIsLinkWithHrefTests(string $html, string $tag, bool $expected): void { $doc = new DOMDocument(); $doc->loadHTML($html); - /** @var \DOMElement $element */ + /** @var DOMElement $element */ $element = $doc->getElementsByTagName($tag)->item(0); $result = SharedUtility::elementIsLinkWithHref($element); diff --git a/composer.json b/composer.json index 152df5b..b658b55 100644 --- a/composer.json +++ b/composer.json @@ -1,55 +1,56 @@ { - "name": "uniwue/uw_a11y_check", - "type": "typo3-cms-extension", - "description": "Configurable a11y check for tt_content and extension records", - "authors": [ - { - "name": "Torben Hansen on behalf of Universität Würzburg", - "email": "torben@derhansen.com", - "homepage": "https://www.uni-wuerzburg.de", - "role": "Developer" + "name": "uniwue/uw-a11y-check", + "type": "typo3-cms-extension", + "description": "Configurable a11y check for tt_content and extension records", + "authors": [ + { + "name": "Torben Hansen on behalf of Universität Würzburg", + "email": "torben@derhansen.com", + "homepage": "https://www.uni-wuerzburg.de", + "role": "Developer" + } + ], + "keywords": ["TYPO3 CMS", "a11y", "Accessibility"], + "license": [ + "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" + }, + "replace": { + "typo3-ter/uw-a11y-check": "self.version" + }, + "autoload": { + "psr-4": { + "UniWue\\UwA11yCheck\\": "Classes" + } + }, + "autoload-dev": { + "psr-4": { + "UniWue\\UwA11yCheck\\Tests\\": "Tests" + } + }, + "config": { + "vendor-dir": ".Build/vendor", + "bin-dir": ".Build/bin" + }, + "extra": { + "typo3/cms": { + "extension-key": "uw_a11y_check", + "app-dir": ".Build", + "web-dir": ".Build/Web" + } + }, + "scripts": { + "post-autoload-dump": [ + "TYPO3\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare" + ] } - ], - "keywords": ["TYPO3 CMS", "a11y", "Accessibility"], - "license": [ - "GPL-2.0+" - ], - "require": { - "typo3/cms-core": "^10.4", - "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": "*" - }, - "replace": { - "typo3-ter/uw-a11y-check": "self.version" - }, - "autoload": { - "psr-4": { - "UniWue\\UwA11yCheck\\": "Classes" - } - }, - "autoload-dev": { - "psr-4": { - "UniWue\\UwA11yCheck\\Tests\\": "Tests" - } - }, - "config": { - "vendor-dir": ".Build/vendor", - "bin-dir": ".Build/bin" - }, - "extra": { - "typo3/cms": { - "extension-key": "uw_a11y_check", - "app-dir": ".Build", - "web-dir": ".Build/Web" - } - }, - "scripts": { - "post-autoload-dump": [ - "TYPO3\\TestingFramework\\Composer\\ExtensionTestEnvironment::prepare" - ] - } } diff --git a/ext_emconf.php b/ext_emconf.php index 3983fc1..f4b27e5 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -7,14 +7,12 @@ 'author' => 'Torben Hansen on behalf of Universität Würzburg', 'author_email' => 'torben@derhansen.com', 'state' => 'beta', - 'uploadfolder' => '0', - 'createDirs' => '', - 'clearCacheOnLoad' => 1, + 'clearCacheOnLoad' => true, 'version' => '3.1.2', 'constraints' => [ 'depends' => [ - 'typo3' => '10.4.0-10.4.99', - 'php' => '7.2.0-7.4.99', + 'typo3' => '10.4.0-11.5.99', + 'php' => '8.0.0-8.2.99', ], 'conflicts' => [], 'suggests' => [], diff --git a/ext_localconf.php b/ext_localconf.php index 35cfb14..cc4c8ac 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,23 +1,28 @@ 'show', + ContentElementsController::class => 'show', ], // non-cacheable actions [ - \UniWue\UwA11yCheck\Controller\ContentElementsController::class => 'show', + ContentElementsController::class => 'show', ] ); if (TYPO3_MODE === 'BE') { - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerTypeConverter( - \UniWue\UwA11yCheck\Property\TypeConverter\PresetTypeConverter::class + ExtensionUtility::registerTypeConverter( + PresetTypeConverter::class ); } @@ -27,8 +32,8 @@ 'EXT:uw_a11y_check/Configuration/A11y/Default.yaml'; } - if (!\TYPO3\CMS\Core\Core\Environment::isComposerMode()) { - $composerAutoloadFile = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('uw_a11y_check') + if (!Environment::isComposerMode()) { + $composerAutoloadFile = ExtensionManagementUtility::extPath('uw_a11y_check') . 'Resources/Private/Php/vendor/autoload.php'; require_once($composerAutoloadFile); } diff --git a/ext_tables.php b/ext_tables.php index 83d1bab..b296599 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,19 +1,21 @@ 'index,check,results,acknowledgeResult', + A11yCheckController::class => 'index,check,results,acknowledgeResult', ], [ 'access' => 'user,group', diff --git a/rector.php b/rector.php new file mode 100644 index 0000000..81bd44b --- /dev/null +++ b/rector.php @@ -0,0 +1,18 @@ +import(__DIR__ . '/../../rector/rector.php'); + + $rectorBasePath = __DIR__; + + // Optional non-php file functionalities: + // @see https://github.com/sabbelasichon/typo3-rector/blob/main/docs/beyond_php_file_processors.md + + // Rewrite your extbase persistence class mapping from typoscript into php according to official docs. + // This processor will create a summarized file with all the typoscript rewrites combined into a single file. + +};