From 5b4a3799785a955f73b6bb1183c4ba6e265208ce Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Fri, 16 Sep 2022 13:53:49 +0200 Subject: [PATCH] Add strict_types and move namespace definition To follow my new conventions. --- Classes/Command/UpdateDataCommand.php | 4 +++- Classes/Dashboard/Provider/NewestPageviews.php | 4 +++- Classes/Dashboard/Provider/PageviewsPerDay.php | 4 +++- .../Provider/PageviewsPerOperatingSystem.php | 4 +++- Classes/Dashboard/Provider/PageviewsPerPage.php | 6 ++++-- Classes/Dashboard/Provider/Recordviews.php | 9 +++++++-- Classes/Domain/Model/Extractor.php | 4 +++- Classes/Domain/Model/HasUserAgent.php | 4 +++- Classes/Domain/Model/Pageview.php | 4 +++- Classes/Domain/Model/RecordRule.php | 4 +++- Classes/Domain/Model/Recordview.php | 4 +++- Classes/Domain/Pageview/Factory.php | 12 +++++++----- Classes/Domain/Recordview/Factory.php | 4 +++- Classes/Domain/Repository/Pageview.php | 4 +++- Classes/Domain/Repository/Recordview.php | 4 +++- Classes/Extension.php | 4 +++- Classes/Hooks/DataHandler.php | 4 +++- Classes/Middleware/Pageview.php | 4 +++- Classes/Middleware/Recordview.php | 4 +++- 19 files changed, 66 insertions(+), 25 deletions(-) diff --git a/Classes/Command/UpdateDataCommand.php b/Classes/Command/UpdateDataCommand.php index 158861b..4aa4f07 100644 --- a/Classes/Command/UpdateDataCommand.php +++ b/Classes/Command/UpdateDataCommand.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Command; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Command; + use DanielSiepmann\Tracking\Domain\Repository\Pageview; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\ProgressBar; diff --git a/Classes/Dashboard/Provider/NewestPageviews.php b/Classes/Dashboard/Provider/NewestPageviews.php index 9c8ad5f..0609db2 100644 --- a/Classes/Dashboard/Provider/NewestPageviews.php +++ b/Classes/Dashboard/Provider/NewestPageviews.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Dashboard\Provider; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Dashboard\Provider; + use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface; diff --git a/Classes/Dashboard/Provider/PageviewsPerDay.php b/Classes/Dashboard/Provider/PageviewsPerDay.php index e1ce108..f44165b 100644 --- a/Classes/Dashboard/Provider/PageviewsPerDay.php +++ b/Classes/Dashboard/Provider/PageviewsPerDay.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Dashboard\Provider; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Dashboard\Provider; + use DanielSiepmann\Tracking\Extension; use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Query\QueryBuilder; diff --git a/Classes/Dashboard/Provider/PageviewsPerOperatingSystem.php b/Classes/Dashboard/Provider/PageviewsPerOperatingSystem.php index 91bb5f6..23da1ee 100644 --- a/Classes/Dashboard/Provider/PageviewsPerOperatingSystem.php +++ b/Classes/Dashboard/Provider/PageviewsPerOperatingSystem.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Dashboard\Provider; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Dashboard\Provider; + use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\Query\QueryBuilder; use TYPO3\CMS\Dashboard\WidgetApi; diff --git a/Classes/Dashboard/Provider/PageviewsPerPage.php b/Classes/Dashboard/Provider/PageviewsPerPage.php index 9ac47bc..e07cf32 100644 --- a/Classes/Dashboard/Provider/PageviewsPerPage.php +++ b/Classes/Dashboard/Provider/PageviewsPerPage.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Dashboard\Provider; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Dashboard\Provider; + use DanielSiepmann\Tracking\Extension; use Doctrine\DBAL\ParameterType; use TYPO3\CMS\Backend\Utility\BackendUtility; @@ -144,7 +146,7 @@ class PageviewsPerPage implements ChartDataProviderInterface continue; } - $labels[] = $this->getRecordTitle($row['pid']); + $labels[] = $this->getRecordTitle((int) $row['pid']); $data[] = $row['total']; } diff --git a/Classes/Dashboard/Provider/Recordviews.php b/Classes/Dashboard/Provider/Recordviews.php index 9aed165..c0f7122 100644 --- a/Classes/Dashboard/Provider/Recordviews.php +++ b/Classes/Dashboard/Provider/Recordviews.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Dashboard\Provider; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Dashboard\Provider; + use DanielSiepmann\Tracking\Extension; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Statement; @@ -117,8 +119,11 @@ class Recordviews implements ChartDataProviderInterface $data = []; foreach ($this->getRecordviewsRecords() as $recordview) { + if (is_numeric($recordview['record_uid']) === false) { + continue; + } $record = $this->getRecord( - $recordview['record_uid'], + (int) $recordview['record_uid'], $recordview['record_table_name'] ); diff --git a/Classes/Domain/Model/Extractor.php b/Classes/Domain/Model/Extractor.php index 0ec7da9..1bea76e 100644 --- a/Classes/Domain/Model/Extractor.php +++ b/Classes/Domain/Model/Extractor.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Model; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Model; + /** * API to extract further info out of an model. */ diff --git a/Classes/Domain/Model/HasUserAgent.php b/Classes/Domain/Model/HasUserAgent.php index eabf7a6..6c3a686 100644 --- a/Classes/Domain/Model/HasUserAgent.php +++ b/Classes/Domain/Model/HasUserAgent.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Model; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Model; + interface HasUserAgent { public function getUserAgent(): string; diff --git a/Classes/Domain/Model/Pageview.php b/Classes/Domain/Model/Pageview.php index 0a91655..a09fca8 100644 --- a/Classes/Domain/Model/Pageview.php +++ b/Classes/Domain/Model/Pageview.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Model; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Model; + use TYPO3\CMS\Core\Site\Entity\SiteLanguage; class Pageview implements HasUserAgent diff --git a/Classes/Domain/Model/RecordRule.php b/Classes/Domain/Model/RecordRule.php index 32ebf69..15438c2 100644 --- a/Classes/Domain/Model/RecordRule.php +++ b/Classes/Domain/Model/RecordRule.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Model; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Model; + class RecordRule { /** diff --git a/Classes/Domain/Model/Recordview.php b/Classes/Domain/Model/Recordview.php index 72e068b..46407fd 100644 --- a/Classes/Domain/Model/Recordview.php +++ b/Classes/Domain/Model/Recordview.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Model; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Model; + use TYPO3\CMS\Core\Site\Entity\SiteLanguage; class Recordview implements HasUserAgent diff --git a/Classes/Domain/Pageview/Factory.php b/Classes/Domain/Pageview/Factory.php index b8687ce..3b5ccb1 100644 --- a/Classes/Domain/Pageview/Factory.php +++ b/Classes/Domain/Pageview/Factory.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Pageview; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Pageview; + use DanielSiepmann\Tracking\Domain\Model\Pageview; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Routing\PageArguments; @@ -54,13 +56,13 @@ class Factory public function fromDbRow(array $dbRow): Pageview { return new Pageview( - $dbRow['pid'], - $this->siteFinder->getSiteByPageId($dbRow['pid'])->getLanguageById($dbRow['sys_language_uid']), + (int) $dbRow['pid'], + $this->siteFinder->getSiteByPageId((int) $dbRow['pid'])->getLanguageById((int) $dbRow['sys_language_uid']), new \DateTimeImmutable('@' . $dbRow['crdate']), - $dbRow['type'], + (int) $dbRow['type'], $dbRow['url'], $dbRow['user_agent'], - $dbRow['uid'] + (int) $dbRow['uid'] ); } diff --git a/Classes/Domain/Recordview/Factory.php b/Classes/Domain/Recordview/Factory.php index f4761b5..06ebbea 100644 --- a/Classes/Domain/Recordview/Factory.php +++ b/Classes/Domain/Recordview/Factory.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Recordview; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Recordview; + use DanielSiepmann\Tracking\Domain\Model\RecordRule; use DanielSiepmann\Tracking\Domain\Model\Recordview; use Psr\Http\Message\ServerRequestInterface; diff --git a/Classes/Domain/Repository/Pageview.php b/Classes/Domain/Repository/Pageview.php index f24df7b..856c568 100644 --- a/Classes/Domain/Repository/Pageview.php +++ b/Classes/Domain/Repository/Pageview.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Repository; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Repository; + use DanielSiepmann\Tracking\Domain\Model\Pageview as Model; use DanielSiepmann\Tracking\Domain\Pageview\Factory; use TYPO3\CMS\Core\Database\Connection; diff --git a/Classes/Domain/Repository/Recordview.php b/Classes/Domain/Repository/Recordview.php index cded3d5..15edb4f 100644 --- a/Classes/Domain/Repository/Recordview.php +++ b/Classes/Domain/Repository/Recordview.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Domain\Repository; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Domain\Repository; + use DanielSiepmann\Tracking\Domain\Model\Recordview as Model; use TYPO3\CMS\Core\Database\Connection; diff --git a/Classes/Extension.php b/Classes/Extension.php index 227fa52..4b005d2 100644 --- a/Classes/Extension.php +++ b/Classes/Extension.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking; + final class Extension { public const EXT_KEY = 'tracking'; diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index 596b961..98c33a7 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Hooks; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Hooks; + use TYPO3\CMS\Core\DataHandling\DataHandler as Typo3DataHandler; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; diff --git a/Classes/Middleware/Pageview.php b/Classes/Middleware/Pageview.php index 276ae07..658b6c1 100644 --- a/Classes/Middleware/Pageview.php +++ b/Classes/Middleware/Pageview.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Middleware; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Middleware; + use DanielSiepmann\Tracking\Domain\Pageview\Factory; use DanielSiepmann\Tracking\Domain\Repository\Pageview as Repository; use Psr\Http\Message\ResponseInterface; diff --git a/Classes/Middleware/Recordview.php b/Classes/Middleware/Recordview.php index 449b75d..17deff0 100644 --- a/Classes/Middleware/Recordview.php +++ b/Classes/Middleware/Recordview.php @@ -1,6 +1,6 @@ @@ -21,6 +21,8 @@ namespace DanielSiepmann\Tracking\Middleware; * 02110-1301, USA. */ +namespace DanielSiepmann\Tracking\Middleware; + use DanielSiepmann\Tracking\Domain\Model\RecordRule; use DanielSiepmann\Tracking\Domain\Recordview\Factory; use DanielSiepmann\Tracking\Domain\Repository\Recordview as Repository;