From f41458cc4026ff8ee47e6c5683486ec0b31d710a Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Wed, 19 Jun 2024 12:21:44 +0200 Subject: [PATCH 1/6] [TASK] Update rector and run (#165) * [TASK] Update rector and run * [BUGFIX] Remove GridElements form TtContent Domain Model Remove all setter methods from this read model. Replace @return comment with type hint for all getter methods. --- Classes/Controller/ProductController.php | 43 +- .../Model/Dto/Product/ProductDemand.php | 2 +- Classes/Domain/Model/Product/BeVariant.php | 32 +- Classes/Domain/Model/Product/FeVariant.php | 8 +- Classes/Domain/Model/Product/Product.php | 14 +- .../Product/ProductBackendVariantTrait.php | 2 +- .../Domain/Model/Product/QuantityDiscount.php | 7 +- Classes/Domain/Model/Product/SpecialPrice.php | 8 +- Classes/Domain/Model/TtContent.php | 1268 ++--------------- .../Repository/Product/ProductRepository.php | 15 +- .../RetrieveProductsFromRequestEvent.php | 13 +- .../CheckProductAvailability.php | 16 +- Classes/EventListener/Create/CheckRequest.php | 11 +- .../Create/CreateCartBackendVariants.php | 26 +- .../Create/CreateCartFrontendVariants.php | 5 +- Classes/EventListener/Create/LoadProduct.php | 16 +- .../EventListener/Order/Stock/HandleStock.php | 6 +- .../RetrieveProductsFromRequest.php | 16 +- Classes/Hooks/DataHandler.php | 4 +- Classes/Hooks/DatamapDataHandlerHook.php | 6 +- Classes/Updates/SlugUpdater.php | 37 +- .../ViewHelpers/CanonicalTagViewHelper.php | 15 +- .../Form/VariantSelectViewHelper.php | 10 +- .../Product/AbstractProductViewHelper.php | 2 +- .../IfBestSpecialPriceAvailableViewHelper.php | 2 +- Configuration/TCA/Overrides/tt_content.php | 2 +- ...tproducts_domain_model_product_product.php | 19 +- ...roducts_domain_model_product_bevariant.php | 19 +- ...omain_model_product_bevariantattribute.php | 8 +- ...model_product_bevariantattributeoption.php | 8 +- ...tproducts_domain_model_product_product.php | 38 +- ..._domain_model_product_quantitydiscount.php | 7 +- ...ucts_domain_model_product_specialprice.php | 12 +- .../Product/ProductRepositoryTest.php | 8 +- Tests/Unit/Domain/Model/CategoryTest.php | 2 +- .../Model/Product/BeVariantAttributeTest.php | 8 +- .../Domain/Model/Product/BeVariantTest.php | 42 +- .../Domain/Model/Product/FeVariantTest.php | 16 +- .../Unit/Domain/Model/Product/ProductTest.php | 94 +- .../Model/Product/QuantityDiscountTest.php | 8 +- .../Domain/Model/Product/SpecialPriceTest.php | 8 +- composer.json | 2 +- ext_localconf.php | 48 +- rector.php | 118 +- 44 files changed, 414 insertions(+), 1637 deletions(-) diff --git a/Classes/Controller/ProductController.php b/Classes/Controller/ProductController.php index 5bb3328d..7ebea80c 100644 --- a/Classes/Controller/ProductController.php +++ b/Classes/Controller/ProductController.php @@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Annotation\IgnoreValidation; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; +use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException; use TYPO3\CMS\Extbase\Http\ForwardResponse; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; @@ -32,40 +33,22 @@ class ProductController extends ActionController { - protected ExtensionService $extensionService; - - protected SessionHandler $sessionHandler; - protected Cart $cart; - - protected CartUtility $cartUtility; - - protected ProductRepository $productRepository; - - protected CategoryRepository $categoryRepository; - protected array $searchArguments = []; - protected array $cartConfiguration = []; public function __construct( - ExtensionService $extensionService, - SessionHandler $sessionHandler, - CartUtility $cartUtility, - ProductRepository $productRepository, - CategoryRepository $categoryRepository - ) { - $this->extensionService = $extensionService; - $this->sessionHandler = $sessionHandler; - $this->cartUtility = $cartUtility; - $this->productRepository = $productRepository; - $this->categoryRepository = $categoryRepository; - } + protected readonly ExtensionService $extensionService, + protected readonly SessionHandler $sessionHandler, + protected readonly CartUtility $cartUtility, + protected readonly ProductRepository $productRepository, + protected readonly CategoryRepository $categoryRepository + ) {} protected function initializeAction() { $this->cartConfiguration = $this->configurationManager->getConfiguration( - ConfigurationManager::CONFIGURATION_TYPE_FRAMEWORK, + ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, 'Cart' ); @@ -143,7 +126,7 @@ protected function addCategoriesToDemandObjectFromSettings(ProductDemand $demand public function listAction(int $currentPage = 1): ResponseInterface { $demand = $this->createDemandObjectFromSettings($this->settings); - $demand->setActionAndClass(__METHOD__, __CLASS__); + $demand->setActionAndClass(__METHOD__, self::class); $itemsPerPage = $this->settings['itemsPerPage'] ?? 20; @@ -172,9 +155,7 @@ public function listAction(int $currentPage = 1): ResponseInterface return $this->htmlResponse(); } - /** - * @IgnoreValidation("product") - */ + #[IgnoreValidation(['value' => 'product'])] public function showAction(Product $product = null): ResponseInterface { if (!$product) { @@ -222,7 +203,7 @@ public function teaserAction(): ResponseInterface public function flexformAction(): ResponseInterface { - $contentObj = $this->configurationManager->getContentObject(); + $contentObj = $this->request->getAttribute('currentContentObject'); $contentId = $contentObj->data['uid']; $this->view->assign('contentId', $contentId); @@ -267,7 +248,7 @@ public function getProductUid(): mixed TypoScriptService::class ); $configuration = $typoscriptService->convertPlainArrayToTypoScriptArray($configuration); - $productUid = (int)$configurationManager->getContentObject()->cObjGetSingle($configuration['product'], $configuration['product.']); + $productUid = (int)$this->request->getAttribute('currentContentObject')->cObjGetSingle($configuration['product'], $configuration['product.']); if ($productUid === 0) { $configurationManager->setConfiguration([ diff --git a/Classes/Domain/Model/Dto/Product/ProductDemand.php b/Classes/Domain/Model/Dto/Product/ProductDemand.php index 6eb900ad..93709118 100644 --- a/Classes/Domain/Model/Dto/Product/ProductDemand.php +++ b/Classes/Domain/Model/Dto/Product/ProductDemand.php @@ -40,7 +40,7 @@ public function getTitle(): ?string return $this->title; } - public function setTitle(string $title) + public function setTitle(string $title): void { $this->title = $title; } diff --git a/Classes/Domain/Model/Product/BeVariant.php b/Classes/Domain/Model/Product/BeVariant.php index 8552365a..1be98ef3 100644 --- a/Classes/Domain/Model/Product/BeVariant.php +++ b/Classes/Domain/Model/Product/BeVariant.php @@ -27,9 +27,9 @@ class BeVariant extends AbstractEntity protected float $price = 0.0; /** - * @Cascade("remove") * @var ObjectStorage */ + #[Cascade(['value' => 'remove'])] protected ObjectStorage $specialPrices; protected int $priceCalcMethod = 0; @@ -91,16 +91,11 @@ public function getPriceCalculated(): float $parentPrice = $this->getProduct()->getPrice(); - switch ($this->priceCalcMethod) { - case 3: - $calc_price = -1 * (($price / 100) * ($parentPrice)); - break; - case 5: - $calc_price = ($price / 100) * ($parentPrice); - break; - default: - $calc_price = 0; - } + $calc_price = match ($this->priceCalcMethod) { + 3 => -1 * (($price / 100) * ($parentPrice)), + 5 => ($price / 100) * ($parentPrice), + default => 0, + }; if ( isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) && @@ -142,16 +137,11 @@ public function getBestPriceCalculated($frontendUserGroupIds = []): float $parentPrice = $this->getProduct()->getBestSpecialPrice($frontendUserGroupIds); - switch ($this->priceCalcMethod) { - case 3: - $calc_price = -1 * (($price / 100) * ($parentPrice)); - break; - case 5: - $calc_price = ($price / 100) * ($parentPrice); - break; - default: - $calc_price = 0; - } + $calc_price = match ($this->priceCalcMethod) { + 3 => -1 * (($price / 100) * ($parentPrice)), + 5 => ($price / 100) * ($parentPrice), + default => 0, + }; if ( isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['cart']['changeVariantDiscount']) && diff --git a/Classes/Domain/Model/Product/FeVariant.php b/Classes/Domain/Model/Product/FeVariant.php index 38bcc7b6..f5e72f2f 100644 --- a/Classes/Domain/Model/Product/FeVariant.php +++ b/Classes/Domain/Model/Product/FeVariant.php @@ -14,14 +14,10 @@ class FeVariant extends AbstractEntity { - /** - * @Validate("NotEmpty") - */ + #[Validate(['validator' => 'NotEmpty'])] protected string $sku = ''; - /** - * @Validate("NotEmpty") - */ + #[Validate(['validator' => 'NotEmpty'])] protected string $title = ''; protected string $description = ''; diff --git a/Classes/Domain/Model/Product/Product.php b/Classes/Domain/Model/Product/Product.php index 1086dfa5..4b3f6244 100644 --- a/Classes/Domain/Model/Product/Product.php +++ b/Classes/Domain/Model/Product/Product.php @@ -32,9 +32,9 @@ class Product extends AbstractProduct protected string $productType = 'simple'; /** - * @Lazy * @var ObjectStorage */ + #[Lazy] protected ?ObjectStorage $productContent = null; protected int $minNumberInOrder = 0; @@ -46,35 +46,35 @@ class Product extends AbstractProduct protected float $price = 0.0; /** - * @Cascade("remove") * @var ObjectStorage */ + #[Cascade(['value' => 'remove'])] protected ObjectStorage $specialPrices; /** - * @Cascade("remove") * @var ObjectStorage */ + #[Cascade(['value' => 'remove'])] protected ObjectStorage $quantityDiscounts; protected int $taxClassId = 1; /** - * @Cascade("remove") * @var ObjectStorage */ + #[Cascade(['value' => 'remove'])] protected ObjectStorage $feVariants; /** - * @Lazy * @var ObjectStorage */ + #[Lazy] protected ?ObjectStorage $relatedProducts = null; /** - * @Lazy * @var ObjectStorage */ + #[Lazy] protected ?ObjectStorage $relatedProductsFrom = null; protected int $stock = 0; @@ -132,7 +132,7 @@ public function getMaxNumberInOrder(): int return $this->maxNumberInOrder; } - public function setMaxNumberInOrder(int $maxNumberInOrder) + public function setMaxNumberInOrder(int $maxNumberInOrder): void { if ($maxNumberInOrder < 0 || (($maxNumberInOrder !== 0) && ($maxNumberInOrder < $this->minNumberInOrder))) { throw new \InvalidArgumentException(); diff --git a/Classes/Domain/Model/Product/ProductBackendVariantTrait.php b/Classes/Domain/Model/Product/ProductBackendVariantTrait.php index 097f0e4a..4774eb08 100644 --- a/Classes/Domain/Model/Product/ProductBackendVariantTrait.php +++ b/Classes/Domain/Model/Product/ProductBackendVariantTrait.php @@ -21,9 +21,9 @@ trait ProductBackendVariantTrait protected ?BeVariantAttribute $beVariantAttribute3 = null; /** - * @Cascade("remove") * @var ObjectStorage */ + #[Cascade(['value' => 'remove'])] protected ObjectStorage $beVariants; public function getBeVariantAttribute1(): ?BeVariantAttribute diff --git a/Classes/Domain/Model/Product/QuantityDiscount.php b/Classes/Domain/Model/Product/QuantityDiscount.php index 37c92125..71e65339 100644 --- a/Classes/Domain/Model/Product/QuantityDiscount.php +++ b/Classes/Domain/Model/Product/QuantityDiscount.php @@ -15,16 +15,13 @@ class QuantityDiscount extends AbstractEntity { - /** - * @Validate("NotEmpty") - */ + #[Validate(['validator' => 'NotEmpty'])] protected float $price = 0.0; /** * Quantity (lower bound) - * - * @Validate("NotEmpty") */ + #[Validate(['validator' => 'NotEmpty'])] protected int $quantity = 0; protected ?FrontendUserGroup $frontendUserGroup = null; diff --git a/Classes/Domain/Model/Product/SpecialPrice.php b/Classes/Domain/Model/Product/SpecialPrice.php index cdc167db..5420fd13 100644 --- a/Classes/Domain/Model/Product/SpecialPrice.php +++ b/Classes/Domain/Model/Product/SpecialPrice.php @@ -15,14 +15,10 @@ class SpecialPrice extends AbstractEntity { - /** - * @Validate("NotEmpty") - */ + #[Validate(['validator' => 'NotEmpty'])] protected string $title = ''; - /** - * @Validate("NotEmpty") - */ + #[Validate(['validator' => 'NotEmpty'])] protected float $price = 0.0; protected ?FrontendUserGroup $frontendUserGroup = null; diff --git a/Classes/Domain/Model/TtContent.php b/Classes/Domain/Model/TtContent.php index 480d76f0..b3c6e12c 100644 --- a/Classes/Domain/Model/TtContent.php +++ b/Classes/Domain/Model/TtContent.php @@ -13,1402 +13,382 @@ class TtContent extends AbstractEntity { - /** - * @var \DateTime - */ - protected $crdate; - - /** - * @var \DateTime - */ - protected $tstamp; - - /** - * @var string - */ - protected $contentType; - - /** - * @var string - */ - protected $header; - - /** - * @var string - */ - protected $headerPosition; - - /** - * @var string - */ - protected $bodytext; - - /** - * @var int - */ - protected $colPos; - - /** - * @var string - */ - protected $image; - - /** - * @var int - */ - protected $imagewidth; - - /** - * @var int - */ - protected $imageheight; - - /** - * @var int - */ - protected $imageorient; - - /** - * @var string - */ - protected $imagecaption; - - /** - * @var int - */ - protected $imagecols; - - /** - * @var int - */ - protected $imageborder; - - /** - * @var string - */ - protected $media; - - /** - * @var string - */ - protected $layout; - - /** - * @var int - */ - protected $cols; - - /** - * @var string - */ - protected $subheader; - - /** - * @var string - */ - protected $headerLink; - - /** - * @var string - */ - protected $imageLink; - - /** - * @var string - */ - protected $imageZoom; - - /** - * @var string - */ - protected $altText; - - /** - * @var string - */ - protected $titleText; - - /** - * @var string - */ - protected $headerLayout; - - /** - * @var string - */ - protected $listType; - - /** - * @var string - */ - protected $records; - - /** - * @var string - */ - protected $pages; - - /** - * @var string - */ - protected $feGroup; - - /** - * @var string - */ - protected $imagecaptionPosition; - - /** - * @var string - */ - protected $longdescUrl; - - /** - * @var string - */ - protected $menuType; - - /** - * @var string - */ - protected $selectKey; - - /** - * @var string - */ - protected $fileCollections; - - /** - * @var string - */ - protected $filelinkSorting; - - /** - * @var string - */ - protected $target; - - /** - * @var string - */ - protected $multimedia; - - /** - * @var string - */ - protected $piFlexform; - - /** - * @var string - */ - protected $accessibilityTitle; - - /** - * @var string - */ - protected $accessibilityBypassText; - - /** - * @var string - */ - protected $selectedCategories; - - /** - * @var string - */ - protected $categoryField; - - /** - * @var int - */ - protected $spaceBefore; - - /** - * @var int - */ - protected $spaceAfter; - - /** - * @var int - */ - protected $imageNoRows; - - /** - * @var int - */ - protected $imageEffects; - - /** - * @var int - */ - protected $imageCompression; - - /** - * @var int - */ - protected $tableBorder; - - /** - * @var int - */ - protected $tableCellspacing; - - /** - * @var int - */ - protected $tableCellpadding; - - /** - * @var int - */ - protected $tableBgColor; - - /** - * @var int - */ - protected $sectionIndex; - - /** - * @var int - */ - protected $linkToTop; - - /** - * @var int - */ - protected $filelinkSize; - - /** - * @var int - */ - protected $sectionFrame; - - /** - * @var int - */ - protected $date; - - /** - * @var int - */ - protected $imageFrames; - - /** - * @var int - */ - protected $recursive; - - /** - * @var int - */ - protected $rteEnabled; - - /** - * @var int - */ - protected $txImpexpOriguid; - - /** - * @var int - */ - protected $accessibilityBypass; - - /** - * @var int - */ - protected $sysLanguageUid; - - /** - * @var int - */ - protected $starttime; - - /** - * @var int - */ - protected $endtime; - - /** - * @var string - */ - protected $txGridelementsBackendLayout; - - /** - * @var int - */ - protected $txGridelementsChildren; - - /** - * @var int - */ - protected $txGridelementsContainer; - - /** - * @var int - */ - protected $txGridelementsColumns; + protected \DateTime $crdate; + protected \DateTime $tstamp; + protected string $contentType; + protected string $header; + protected string $headerPosition; + protected string $bodytext; + protected int $colPos; + protected string $image; + protected int $imagewidth; + protected int $imageheight; + protected int $imageorient; + protected string $imagecaption; + protected int $imagecols; + protected int $imageborder; + protected string $media; + protected string $layout; + protected int $cols; + protected string $subheader; + protected string $headerLink; + protected string $imageLink; + protected string $imageZoom; + protected string $altText; + protected string $titleText; + protected string $headerLayout; + protected string $listType; + protected string $records; + protected string $pages; + protected string $feGroup; + protected string $imagecaptionPosition; + protected string $longdescUrl; + protected string $menuType; + protected string $selectKey; + protected string $fileCollections; + protected string $filelinkSorting; + protected string $target; + protected string $multimedia; + protected string $piFlexform; + protected string $accessibilityTitle; + protected string $accessibilityBypassText; + protected string $selectedCategories; + protected string $categoryField; + protected int $spaceBefore; + protected int $spaceAfter; + protected int $imageNoRows; + protected int $imageEffects; + protected int $imageCompression; + protected int $tableBorder; + protected int $tableCellspacing; + protected int $tableCellpadding; + protected int $tableBgColor; + protected int $sectionIndex; + protected int $linkToTop; + protected int $filelinkSize; + protected int $sectionFrame; + protected int $date; + protected int $imageFrames; + protected int $recursive; + protected int $rteEnabled; + protected int $txImpexpOriguid; + protected int $accessibilityBypass; + protected int $sysLanguageUid; + protected int $starttime; + protected int $endtime; public function getCrdate(): \DateTime { return $this->crdate; } - public function setCrdate(\DateTime $crdate) - { - $this->crdate = $crdate; - } - public function getTstamp(): \DateTime { return $this->tstamp; } - public function setTstamp(\DateTime $tstamp) - { - $this->tstamp = $tstamp; - } - - /** - * @return string - */ - public function getContentType() + public function getContentType(): string { return $this->contentType; } - /** - * @param $contentType - */ - public function setContentType($contentType) - { - $this->contentType = $contentType; - } - - /** - * @return string - */ - public function getHeader() + public function getHeader(): string { return $this->header; } - /** - * @param $header - */ - public function setHeader($header) - { - $this->header = $header; - } - - /** - * @return string - */ - public function getHeaderPosition() + public function getHeaderPosition(): string { return $this->headerPosition; } - /** - * @param $headerPosition - */ - public function setHeaderPosition($headerPosition) - { - $this->headerPosition = $headerPosition; - } - - /** - * @return string - */ - public function getBodytext() + public function getBodytext(): string { return $this->bodytext; } - /** - * @param $bodytext - */ - public function setBodytext($bodytext) - { - $this->bodytext = $bodytext; - } - - /** - * Get the colpos - * - * @return int - */ - public function getColPos() - { - return (int)$this->colPos; - } - - /** - * Set colpos - * - * @param int $colPos - */ - public function setColPos($colPos) + public function getColPos(): int { - $this->colPos = $colPos; + return $this->colPos; } - /** - * @return string - */ - public function getImage() + public function getImage(): string { return $this->image; } - /** - * @param $image - */ - public function setImage($image) - { - $this->image = $image; - } - - /** - * @return int - */ - public function getImagewidth() + public function getImagewidth(): int { return $this->imagewidth; } - /** - * @param $imagewidth - */ - public function setImagewidth($imagewidth) - { - $this->imagewidth = $imagewidth; - } - - /** - * @return int - */ - public function getImageheight() + public function getImageheight(): int { return $this->imageheight; } - /** - * @param $imageheight - */ - public function setImageheight($imageheight) - { - $this->imageheight = $imageheight; - } - - /** - * @return int - */ - public function getImageorient() + public function getImageorient(): int { return $this->imageorient; } - /** - * @param $imageorient - */ - public function setImageorient($imageorient) - { - $this->imageorient = $imageorient; - } - - /** - * @return string - */ - public function getImagecaption() + public function getImagecaption(): string { return $this->imagecaption; } - /** - * @param $imagecaption - */ - public function setImagecaption($imagecaption) - { - $this->imagecaption = $imagecaption; - } - - /** - * @return int - */ - public function getImagecols() + public function getImagecols(): int { return $this->imagecols; } - /** - * @param $imagecols - */ - public function setImagecols($imagecols) - { - $this->imagecols = $imagecols; - } - - /** - * @return int - */ - public function getImageborder() + public function getImageborder(): int { return $this->imageborder; } - /** - * @param $imageborder - */ - public function setImageborder($imageborder) - { - $this->imageborder = $imageborder; - } - - /** - * @return string - */ - public function getMedia() + public function getMedia(): string { return $this->media; } - /** - * @param $media - */ - public function setMedia($media) - { - $this->media = $media; - } - - /** - * @return string - */ - public function getLayout() + public function getLayout(): string { return $this->layout; } - /** - * @param $layout - */ - public function setLayout($layout) - { - $this->layout = $layout; - } - - /** - * @return int - */ - public function getCols() + public function getCols(): int { return $this->cols; } - /** - * @param $cols - */ - public function setCols($cols) - { - $this->cols = $cols; - } - - /** - * @return string - */ - public function getSubheader() + public function getSubheader(): string { return $this->subheader; } - /** - * @param $subheader - */ - public function setSubheader($subheader) - { - $this->subheader = $subheader; - } - - /** - * @return string - */ - public function getHeaderLink() + public function getHeaderLink(): string { return $this->headerLink; } - /** - * @param $headerLink - */ - public function setHeaderLink($headerLink) - { - $this->headerLink = $headerLink; - } - - /** - * @return string - */ - public function getImageLink() + public function getImageLink(): string { return $this->imageLink; } - /** - * @param $imageLink - */ - public function setImageLink($imageLink) - { - $this->imageLink = $imageLink; - } - - /** - * @return string - */ - public function getImageZoom() + public function getImageZoom(): string { return $this->imageZoom; } - /** - * @param $imageZoom - */ - public function setImageZoom($imageZoom) - { - $this->imageZoom = $imageZoom; - } - - /** - * @return string - */ - public function getAltText() + public function getAltText(): string { return $this->altText; } - /** - * @param $altText - */ - public function setAltText($altText) - { - $this->altText = $altText; - } - - /** - * @return string - */ - public function getTitleText() + public function getTitleText(): string { return $this->titleText; } - /** - * @param $titleText - */ - public function setTitleText($titleText) - { - $this->titleText = $titleText; - } - - /** - * @return string - */ - public function getHeaderLayout() + public function getHeaderLayout(): string { return $this->headerLayout; } - /** - * @param $headerLayout - */ - public function setHeaderLayout($headerLayout) - { - $this->headerLayout = $headerLayout; - } - - /** - * @return string - */ - public function getListType() + public function getListType(): string { return $this->listType; } - /** - * @param string $listType - */ - public function setListType($listType) - { - $this->listType = $listType; - } - - /** - * @return string - */ - public function getRecords() + public function getRecords(): string { return $this->records; } - /** - * @param $records - */ - public function setRecords($records) - { - $this->records = $records; - } - - /** - * @return string - */ - public function getPages() + public function getPages(): string { return $this->pages; } - /** - * @param $pages - */ - public function setPages($pages) - { - $this->pages = $pages; - } - - /** - * @return string - */ - public function getFeGroup() + public function getFeGroup(): string { return $this->feGroup; } - /** - * @param $feGroup - */ - public function setFeGroup($feGroup) - { - $this->feGroup = $feGroup; - } - - /** - * @return string - */ - public function getImagecaptionPosition() + public function getImagecaptionPosition(): string { return $this->imagecaptionPosition; } - /** - * @param $imagecaptionPosition - */ - public function setImagecaptionPosition($imagecaptionPosition) - { - $this->imagecaptionPosition = $imagecaptionPosition; - } - - /** - * @return string - */ - public function getLongdescUrl() + public function getLongdescUrl(): string { return $this->longdescUrl; } - /** - * @param $longdescUrl - */ - public function setLongdescUrl($longdescUrl) - { - $this->longdescUrl = $longdescUrl; - } - - /** - * @return string - */ - public function getMenuType() + public function getMenuType(): string { return $this->menuType; } - /** - * @param $menuType - */ - public function setMenuType($menuType) - { - $this->menuType = $menuType; - } - - /** - * @return string - */ - public function getSelectKey() + public function getSelectKey(): string { return $this->selectKey; } - /** - * @param $selectKey - */ - public function setSelectKey($selectKey) - { - $this->selectKey = $selectKey; - } - - /** - * @return string - */ - public function getFileCollections() + public function getFileCollections(): string { return $this->fileCollections; } - /** - * @param $fileCollections - */ - public function setFileCollections($fileCollections) - { - $this->fileCollections = $fileCollections; - } - - /** - * @return string - */ - public function getFilelinkSorting() + public function getFilelinkSorting(): string { return $this->filelinkSorting; } - /** - * @param $filelinkSorting - */ - public function setFilelinkSorting($filelinkSorting) - { - $this->filelinkSorting = $filelinkSorting; - } - - /** - * @return string - */ - public function getTarget() + public function getTarget(): string { return $this->target; } - /** - * @param $target - */ - public function setTarget($target) - { - $this->target = $target; - } - - /** - * @return string - */ - public function getMultimedia() + public function getMultimedia(): string { return $this->multimedia; } - /** - * @param $multimedia - */ - public function setMultimedia($multimedia) - { - $this->multimedia = $multimedia; - } - - /** - * @return string - */ public function getPiFlexform() { return $this->piFlexform; } - /** - * @param $piFlexform - */ - public function setPiFlexform($piFlexform) - { - $this->piFlexform = $piFlexform; - } - - /** - * @return string - */ - public function getAccessibilityTitle() + public function getAccessibilityTitle(): string { return $this->accessibilityTitle; } - /** - * @param $accessibilityTitle - */ - public function setAccessibilityTitle($accessibilityTitle) - { - $this->accessibilityTitle = $accessibilityTitle; - } - - /** - * @return string - */ - public function getAccessibilityBypassText() + public function getAccessibilityBypassText(): string { return $this->accessibilityBypassText; } - /** - * @param $accessibilityBypassText - */ - public function setAccessibilityBypassText($accessibilityBypassText) - { - $this->accessibilityBypassText = $accessibilityBypassText; - } - - /**string - * @return string - */ - public function getSelectedCategories() + public function getSelectedCategories(): string { return $this->selectedCategories; } - /** - * @param $selectedCategories - */ - public function setSelectedCategories($selectedCategories) - { - $this->selectedCategories = $selectedCategories; - } - - /** - * @return string - */ - public function getCategoryField() + public function getCategoryField(): string { return $this->categoryField; } - /** - * @param $categoryField - */ - public function setCategoryField($categoryField) - { - $this->categoryField = $categoryField; - } - - /** - * @return int - */ - public function getSpaceBefore() + public function getSpaceBefore(): int { return $this->spaceBefore; } - /** - * @param $spaceBefore - */ - public function setSpaceBefore($spaceBefore) - { - $this->spaceBefore = $spaceBefore; - } - - /** - * @return int - */ - public function getSpaceAfter() + public function getSpaceAfter(): int { return $this->spaceAfter; } - /** - * @param $spaceAfter - */ - public function setSpaceAfter($spaceAfter) - { - $this->spaceAfter = $spaceAfter; - } - - /** - * @return int - */ - public function getImageNoRows() + public function getImageNoRows(): int { return $this->imageNoRows; } - /** - * @param $imageNoRows - */ - public function setImageNoRows($imageNoRows) - { - $this->imageNoRows = $imageNoRows; - } - - /** - * @return int - */ - public function getImageEffects() + public function getImageEffects(): int { return $this->imageEffects; } - /** - * @param $imageEffects - */ - public function setImageEffects($imageEffects) - { - $this->imageEffects = $imageEffects; - } - - /** - * @return int - */ - public function getImageCompression() + public function getImageCompression(): int { return $this->imageCompression; } - /** - * @param $imageCompression - */ - public function setImageCompression($imageCompression) - { - $this->imageCompression = $imageCompression; - } - - /** - * @return int - */ - public function getTableBorder() + public function getTableBorder(): int { return $this->tableBorder; } - /** - * @param $tableBorder - */ - public function setTableBorder($tableBorder) - { - $this->tableBorder = $tableBorder; - } - - /** - * @return int - */ - public function getTableCellspacing() + public function getTableCellspacing(): int { return $this->tableCellspacing; } - /** - * @param $tableCellspacing - */ - public function setTableCellspacing($tableCellspacing) - { - $this->tableCellspacing = $tableCellspacing; - } - - /** - * @return int - */ - public function getTableCellpadding() + public function getTableCellpadding(): int { return $this->tableCellpadding; } - /** - * @param $tableCellpadding - */ - public function setTableCellpadding($tableCellpadding) - { - $this->tableCellpadding = $tableCellpadding; - } - - /** - * @return int - */ - public function getTableBgColor() + public function getTableBgColor(): int { return $this->tableBgColor; } - /** - * @param $tableBgColor - */ - public function setTableBgColor($tableBgColor) - { - $this->tableBgColor = $tableBgColor; - } - - /** - * @return int - */ - public function getSectionIndex() + public function getSectionIndex(): int { return $this->sectionIndex; } - /** - * @param $sectionIndex - */ - public function setSectionIndex($sectionIndex) - { - $this->sectionIndex = $sectionIndex; - } - - /** - * @return int - */ - public function getLinkToTop() + public function getLinkToTop(): int { return $this->linkToTop; } - /** - * @param $linkToTop - */ - public function setLinkToTop($linkToTop) - { - $this->linkToTop = $linkToTop; - } - - /** - * @return int - */ - public function getFilelinkSize() + public function getFilelinkSize(): int { return $this->filelinkSize; } - /** - * @param $filelinkSize - */ - public function setFilelinkSize($filelinkSize) - { - $this->filelinkSize = $filelinkSize; - } - - /** - * @return int - */ - public function getSectionFrame() + public function getSectionFrame(): int { return $this->sectionFrame; } - /** - * @param $sectionFrame - */ - public function setSectionFrame($sectionFrame) - { - $this->sectionFrame = $sectionFrame; - } - - /** - * @return int - */ - public function getDate() + public function getDate(): int { return $this->date; } - /** - * @param $date - */ - public function setDate($date) - { - $this->date = $date; - } - - /** - * @return int - */ - public function getImageFrames() + public function getImageFrames(): int { return $this->imageFrames; } - /** - * @param $imageFrames - */ - public function setImageFrames($imageFrames) - { - $this->imageFrames = $imageFrames; - } - - /** - * @return int - */ - public function getRecursive() + public function getRecursive(): int { return $this->recursive; } - /** - * @param $recursive - */ - public function setRecursive($recursive) - { - $this->recursive = $recursive; - } - - /** - * @return int - */ - public function getRteEnabled() + public function getRteEnabled(): int { return $this->rteEnabled; } - /** - * @param $rteEnabled - */ - public function setRteEnabled($rteEnabled) - { - $this->rteEnabled = $rteEnabled; - } - - /** - * @return int - */ - public function getTxImpexpOriguid() + public function getTxImpexpOriguid(): int { return $this->txImpexpOriguid; } - /** - * @param $txImpexpOriguid - */ - public function setTxImpexpOriguid($txImpexpOriguid) - { - $this->txImpexpOriguid = $txImpexpOriguid; - } - - /** - * @return int - */ - public function getAccessibilityBypass() + public function getAccessibilityBypass(): int { return $this->accessibilityBypass; } - /** - * @param $accessibilityBypass - */ - public function setAccessibilityBypass($accessibilityBypass) - { - $this->accessibilityBypass = $accessibilityBypass; - } - - /** - * @return int - */ - public function getSysLanguageUid() + public function getSysLanguageUid(): int { return $this->sysLanguageUid; } - /** - * @param $sysLanguageUid - */ - public function setSysLanguageUid($sysLanguageUid) - { - $this->sysLanguageUid = $sysLanguageUid; - } - - /** - * @return int - */ - public function getStarttime() + public function getStarttime(): int { return $this->starttime; } - /** - * @param $starttime - */ - public function setStarttime($starttime) - { - $this->starttime = $starttime; - } - - /** - * @return int - */ - public function getEndtime() + public function getEndtime(): int { return $this->endtime; } - - /** - * @param $endtime - */ - public function setEndtime($endtime) - { - $this->endtime = $endtime; - } - - /** - * @return string - */ - public function getTxGridelementsBackendLayout() - { - return $this->txGridelementsBackendLayout; - } - - /** - * @param $txGridelementsBackendLayout - */ - public function setTxGridelementsBackendLayout($txGridelementsBackendLayout) - { - $this->txGridelementsBackendLayout = $txGridelementsBackendLayout; - } - - /** - * @return int - */ - public function getTxGridelementsChildren() - { - return $this->txGridelementsChildren; - } - - /** - * @param $txGridelementsChildren - */ - public function setTxGridelementsChildren($txGridelementsChildren) - { - $this->txGridelementsChildren = $txGridelementsChildren; - } - - /** - * @return int - */ - public function getTxGridelementsContainer() - { - return $this->txGridelementsContainer; - } - - /** - * @param $txGridelementsContainer - */ - public function setTxGridelementsContainer($txGridelementsContainer) - { - $this->txGridelementsContainer = $txGridelementsContainer; - } - - /** - * @return int - */ - public function getTxGridelementsColumns() - { - return $this->txGridelementsColumns; - } - - /** - * @param $txGridelementsColumns - */ - public function setTxGridelementsColumns($txGridelementsColumns) - { - $this->txGridelementsColumns = $txGridelementsColumns; - } } diff --git a/Classes/Domain/Repository/Product/ProductRepository.php b/Classes/Domain/Repository/Product/ProductRepository.php index d7d0c29b..a19146a4 100644 --- a/Classes/Domain/Repository/Product/ProductRepository.php +++ b/Classes/Domain/Repository/Product/ProductRepository.php @@ -16,10 +16,7 @@ class ProductRepository extends Repository { - /** - * @return QueryResultInterface|array - */ - public function findDemanded(ProductDemand $demand) + public function findDemanded(ProductDemand $demand): QueryResultInterface { $query = $this->createQuery(); @@ -54,9 +51,6 @@ public function findDemanded(ProductDemand $demand) return $query->execute(); } - /** - * Find all products based on selected uids - */ public function findByUids(string $uids): array { $uids = explode(',', $uids); @@ -71,11 +65,6 @@ public function findByUids(string $uids): array return $this->orderByField($query->execute(), $uids); } - /** - * @param ProductDemand $demand - * - * @return array - */ protected function createOrderingsFromDemand(ProductDemand $demand): array { $orderings = []; @@ -84,7 +73,7 @@ protected function createOrderingsFromDemand(ProductDemand $demand): array if (!empty($orderList)) { foreach ($orderList as $orderItem) { - list($orderField, $orderDirection) = + [$orderField, $orderDirection] = GeneralUtility::trimExplode(' ', $orderItem, true); if ( $orderDirection && diff --git a/Classes/Event/RetrieveProductsFromRequestEvent.php b/Classes/Event/RetrieveProductsFromRequestEvent.php index e373f752..90151e27 100644 --- a/Classes/Event/RetrieveProductsFromRequestEvent.php +++ b/Classes/Event/RetrieveProductsFromRequestEvent.php @@ -19,10 +19,6 @@ final class RetrieveProductsFromRequestEvent implements RetrieveProductsFromRequestEventInterface { - private Request $request; - - private array $taxClasses = []; - private ?ProductProduct $productProduct = null; private ?CartProduct $cartProduct = null; @@ -39,12 +35,9 @@ final class RetrieveProductsFromRequestEvent implements RetrieveProductsFromRequ private bool $isPropagationStopped = false; public function __construct( - Request $request, - array $taxClasses - ) { - $this->request = $request; - $this->taxClasses = $taxClasses; - } + private readonly Request $request, + private readonly array $taxClasses + ) {} public function getRequest(): Request { diff --git a/Classes/EventListener/CheckProductAvailability.php b/Classes/EventListener/CheckProductAvailability.php index f7080c73..227219d2 100644 --- a/Classes/EventListener/CheckProductAvailability.php +++ b/Classes/EventListener/CheckProductAvailability.php @@ -10,27 +10,19 @@ * For the full copyright and license information, please read the * LICENSE file that was distributed with this source code. */ - use Extcode\Cart\Event\CheckProductAvailabilityEvent; use Extcode\CartProducts\Domain\Model\Product\Product; use Extcode\CartProducts\Domain\Repository\Product\ProductRepository; -use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; class CheckProductAvailability { - /** - * @var ProductRepository - */ - protected $productRepository; - public function __construct( - ProductRepository $productRepository - ) { - $this->productRepository = $productRepository; - } + private readonly ProductRepository $productRepository + ) {} public function __invoke(CheckProductAvailabilityEvent $event): void { @@ -105,7 +97,7 @@ protected function falseAvailability(CheckProductAvailabilityEvent $event): void 'cart' ), '', - AbstractMessage::ERROR + ContextualFeedbackSeverity::ERROR ) ); } diff --git a/Classes/EventListener/Create/CheckRequest.php b/Classes/EventListener/Create/CheckRequest.php index a7eead18..7a9e7e61 100644 --- a/Classes/EventListener/Create/CheckRequest.php +++ b/Classes/EventListener/Create/CheckRequest.php @@ -10,10 +10,9 @@ * For the full copyright and license information, please read the * LICENSE file that was distributed with this source code. */ - use Extcode\CartProducts\Event\RetrieveProductsFromRequestEvent; -use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; class CheckRequest @@ -30,10 +29,10 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void new FlashMessage( LocalizationUtility::translate( 'tx_cart.error.parameter.no_product', - 'cart_products' + 'CartProducts' ), '', - AbstractMessage::ERROR + ContextualFeedbackSeverity::ERROR ) ); $event->setPropagationStopped(true); @@ -47,10 +46,10 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void new FlashMessage( LocalizationUtility::translate( 'tx_cart.error.invalid_quantity', - 'cart_products' + 'CartProducts' ), '', - AbstractMessage::WARNING + ContextualFeedbackSeverity::WARNING ) ); $event->setPropagationStopped(true); diff --git a/Classes/EventListener/Create/CreateCartBackendVariants.php b/Classes/EventListener/Create/CreateCartBackendVariants.php index 31cab26c..37b317de 100644 --- a/Classes/EventListener/Create/CreateCartBackendVariants.php +++ b/Classes/EventListener/Create/CreateCartBackendVariants.php @@ -19,15 +19,11 @@ class CreateCartBackendVariants { - protected BeVariantRepository $beVariantRepository; - protected array $frontendUserGroupIds; public function __construct( - BeVariantRepository $beVariantRepository - ) { - $this->beVariantRepository = $beVariantRepository; - } + protected BeVariantRepository $beVariantRepository + ) {} public function __invoke(RetrieveProductsFromRequestEvent $event): void { @@ -48,10 +44,10 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void foreach ($requestBeVariants as $variantsKey => $variantId) { if ($variantsKey === 1) { $newVariant = $this->createCartBackendVariant( - $cartProduct, - null, $quantity, - $variantId + $variantId, + $cartProduct, + null ); if ($newVariant) { @@ -62,10 +58,10 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void } } else { $newVariant = $this->createCartBackendVariant( - null, - $newVariantArr[$variantsKey - 1], $quantity, - $variantId + $variantId, + null, + $newVariantArr[$variantsKey - 1] ); if ($newVariant) { @@ -80,10 +76,10 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void } protected function createCartBackendVariant( - Product $product = null, - BeVariant $variant = null, int $quantity, - string $variantId + string $variantId, + Product $product = null, + BeVariant $variant = null ): ?BeVariant { $productBackendVariant = $this->beVariantRepository->findByUid($variantId); diff --git a/Classes/EventListener/Create/CreateCartFrontendVariants.php b/Classes/EventListener/Create/CreateCartFrontendVariants.php index 4da9fe06..5115a1cb 100644 --- a/Classes/EventListener/Create/CreateCartFrontendVariants.php +++ b/Classes/EventListener/Create/CreateCartFrontendVariants.php @@ -18,10 +18,7 @@ class CreateCartFrontendVariants { - /** - * @var ProductRepository - */ - protected $productRepository; + protected ProductRepository $productRepository; public function __construct( ProductRepository $productRepository, diff --git a/Classes/EventListener/Create/LoadProduct.php b/Classes/EventListener/Create/LoadProduct.php index fb70a337..b839c840 100644 --- a/Classes/EventListener/Create/LoadProduct.php +++ b/Classes/EventListener/Create/LoadProduct.php @@ -10,24 +10,16 @@ * For the full copyright and license information, please read the * LICENSE file that was distributed with this source code. */ - use Extcode\CartProducts\Domain\Repository\Product\ProductRepository; use Extcode\CartProducts\Event\RetrieveProductsFromRequestEvent; -use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Messaging\FlashMessage; +use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; class LoadProduct { - /** - * @var ProductRepository - */ - protected $productRepository; - public function __construct( - ProductRepository $productRepository - ) { - $this->productRepository = $productRepository; - } + private readonly ProductRepository $productRepository + ) {} public function __invoke(RetrieveProductsFromRequestEvent $event): void { @@ -41,7 +33,7 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void new FlashMessage( 'product not found', '', - AbstractMessage::ERROR + ContextualFeedbackSeverity::ERROR ) ); diff --git a/Classes/EventListener/Order/Stock/HandleStock.php b/Classes/EventListener/Order/Stock/HandleStock.php index e90a9b15..bbce1a24 100644 --- a/Classes/EventListener/Order/Stock/HandleStock.php +++ b/Classes/EventListener/Order/Stock/HandleStock.php @@ -30,7 +30,7 @@ public function __invoke(EventInterface $event): void $product = $productQueryBuilder ->select('uid', 'handle_stock', 'handle_stock_in_variants') - ->from('tx_cartproducts_domain_model_product_product')->where($productQueryBuilder->expr()->eq('uid', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)))->executeQuery()->fetch(); + ->from('tx_cartproducts_domain_model_product_product')->where($productQueryBuilder->expr()->eq('uid', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)))->executeQuery()->fetchAssociative(); if ($product['handle_stock']) { if ($product['handle_stock_in_variants']) { @@ -51,7 +51,7 @@ protected function handleStockInProduct(CartProduct $cartProduct): void $product = $productQueryBuilder ->select('stock') - ->from('tx_cartproducts_domain_model_product_product')->where($productQueryBuilder->expr()->eq('uid', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)))->executeQuery()->fetch(); + ->from('tx_cartproducts_domain_model_product_product')->where($productQueryBuilder->expr()->eq('uid', $productQueryBuilder->createNamedParameter($cartProduct->getProductId(), \PDO::PARAM_INT)))->executeQuery()->fetchAssociative(); $productQueryBuilder ->update('tx_cartproducts_domain_model_product_product') @@ -72,7 +72,7 @@ protected function handleStockInBeVariant(CartProduct $cartProduct): void $beVariantQueryBuilder = $beVariantConnection->createQueryBuilder(); $beVariant = $beVariantQueryBuilder ->select('stock') - ->from('tx_cartproducts_domain_model_product_bevariant')->where($beVariantQueryBuilder->expr()->eq('uid', $beVariantQueryBuilder->createNamedParameter($cartBeVariant->getId(), \PDO::PARAM_INT)))->executeQuery()->fetch(); + ->from('tx_cartproducts_domain_model_product_bevariant')->where($beVariantQueryBuilder->expr()->eq('uid', $beVariantQueryBuilder->createNamedParameter($cartBeVariant->getId(), \PDO::PARAM_INT)))->executeQuery()->fetchAssociative(); $beVariantQueryBuilder ->update('tx_cartproducts_domain_model_product_bevariant') diff --git a/Classes/EventListener/RetrieveProductsFromRequest.php b/Classes/EventListener/RetrieveProductsFromRequest.php index 06cceefa..acf3e6ff 100644 --- a/Classes/EventListener/RetrieveProductsFromRequest.php +++ b/Classes/EventListener/RetrieveProductsFromRequest.php @@ -21,17 +21,10 @@ class RetrieveProductsFromRequest { - private EventDispatcherInterface $eventDispatcher; - - protected ProductRepository $productRepository; - public function __construct( - EventDispatcherInterface $eventDispatcher, - ProductRepository $productRepository - ) { - $this->eventDispatcher = $eventDispatcher; - $this->productRepository = $productRepository; - } + private readonly EventDispatcherInterface $eventDispatcher, + protected ProductRepository $productRepository + ) {} public function __invoke(RetrieveProductsFromRequestEvent $event): void { @@ -59,9 +52,6 @@ public function __invoke(RetrieveProductsFromRequestEvent $event): void $event->addProduct($createEvent->getCartProduct()); } - /** - * Get Frontend User Group - */ protected function getFrontendUserGroupIds(): array { $feGroupIds = []; diff --git a/Classes/Hooks/DataHandler.php b/Classes/Hooks/DataHandler.php index bafceb7f..29f14750 100644 --- a/Classes/Hooks/DataHandler.php +++ b/Classes/Hooks/DataHandler.php @@ -17,10 +17,8 @@ class DataHandler /** * Flushes the cache if a news record was edited. * This happens on two levels: by UID and by PID. - * - * @param array $params */ - public function clearCachePostProc(array $params) + public function clearCachePostProc(array $params): void { if (isset($params['table']) && ($params['table'] === 'tx_cartproducts_domain_model_product_product')) { $cacheTagsToFlush = []; diff --git a/Classes/Hooks/DatamapDataHandlerHook.php b/Classes/Hooks/DatamapDataHandlerHook.php index 1ae538b5..fdb0d5a3 100644 --- a/Classes/Hooks/DatamapDataHandlerHook.php +++ b/Classes/Hooks/DatamapDataHandlerHook.php @@ -25,7 +25,7 @@ class DatamapDataHandlerHook /** * @param DataHandler $dataHandler */ - public function processDatamap_beforeStart(DataHandler $dataHandler) + public function processDatamap_beforeStart(DataHandler $dataHandler): void { $datamap = $dataHandler->datamap; if (empty($datamap['tt_content']) || $dataHandler->bypassAccessCheckForRecords) { @@ -65,7 +65,7 @@ public function processDatamap_beforeStart(DataHandler $dataHandler) } } - public function processDatamap_afterAllOperations(DataHandler $dataHandler) + public function processDatamap_afterAllOperations(DataHandler $dataHandler): void { $newIdUidArray = $dataHandler->substNEWwithIDs; @@ -86,7 +86,7 @@ public function processDatamap_afterAllOperations(DataHandler $dataHandler) protected function isAllowedTargetPage($listType, $doktype) { - if (empty($listType) || substr($listType, 0, 11) !== 'cartproducts_') { + if (empty($listType) || substr((string)$listType, 0, 11) !== 'cartproducts_') { return true; } diff --git a/Classes/Updates/SlugUpdater.php b/Classes/Updates/SlugUpdater.php index b1dab8cd..483241a6 100644 --- a/Classes/Updates/SlugUpdater.php +++ b/Classes/Updates/SlugUpdater.php @@ -26,47 +26,23 @@ class SlugUpdater implements UpgradeWizardInterface, ChattyInterface public const IDENTIFIER = 'cartProductsSlugUpdater'; public const TABLE_NAME = 'tx_cartproducts_domain_model_product_product'; - /** - * @var OutputInterface - */ - protected $output; + protected OutputInterface $output; - /** - * Return the identifier for this wizard - * This should be the same string as used in the ext_localconf class registration - * - * @return string - */ public function getIdentifier(): string { return self::IDENTIFIER; } - /** - * Get title - * - * @return string - */ public function getTitle(): string { return 'Updates slug field "path_segment" of EXT:cart_products records'; } - /** - * Return the description for this wizard - * - * @return string - */ public function getDescription(): string { return 'TYPO3 includes native URL handling. Every product record has its own speaking URL path called "slug" which can be edited in TYPO3 Backend. However, it is necessary that all products have a URL pre-filled. This is done by evaluating the title.'; } - /** - * Checks if an update is needed - * - * @return bool Whether an update is needed (TRUE) or not (FALSE) - */ public function updateNecessary(): bool { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE_NAME); @@ -77,11 +53,6 @@ public function updateNecessary(): bool return (bool)$elementCount; } - /** - * Performs the database update - * - * @return bool - */ public function executeUpdate(): bool { $slugHelper = GeneralUtility::makeInstance( @@ -96,7 +67,7 @@ public function executeUpdate(): bool $queryBuilder->getRestrictions()->removeAll(); $statement = $queryBuilder->select('uid', 'title') ->from(self::TABLE_NAME)->where($queryBuilder->expr()->or($queryBuilder->expr()->eq('path_segment', $queryBuilder->createNamedParameter('', \PDO::PARAM_STR)), $queryBuilder->expr()->isNull('path_segment')))->executeQuery(); - while ($record = $statement->fetch()) { + while ($record = $statement->fetchAssociative()) { $queryBuilder = $connection->createQueryBuilder(); $queryBuilder->update(self::TABLE_NAME) ->where( @@ -114,8 +85,6 @@ public function executeUpdate(): bool } /** - * Returns an array of class names of Prerequisite classes - * * @return string[] */ public function getPrerequisites(): array @@ -124,8 +93,6 @@ public function getPrerequisites(): array } /** - * Setter injection for output into upgrade wizards - * * @param OutputInterface $output */ public function setOutput(OutputInterface $output): void diff --git a/Classes/ViewHelpers/CanonicalTagViewHelper.php b/Classes/ViewHelpers/CanonicalTagViewHelper.php index 3df23738..a48c5ccc 100644 --- a/Classes/ViewHelpers/CanonicalTagViewHelper.php +++ b/Classes/ViewHelpers/CanonicalTagViewHelper.php @@ -23,7 +23,7 @@ class CanonicalTagViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'link'; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); @@ -36,9 +36,6 @@ public function initializeArguments() ); } - /** - * Override the canonical tag - */ public function render(): string { $product = $this->arguments['product']; @@ -80,10 +77,7 @@ public function render(): string return ''; } - /** - * @return PageRenderer - */ - protected function getPageRenderer() + protected function getPageRenderer(): PageRenderer { if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend() && is_callable([$this->getTypoScriptFrontendController(), 'getPageRenderer'])) { return $this->getTypoScriptFrontendController()->getPageRenderer(); @@ -92,10 +86,7 @@ protected function getPageRenderer() return GeneralUtility::makeInstance(PageRenderer::class); } - /** - * @return TypoScriptFrontendController - */ - protected function getTypoScriptFrontendController() + protected function getTypoScriptFrontendController(): TypoScriptFrontendController { return $GLOBALS['TSFE']; } diff --git a/Classes/ViewHelpers/Form/VariantSelectViewHelper.php b/Classes/ViewHelpers/Form/VariantSelectViewHelper.php index 56fd5a3e..fe4c5e9e 100644 --- a/Classes/ViewHelpers/Form/VariantSelectViewHelper.php +++ b/Classes/ViewHelpers/Form/VariantSelectViewHelper.php @@ -32,7 +32,7 @@ class VariantSelectViewHelper extends AbstractViewHelper * * @api */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); @@ -119,16 +119,12 @@ protected function getOptions(): array * @var BeVariant $beVariant */ $currencyViewHelper->setRenderChildrenClosure( - function () use ($beVariant) { - return $beVariant->getPriceCalculated(); - } + fn() => $beVariant->getPriceCalculated() ); $regularPrice = $currencyViewHelper->render(); $currencyViewHelper->setRenderChildrenClosure( - function () use ($beVariant) { - return $beVariant->getBestPriceCalculated(); - } + fn() => $beVariant->getBestPriceCalculated() ); $specialPrice = $currencyViewHelper->render(); diff --git a/Classes/ViewHelpers/Product/AbstractProductViewHelper.php b/Classes/ViewHelpers/Product/AbstractProductViewHelper.php index f2687d79..19ce7277 100644 --- a/Classes/ViewHelpers/Product/AbstractProductViewHelper.php +++ b/Classes/ViewHelpers/Product/AbstractProductViewHelper.php @@ -22,7 +22,7 @@ abstract class AbstractProductViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); diff --git a/Classes/ViewHelpers/Product/IfBestSpecialPriceAvailableViewHelper.php b/Classes/ViewHelpers/Product/IfBestSpecialPriceAvailableViewHelper.php index fd7cdcc6..df45ec9d 100644 --- a/Classes/ViewHelpers/Product/IfBestSpecialPriceAvailableViewHelper.php +++ b/Classes/ViewHelpers/Product/IfBestSpecialPriceAvailableViewHelper.php @@ -22,7 +22,7 @@ class IfBestSpecialPriceAvailableViewHelper extends AbstractConditionViewHelper */ protected $escapeOutput = false; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index cc5a7ea9..88ebb52d 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -23,7 +23,7 @@ foreach ($pluginNames as $pluginName => $pluginConf) { $pluginSignature = 'cartproducts_' . strtolower($pluginName); - $pluginNameSC = strtolower(preg_replace('/[A-Z]/', '_$0', lcfirst($pluginName))); + $pluginNameSC = strtolower((string)preg_replace('/[A-Z]/', '_$0', lcfirst($pluginName))); ExtensionUtility::registerPlugin( 'CartProducts', $pluginName, diff --git a/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php b/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php index 85aebf8d..c9609631 100644 --- a/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php +++ b/Configuration/TCA/Overrides/tx_cartproducts_domain_model_product_product.php @@ -12,19 +12,12 @@ if ($categoryRestrictionSetting) { $categoryRestriction = ''; - switch ($categoryRestrictionSetting) { - case 'current_pid': - $categoryRestriction = ' AND sys_category.pid=###CURRENT_PID### '; - break; - case 'siteroot': - $categoryRestriction = ' AND sys_category.pid IN (###SITEROOT###) '; - break; - case 'page_tsconfig': - $categoryRestriction = ' AND sys_category.pid IN (###PAGE_TSCONFIG_IDLIST###) '; - break; - default: - $categoryRestriction = ''; - } + $categoryRestriction = match ($categoryRestrictionSetting) { + 'current_pid' => ' AND sys_category.pid=###CURRENT_PID### ', + 'siteroot' => ' AND sys_category.pid IN (###SITEROOT###) ', + 'page_tsconfig' => ' AND sys_category.pid IN (###PAGE_TSCONFIG_IDLIST###) ', + default => '', + }; // prepend category restriction at the beginning of foreign_table_where if (!empty($categoryRestriction)) { diff --git a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php index d8f5305d..9fffc9cf 100644 --- a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php +++ b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariant.php @@ -107,10 +107,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.starttime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ @@ -122,10 +120,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.endtime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ @@ -201,11 +197,11 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.price', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', 'required' => true, + 'format' => 'decimal', ], ], @@ -252,9 +248,9 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.price_measure', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', + 'format' => 'decimal', ], ], @@ -291,9 +287,8 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_bevariant.stock', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'int', 'default' => 0, 'required' => true, ], diff --git a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattribute.php b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattribute.php index 6ccb3e01..cafdefa6 100644 --- a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattribute.php +++ b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattribute.php @@ -81,10 +81,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.starttime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ @@ -96,10 +94,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.endtime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ diff --git a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattributeoption.php b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattributeoption.php index 48c1c17c..e86ca561 100644 --- a/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattributeoption.php +++ b/Configuration/TCA/tx_cartproducts_domain_model_product_bevariantattributeoption.php @@ -82,10 +82,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.starttime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ @@ -97,10 +95,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.endtime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ diff --git a/Configuration/TCA/tx_cartproducts_domain_model_product_product.php b/Configuration/TCA/tx_cartproducts_domain_model_product_product.php index 1495442c..e77ac65c 100644 --- a/Configuration/TCA/tx_cartproducts_domain_model_product_product.php +++ b/Configuration/TCA/tx_cartproducts_domain_model_product_product.php @@ -141,10 +141,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.starttime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ @@ -156,10 +154,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.endtime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, 'range' => [ @@ -251,9 +247,8 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.min_number_in_order', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'int', ], ], @@ -261,9 +256,8 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.max_number_in_order', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'int', ], ], @@ -279,11 +273,11 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.price', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', 'required' => true, + 'format' => 'decimal', ], ], @@ -331,10 +325,10 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.price_measure', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', + 'format' => 'decimal', ], ], @@ -400,33 +394,33 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.service_attribute1', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', 'required' => true, + 'format' => 'decimal', ], ], 'service_attribute2' => [ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.service_attribute2', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', 'required' => true, + 'format' => 'decimal', ], ], 'service_attribute3' => [ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.service_attribute3', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', 'required' => true, + 'format' => 'decimal', ], ], @@ -651,7 +645,6 @@ 'appearance' => [ 'levelLinksPosition' => 'top', 'showPossibleLocalizationRecords' => true, - 'showRemovedLocalizationRecords' => true, 'showAllLocalizationLink' => true, 'showSynchronizationLink' => true, 'enabledControls' => [ @@ -706,9 +699,8 @@ ], 'label' => $_LLL . ':tx_cartproducts_domain_model_product_product.stock', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'int', 'default' => 0, ], 'l10n_mode' => 'exclude', diff --git a/Configuration/TCA/tx_cartproducts_domain_model_product_quantitydiscount.php b/Configuration/TCA/tx_cartproducts_domain_model_product_quantitydiscount.php index 9f25d340..dc8698dc 100644 --- a/Configuration/TCA/tx_cartproducts_domain_model_product_quantitydiscount.php +++ b/Configuration/TCA/tx_cartproducts_domain_model_product_quantitydiscount.php @@ -54,9 +54,8 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_quantitydiscount.quantity', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'int', 'default' => '0', 'required' => true, ], @@ -65,11 +64,11 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_quantitydiscount.price', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', 'required' => true, + 'format' => 'decimal', ], ], diff --git a/Configuration/TCA/tx_cartproducts_domain_model_product_specialprice.php b/Configuration/TCA/tx_cartproducts_domain_model_product_specialprice.php index f24a0cbc..1e3e6de5 100644 --- a/Configuration/TCA/tx_cartproducts_domain_model_product_specialprice.php +++ b/Configuration/TCA/tx_cartproducts_domain_model_product_specialprice.php @@ -93,10 +93,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.starttime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, ], @@ -105,10 +103,8 @@ 'exclude' => 1, 'label' => $_LLL_general . ':LGL.endtime', 'config' => [ - 'type' => 'input', - 'renderType' => 'inputDateTime', + 'type' => 'datetime', 'size' => 13, - 'eval' => 'datetime', 'checkbox' => 0, 'default' => 0, ], @@ -127,11 +123,11 @@ 'exclude' => 1, 'label' => $_LLL . ':tx_cartproducts_domain_model_product_specialprice.price', 'config' => [ - 'type' => 'input', + 'type' => 'number', 'size' => 30, - 'eval' => 'double2', 'default' => '0.00', 'required' => true, + 'format' => 'decimal', ], ], diff --git a/Tests/Functional/Domain/Repository/Product/ProductRepositoryTest.php b/Tests/Functional/Domain/Repository/Product/ProductRepositoryTest.php index 3d239e81..51c7c910 100644 --- a/Tests/Functional/Domain/Repository/Product/ProductRepositoryTest.php +++ b/Tests/Functional/Domain/Repository/Product/ProductRepositoryTest.php @@ -33,7 +33,7 @@ public function setUp(): void /** * @test */ - public function findDemandedWithGivenSkuReturnsProducts() + public function findDemandedWithGivenSkuReturnsProducts(): void { $querySettings = GeneralUtility::makeInstance(QuerySettingsInterface::class); $querySettings->setStoragePageIds([110]); @@ -53,7 +53,7 @@ public function findDemandedWithGivenSkuReturnsProducts() /** * @test */ - public function findDemandedWithGivenTitleReturnsProducts() + public function findDemandedWithGivenTitleReturnsProducts(): void { $querySettings = GeneralUtility::makeInstance(QuerySettingsInterface::class); $querySettings->setStoragePageIds([110]); @@ -82,7 +82,7 @@ public function findDemandedWithGivenTitleReturnsProducts() /** * @test */ - public function findByUidsDoesNotRespectStoragePid() + public function findByUidsDoesNotRespectStoragePid(): void { $products = $this->productRepository->findByUids('3,1,2,5,4'); @@ -103,7 +103,7 @@ public function findByUidsDoesNotRespectStoragePid() /** * @test */ - public function findByUidsReturnsCorrectOrder() + public function findByUidsReturnsCorrectOrder(): void { $listOfProductIds = [3, 1, 2, 5, 4]; $products = $this->productRepository->findByUids(implode(',', $listOfProductIds)); diff --git a/Tests/Unit/Domain/Model/CategoryTest.php b/Tests/Unit/Domain/Model/CategoryTest.php index a3e72486..663fe5dc 100644 --- a/Tests/Unit/Domain/Model/CategoryTest.php +++ b/Tests/Unit/Domain/Model/CategoryTest.php @@ -27,7 +27,7 @@ protected function tearDown(): void /** * @test */ - public function getCartProductShowPidReturnsShowPid() + public function getCartProductShowPidReturnsShowPid(): void { $cartProductShowPid = 123; diff --git a/Tests/Unit/Domain/Model/Product/BeVariantAttributeTest.php b/Tests/Unit/Domain/Model/Product/BeVariantAttributeTest.php index 1eec9372..0242b240 100644 --- a/Tests/Unit/Domain/Model/Product/BeVariantAttributeTest.php +++ b/Tests/Unit/Domain/Model/Product/BeVariantAttributeTest.php @@ -27,7 +27,7 @@ public function tearDown(): void /** * @test */ - public function getBeVariantAttributeOptionsInitiallyIsEmpty() + public function getBeVariantAttributeOptionsInitiallyIsEmpty(): void { self::assertEmpty( $this->beVariantAttribute->getBeVariantAttributeOptions() @@ -37,7 +37,7 @@ public function getBeVariantAttributeOptionsInitiallyIsEmpty() /** * @test */ - public function setTransactionsSetsTransactions() + public function setTransactionsSetsTransactions(): void { $beVariantAttributeOption1 = new BeVariantAttributeOption(); $beVariantAttributeOption2 = new BeVariantAttributeOption(); @@ -61,7 +61,7 @@ public function setTransactionsSetsTransactions() /** * @test */ - public function addTransactionAddsTransaction() + public function addTransactionAddsTransaction(): void { $beVariantAttributeOption1 = new BeVariantAttributeOption(); $beVariantAttributeOption2 = new BeVariantAttributeOption(); @@ -82,7 +82,7 @@ public function addTransactionAddsTransaction() /** * @test */ - public function removeTransactionRemovesTransaction() + public function removeTransactionRemovesTransaction(): void { $beVariantAttributeOption1 = new BeVariantAttributeOption(); $beVariantAttributeOption2 = new BeVariantAttributeOption(); diff --git a/Tests/Unit/Domain/Model/Product/BeVariantTest.php b/Tests/Unit/Domain/Model/Product/BeVariantTest.php index 2d45be82..52feaccc 100644 --- a/Tests/Unit/Domain/Model/Product/BeVariantTest.php +++ b/Tests/Unit/Domain/Model/Product/BeVariantTest.php @@ -29,7 +29,7 @@ public function tearDown(): void /** * @test */ - public function getProductInitiallyReturnsNull() + public function getProductInitiallyReturnsNull(): void { self::assertNull( $this->beVariant->getProduct() @@ -39,7 +39,7 @@ public function getProductInitiallyReturnsNull() /** * @test */ - public function setProductSetsProduct() + public function setProductSetsProduct(): void { $product = new Product(); $this->beVariant->setProduct($product); @@ -53,7 +53,7 @@ public function setProductSetsProduct() /** * @test */ - public function getBeVariantAttributeOption1InitiallyIsNull() + public function getBeVariantAttributeOption1InitiallyIsNull(): void { self::assertNull( $this->beVariant->getBeVariantAttributeOption1() @@ -63,7 +63,7 @@ public function getBeVariantAttributeOption1InitiallyIsNull() /** * @test */ - public function setBeVariantAttributeOption1SetsBeVariantAttributeOption1() + public function setBeVariantAttributeOption1SetsBeVariantAttributeOption1(): void { $beVariantAttributeOption = new BeVariantAttributeOption(); @@ -78,7 +78,7 @@ public function setBeVariantAttributeOption1SetsBeVariantAttributeOption1() /** * @test */ - public function getBeVariantAttributeOption2InitiallyIsNull() + public function getBeVariantAttributeOption2InitiallyIsNull(): void { self::assertNull( $this->beVariant->getBeVariantAttributeOption2() @@ -88,7 +88,7 @@ public function getBeVariantAttributeOption2InitiallyIsNull() /** * @test */ - public function setBeVariantAttributeOption2SetsBeVariantAttributeOption2() + public function setBeVariantAttributeOption2SetsBeVariantAttributeOption2(): void { $beVariantAttributeOption = new BeVariantAttributeOption(); @@ -103,7 +103,7 @@ public function setBeVariantAttributeOption2SetsBeVariantAttributeOption2() /** * @test */ - public function getBeVariantAttributeOption3InitiallyIsNull() + public function getBeVariantAttributeOption3InitiallyIsNull(): void { self::assertNull( $this->beVariant->getBeVariantAttributeOption3() @@ -113,7 +113,7 @@ public function getBeVariantAttributeOption3InitiallyIsNull() /** * @test */ - public function setBeVariantAttributeOption3SetsBeVariantAttributeOption3() + public function setBeVariantAttributeOption3SetsBeVariantAttributeOption3(): void { $beVariantAttributeOption = new BeVariantAttributeOption(); @@ -128,7 +128,7 @@ public function setBeVariantAttributeOption3SetsBeVariantAttributeOption3() /** * @test */ - public function getPriceInitiallyReturnsZero() + public function getPriceInitiallyReturnsZero(): void { $price = 0.0; @@ -141,7 +141,7 @@ public function getPriceInitiallyReturnsZero() /** * @test */ - public function setPriceSetsPrice() + public function setPriceSetsPrice(): void { $price = 100.0; @@ -156,7 +156,7 @@ public function setPriceSetsPrice() /** * @test */ - public function getSpecialPricesInitiallyReturnsEmptyObjectStorage() + public function getSpecialPricesInitiallyReturnsEmptyObjectStorage(): void { self::assertInstanceOf( ObjectStorage::class, @@ -167,7 +167,7 @@ public function getSpecialPricesInitiallyReturnsEmptyObjectStorage() /** * @test */ - public function addSpecialPriceAddsSpecialPrice() + public function addSpecialPriceAddsSpecialPrice(): void { $specialPrice = new SpecialPrice(); @@ -182,7 +182,7 @@ public function addSpecialPriceAddsSpecialPrice() /** * @test */ - public function getBestSpecialPriceWithOneSpecialPriceReturnsSpecialPrice() + public function getBestSpecialPriceWithOneSpecialPriceReturnsSpecialPrice(): void { $specialPrice = new SpecialPrice(); @@ -233,7 +233,7 @@ public function getBestSpecialPriceWithMoreSpecialPricesReturnsBestSpecialPrice( $priceForSpecialPrice2, $priceForSpecialPrice3, $expectedBestSpecialPrice - ) { + ): void { $this->beVariant->setPriceCalcMethod($priceCalcMethod); $specialPrice1 = new SpecialPrice(); @@ -262,7 +262,7 @@ public function getBestSpecialPriceWithMoreSpecialPricesReturnsBestSpecialPrice( /** * @test */ - public function getBestPriceInitiallyReturnsPrice() + public function getBestPriceInitiallyReturnsPrice(): void { $price = 100.0; @@ -306,7 +306,7 @@ public function getBestPriceWithSpecialPriceAndDifferentPriceCalcMethodsReturnsB $price, $specialPrice, $expectedBestPrice - ) { + ): void { $specialPriceObj = $this->createMock( SpecialPrice::class ); @@ -355,7 +355,7 @@ public function getBestPriceCalculatedWithPriceCalcMethod0ReturnsPrice( $price, $specialPrice, $expectedBestPrice - ) { + ): void { $specialPriceObj = $this->createMock( SpecialPrice::class ); @@ -378,7 +378,7 @@ public function getBestPriceCalculatedWithPriceCalcMethod0ReturnsPrice( /** * @test */ - public function getStockInitiallyReturnsZero() + public function getStockInitiallyReturnsZero(): void { self::assertSame( 0, @@ -389,7 +389,7 @@ public function getStockInitiallyReturnsZero() /** * @test */ - public function setStockSetsStock() + public function setStockSetsStock(): void { $stock = 10; $this->beVariant->setStock($stock); @@ -403,7 +403,7 @@ public function setStockSetsStock() /** * @test */ - public function getIsAvailableInitiallyReturnsFalse() + public function getIsAvailableInitiallyReturnsFalse(): void { self::assertFalse( $this->beVariant->getIsAvailable() @@ -413,7 +413,7 @@ public function getIsAvailableInitiallyReturnsFalse() /** * @test */ - public function getIsAvailableWithStockGreaterZeroReturnsTrue() + public function getIsAvailableWithStockGreaterZeroReturnsTrue(): void { $this->beVariant->setStock(10); diff --git a/Tests/Unit/Domain/Model/Product/FeVariantTest.php b/Tests/Unit/Domain/Model/Product/FeVariantTest.php index b8d1c30e..85c30a47 100644 --- a/Tests/Unit/Domain/Model/Product/FeVariantTest.php +++ b/Tests/Unit/Domain/Model/Product/FeVariantTest.php @@ -25,7 +25,7 @@ public function tearDown(): void /** * @test */ - public function getSkuInitiallyReturnsEmptyString() + public function getSkuInitiallyReturnsEmptyString(): void { self::assertSame( '', @@ -36,7 +36,7 @@ public function getSkuInitiallyReturnsEmptyString() /** * @test */ - public function setSkuForStringSetsSku() + public function setSkuForStringSetsSku(): void { $this->feVariant->setSku('SKU'); @@ -49,7 +49,7 @@ public function setSkuForStringSetsSku() /** * @test */ - public function getTitleInitiallyReturnsEmptyString() + public function getTitleInitiallyReturnsEmptyString(): void { self::assertSame( '', @@ -60,7 +60,7 @@ public function getTitleInitiallyReturnsEmptyString() /** * @test */ - public function setTitleForStringSetsTitle() + public function setTitleForStringSetsTitle(): void { $this->feVariant->setTitle('Title'); @@ -73,7 +73,7 @@ public function setTitleForStringSetsTitle() /** * @test */ - public function getDescriptionInitiallyReturnsEmptyString() + public function getDescriptionInitiallyReturnsEmptyString(): void { self::assertSame( '', @@ -84,7 +84,7 @@ public function getDescriptionInitiallyReturnsEmptyString() /** * @test */ - public function setDescriptionForStringSetsDescription() + public function setDescriptionForStringSetsDescription(): void { $this->feVariant->setDescription('Description'); @@ -97,7 +97,7 @@ public function setDescriptionForStringSetsDescription() /** * @test */ - public function getIsRequiredInitiallyReturnsFalse() + public function getIsRequiredInitiallyReturnsFalse(): void { self::assertFalse( $this->feVariant->getIsRequired() @@ -107,7 +107,7 @@ public function getIsRequiredInitiallyReturnsFalse() /** * @test */ - public function setIsRequiredSetsIsRequired() + public function setIsRequiredSetsIsRequired(): void { $this->feVariant->setIsRequired(true); diff --git a/Tests/Unit/Domain/Model/Product/ProductTest.php b/Tests/Unit/Domain/Model/Product/ProductTest.php index 03761cdb..eb0a9ccf 100644 --- a/Tests/Unit/Domain/Model/Product/ProductTest.php +++ b/Tests/Unit/Domain/Model/Product/ProductTest.php @@ -57,7 +57,7 @@ public static function bestSpecialPriceDiscountProvider() /** * @test */ - public function getProductTypeReturnsInitialValueForProductType() + public function getProductTypeReturnsInitialValueForProductType(): void { self::assertSame( 'simple', @@ -68,7 +68,7 @@ public function getProductTypeReturnsInitialValueForProductType() /** * @test */ - public function setProductTypeSetsProductType() + public function setProductTypeSetsProductType(): void { $this->product->setProductType('configurable'); @@ -81,7 +81,7 @@ public function setProductTypeSetsProductType() /** * @test */ - public function getTeaserReturnsInitialValueForTeaser() + public function getTeaserReturnsInitialValueForTeaser(): void { self::assertSame( '', @@ -92,7 +92,7 @@ public function getTeaserReturnsInitialValueForTeaser() /** * @test */ - public function setTeaserForStringSetsTeaser() + public function setTeaserForStringSetsTeaser(): void { $this->product->setTeaser('Conceived at T3CON10'); @@ -105,7 +105,7 @@ public function setTeaserForStringSetsTeaser() /** * @test */ - public function getMinNumberInOrderInitiallyReturnsMinNumberInOrder() + public function getMinNumberInOrderInitiallyReturnsMinNumberInOrder(): void { self::assertSame( 0, @@ -116,7 +116,7 @@ public function getMinNumberInOrderInitiallyReturnsMinNumberInOrder() /** * @test */ - public function setNegativeMinNumberThrowsException() + public function setNegativeMinNumberThrowsException(): void { $this->expectException(\InvalidArgumentException::class); $minNumber = -10; @@ -127,7 +127,7 @@ public function setNegativeMinNumberThrowsException() /** * @test */ - public function setMinNumberGreaterThanMaxNumberThrowsException() + public function setMinNumberGreaterThanMaxNumberThrowsException(): void { $this->expectException(\InvalidArgumentException::class); $minNumber = 10; @@ -138,7 +138,7 @@ public function setMinNumberGreaterThanMaxNumberThrowsException() /** * @test */ - public function setMinNumberInOrderSetsMinNumberInOrder() + public function setMinNumberInOrderSetsMinNumberInOrder(): void { $minNumber = 10; @@ -154,7 +154,7 @@ public function setMinNumberInOrderSetsMinNumberInOrder() /** * @test */ - public function getMaxNumberInOrderInitiallyReturnsMaxNumberInOrder() + public function getMaxNumberInOrderInitiallyReturnsMaxNumberInOrder(): void { self::assertSame( 0, @@ -165,7 +165,7 @@ public function getMaxNumberInOrderInitiallyReturnsMaxNumberInOrder() /** * @test */ - public function setNegativeMaxNumberThrowsException() + public function setNegativeMaxNumberThrowsException(): void { $this->expectException(\InvalidArgumentException::class); $maxNumber = -10; @@ -176,7 +176,7 @@ public function setNegativeMaxNumberThrowsException() /** * @test */ - public function setMaxNumberInOrderSetsMaxNumberInOrder() + public function setMaxNumberInOrderSetsMaxNumberInOrder(): void { $maxNumber = 10; @@ -191,7 +191,7 @@ public function setMaxNumberInOrderSetsMaxNumberInOrder() /** * @test */ - public function setMaxNumberLesserThanMinNumberThrowsException() + public function setMaxNumberLesserThanMinNumberThrowsException(): void { $this->expectException(\InvalidArgumentException::class); $minNumber = 10; @@ -206,7 +206,7 @@ public function setMaxNumberLesserThanMinNumberThrowsException() /** * @test */ - public function getPriceReturnsInitialValueForFloat() + public function getPriceReturnsInitialValueForFloat(): void { self::assertSame( 0.0, @@ -217,7 +217,7 @@ public function getPriceReturnsInitialValueForFloat() /** * @test */ - public function setPriceSetsPrice() + public function setPriceSetsPrice(): void { $this->product->setPrice(3.14159265); @@ -230,7 +230,7 @@ public function setPriceSetsPrice() /** * @test */ - public function getSpecialPricesInitiallyIsEmpty() + public function getSpecialPricesInitiallyIsEmpty(): void { self::assertEmpty( $this->product->getSpecialPrices() @@ -240,7 +240,7 @@ public function getSpecialPricesInitiallyIsEmpty() /** * @test */ - public function setSpecialPricesSetsSpecialPrices() + public function setSpecialPricesSetsSpecialPrices(): void { $price = 10.00; @@ -261,7 +261,7 @@ public function setSpecialPricesSetsSpecialPrices() /** * @test */ - public function addSpecialPriceAddsSpecialPrice() + public function addSpecialPriceAddsSpecialPrice(): void { $price = 10.00; @@ -279,7 +279,7 @@ public function addSpecialPriceAddsSpecialPrice() /** * @test */ - public function removeSpecialPriceRemovesSpecialPrice() + public function removeSpecialPriceRemovesSpecialPrice(): void { $price = 10.00; @@ -297,7 +297,7 @@ public function removeSpecialPriceRemovesSpecialPrice() /** * @test */ - public function getBestSpecialPriceDiscountForEmptySpecialPriceReturnsDiscount() + public function getBestSpecialPriceDiscountForEmptySpecialPriceReturnsDiscount(): void { $price = 10.00; @@ -320,7 +320,7 @@ public function getBestSpecialPriceForGivenSpecialPricesReturnsBestSpecialPrice( $special2, $special3, $expectedBestSpecialPrice - ) { + ): void { $product = new Product(); $product->setPrice($price); @@ -345,7 +345,7 @@ public function getBestSpecialPriceForGivenSpecialPricesReturnsBestSpecialPrice( /** * @test */ - public function getBestSpecialPriceDiscountForGivenSpecialPriceReturnsPercentageDiscount() + public function getBestSpecialPriceDiscountForGivenSpecialPriceReturnsPercentageDiscount(): void { $price = 10.0; $porductSpecialPrice = 9.0; @@ -374,7 +374,7 @@ public function getBestSpecialPriceDiscountForGivenSpecialPricesReturnsBestPerce $special2, $special3, $expectedBestSpecialPriceDiscount - ) { + ): void { $product = new Product(); $product->setPrice($price); @@ -399,7 +399,7 @@ public function getBestSpecialPriceDiscountForGivenSpecialPricesReturnsBestPerce /** * @test */ - public function getStockWithoutHandleStockInitiallyReturnsIntMax() + public function getStockWithoutHandleStockInitiallyReturnsIntMax(): void { $product = new Product(); @@ -412,7 +412,7 @@ public function getStockWithoutHandleStockInitiallyReturnsIntMax() /** * @test */ - public function getStockWithHandleStockInitiallyReturnsZero() + public function getStockWithHandleStockInitiallyReturnsZero(): void { $product = new Product(); $product->setHandleStock(true); @@ -426,7 +426,7 @@ public function getStockWithHandleStockInitiallyReturnsZero() /** * @test */ - public function setStockWithHandleStockSetsStock() + public function setStockWithHandleStockSetsStock(): void { $stock = 10; @@ -450,7 +450,7 @@ public function setStockWithHandleStockSetsStock() /** * @test */ - public function addToStockAddsANumberOfProductsToStock() + public function addToStockAddsANumberOfProductsToStock(): void { $numberOfProducts = 10; @@ -467,7 +467,7 @@ public function addToStockAddsANumberOfProductsToStock() /** * @test */ - public function removeFromStockAddsRemovesANumberOfProductsFromStock() + public function removeFromStockAddsRemovesANumberOfProductsFromStock(): void { $stock = 100; $numberOfProducts = 10; @@ -486,7 +486,7 @@ public function removeFromStockAddsRemovesANumberOfProductsFromStock() /** * @test */ - public function handleStockInitiallyReturnsFalse() + public function handleStockInitiallyReturnsFalse(): void { $product = new Product(); @@ -498,7 +498,7 @@ public function handleStockInitiallyReturnsFalse() /** * @test */ - public function setHandleStockSetsHandleStock() + public function setHandleStockSetsHandleStock(): void { $product = new Product(); $product->setHandleStock(true); @@ -511,7 +511,7 @@ public function setHandleStockSetsHandleStock() /** * @test */ - public function isAvailableInitiallyReturnsTrue() + public function isAvailableInitiallyReturnsTrue(): void { $product = new Product(); @@ -523,7 +523,7 @@ public function isAvailableInitiallyReturnsTrue() /** * @test */ - public function isAvailableWithHandleStockIsEnabledAndEmptyStockReturnsFalse() + public function isAvailableWithHandleStockIsEnabledAndEmptyStockReturnsFalse(): void { $product = new Product(); $product->setHandleStock(true); @@ -536,7 +536,7 @@ public function isAvailableWithHandleStockIsEnabledAndEmptyStockReturnsFalse() /** * @test */ - public function isAvailableWithHandleStockIsEnabledAndNotEmptyStockReturnsTrue() + public function isAvailableWithHandleStockIsEnabledAndNotEmptyStockReturnsTrue(): void { $product = new Product(); $product->setStock(10); @@ -550,7 +550,7 @@ public function isAvailableWithHandleStockIsEnabledAndNotEmptyStockReturnsTrue() /** * @test */ - public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndNoBackendVariantsConfiguredReturnsFalse() + public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndNoBackendVariantsConfiguredReturnsFalse(): void { $product = new Product(); $product->setStock(10); @@ -565,7 +565,7 @@ public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndNo /** * @test */ - public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndBackendVariantConfiguredIsNotAvailableReturnsFalse() + public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndBackendVariantConfiguredIsNotAvailableReturnsFalse(): void { $productBackendVariant = $this->createMock( BeVariant::class @@ -586,7 +586,7 @@ public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndBa /** * @test */ - public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndBackendVariantConfiguredIsAvailableReturnsFalse() + public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndBackendVariantConfiguredIsAvailableReturnsFalse(): void { $productBackendVariant = $this->createMock( BeVariant::class @@ -607,7 +607,7 @@ public function isAvailableWithHandleStockAndHandleStockInVariantsIsEnabledAndBa /** * @test */ - public function getTaxClassIdInitiallyReturnsTaxClassId() + public function getTaxClassIdInitiallyReturnsTaxClassId(): void { self::assertSame( 1, @@ -618,7 +618,7 @@ public function getTaxClassIdInitiallyReturnsTaxClassId() /** * @test */ - public function setTaxClassIdSetsTaxClassId() + public function setTaxClassIdSetsTaxClassId(): void { $taxClassId = 2; @@ -633,7 +633,7 @@ public function setTaxClassIdSetsTaxClassId() /** * @test */ - public function getBeVariantAttribute1InitiallyIsNull() + public function getBeVariantAttribute1InitiallyIsNull(): void { self::assertNull( $this->product->getBeVariantAttribute1() @@ -643,7 +643,7 @@ public function getBeVariantAttribute1InitiallyIsNull() /** * @test */ - public function setBeVariantAttribute1SetsBeVariantAttribute1() + public function setBeVariantAttribute1SetsBeVariantAttribute1(): void { $beVariantAttribute = new BeVariantAttribute(); @@ -658,7 +658,7 @@ public function setBeVariantAttribute1SetsBeVariantAttribute1() /** * @test */ - public function getBeVariantAttribute2InitiallyIsNull() + public function getBeVariantAttribute2InitiallyIsNull(): void { self::assertNull( $this->product->getBeVariantAttribute2() @@ -668,7 +668,7 @@ public function getBeVariantAttribute2InitiallyIsNull() /** * @test */ - public function setBeVariantAttribute2SetsBeVariantAttribute2() + public function setBeVariantAttribute2SetsBeVariantAttribute2(): void { $beVariantAttribute = new BeVariantAttribute(); @@ -683,7 +683,7 @@ public function setBeVariantAttribute2SetsBeVariantAttribute2() /** * @test */ - public function getBeVariantAttribute3InitiallyIsNull() + public function getBeVariantAttribute3InitiallyIsNull(): void { self::assertNull( $this->product->getBeVariantAttribute3() @@ -693,7 +693,7 @@ public function getBeVariantAttribute3InitiallyIsNull() /** * @test */ - public function setBeVariantAttribute3SetsBeVariantAttribute3() + public function setBeVariantAttribute3SetsBeVariantAttribute3(): void { $beVariantAttribute = new BeVariantAttribute(); @@ -708,7 +708,7 @@ public function setBeVariantAttribute3SetsBeVariantAttribute3() /** * @test */ - public function getVariantsInitiallyIsEmpty() + public function getVariantsInitiallyIsEmpty(): void { self::assertEmpty( $this->product->getBeVariants() @@ -718,7 +718,7 @@ public function getVariantsInitiallyIsEmpty() /** * @test */ - public function setVariantsSetsVariants() + public function setVariantsSetsVariants(): void { $variant = new BeVariant(); @@ -736,7 +736,7 @@ public function setVariantsSetsVariants() /** * @test */ - public function addVariantAddsVariant() + public function addVariantAddsVariant(): void { $variant = new BeVariant(); @@ -751,7 +751,7 @@ public function addVariantAddsVariant() /** * @test */ - public function removeVariantRemovesVariant() + public function removeVariantRemovesVariant(): void { $variant = new BeVariant(); diff --git a/Tests/Unit/Domain/Model/Product/QuantityDiscountTest.php b/Tests/Unit/Domain/Model/Product/QuantityDiscountTest.php index c20af1d3..04854e7f 100644 --- a/Tests/Unit/Domain/Model/Product/QuantityDiscountTest.php +++ b/Tests/Unit/Domain/Model/Product/QuantityDiscountTest.php @@ -25,7 +25,7 @@ public function tearDown(): void /** * @test */ - public function getPriceInitiallyReturnsZero() + public function getPriceInitiallyReturnsZero(): void { self::assertSame( 0.0, @@ -36,7 +36,7 @@ public function getPriceInitiallyReturnsZero() /** * @test */ - public function setPriceSetThePrice() + public function setPriceSetThePrice(): void { $price = 1.00; @@ -51,7 +51,7 @@ public function setPriceSetThePrice() /** * @test */ - public function getQuantityInitiallyReturnsZero() + public function getQuantityInitiallyReturnsZero(): void { self::assertSame( 0, @@ -62,7 +62,7 @@ public function getQuantityInitiallyReturnsZero() /** * @test */ - public function setQuantitySetTheQuantity() + public function setQuantitySetTheQuantity(): void { $quantity = 10; diff --git a/Tests/Unit/Domain/Model/Product/SpecialPriceTest.php b/Tests/Unit/Domain/Model/Product/SpecialPriceTest.php index 1fb53b34..8092376f 100644 --- a/Tests/Unit/Domain/Model/Product/SpecialPriceTest.php +++ b/Tests/Unit/Domain/Model/Product/SpecialPriceTest.php @@ -25,7 +25,7 @@ public function tearDown(): void /** * @test */ - public function getTitleInitiallyReturnsEmptyString() + public function getTitleInitiallyReturnsEmptyString(): void { self::assertSame( '', @@ -36,7 +36,7 @@ public function getTitleInitiallyReturnsEmptyString() /** * @test */ - public function setTitleSetsTitle() + public function setTitleSetsTitle(): void { $title = 'Special Price Title'; @@ -51,7 +51,7 @@ public function setTitleSetsTitle() /** * @test */ - public function getPriceInitiallyReturnsZero() + public function getPriceInitiallyReturnsZero(): void { self::assertSame( 0.0, @@ -62,7 +62,7 @@ public function getPriceInitiallyReturnsZero() /** * @test */ - public function setPriceSetThePrice() + public function setPriceSetThePrice(): void { $price = 1.00; diff --git a/composer.json b/composer.json index cea203e7..74f8d6ea 100644 --- a/composer.json +++ b/composer.json @@ -63,7 +63,7 @@ "helmich/typo3-typoscript-lint": "^3.1", "overtrue/phplint": "^5.5", "phpstan/phpstan": "^1.10", - "ssch/typo3-rector": "^1.2", + "ssch/typo3-rector": "^2.6", "typo3/cms-dashboard": "^12.4", "typo3/cms-fluid-styled-content": "^12.4", "typo3/testing-framework": "^8.0" diff --git a/ext_localconf.php b/ext_localconf.php index a8c8e134..5b032aca 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -1,52 +1,62 @@ 'show, list, teaser, showForm', + ProductController::class => 'show, list, teaser, showForm', ], [ - \Extcode\CartProducts\Controller\ProductController::class => 'showForm', + ProductController::class => 'showForm', ] ); -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( +ExtensionUtility::configurePlugin( 'cart_products', 'TeaserProducts', [ - \Extcode\CartProducts\Controller\ProductController::class => 'teaser, showForm', + ProductController::class => 'teaser, showForm', ], [ - \Extcode\CartProducts\Controller\ProductController::class => 'showForm', + ProductController::class => 'showForm', ] ); -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( +ExtensionUtility::configurePlugin( 'cart_products', 'SingleProduct', [ - \Extcode\CartProducts\Controller\ProductController::class => 'show, showForm', + ProductController::class => 'show, showForm', ], [ - \Extcode\CartProducts\Controller\ProductController::class => 'showForm', + ProductController::class => 'showForm', ] ); -\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( +ExtensionUtility::configurePlugin( 'cart_products', 'ProductPartial', [ - \Extcode\CartProducts\Controller\ProductController::class => 'showForm', + ProductController::class => 'showForm', ], [ - \Extcode\CartProducts\Controller\ProductController::class => 'showForm', + ProductController::class => 'showForm', ] ); @@ -59,14 +69,14 @@ 'ext-cartproducts-wizard-icon' => 'cartproducts_plugin_wizard.svg', ]; -$iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( - \TYPO3\CMS\Core\Imaging\IconRegistry::class +$iconRegistry = GeneralUtility::makeInstance( + IconRegistry::class ); foreach ($icons as $identifier => $fileName) { $iconRegistry->registerIcon( $identifier, - \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + SvgIconProvider::class, [ 'source' => 'EXT:cart_products/Resources/Public/Icons/' . $fileName, ] @@ -75,7 +85,7 @@ // TSconfig -\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig(' +ExtensionManagementUtility::addPageTSConfig(' '); @@ -84,12 +94,12 @@ // processDatamapClass Hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass']['cartproducts_allowed'] = - \Extcode\CartProducts\Hooks\DatamapDataHandlerHook::class; + DatamapDataHandlerHook::class; // clearCachePostProc Hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['cartproducts_clearcache'] = - \Extcode\CartProducts\Hooks\DataHandler::class . '->clearCachePostProc'; + DataHandler::class . '->clearCachePostProc'; // register "cartproducts:" namespace $GLOBALS['TYPO3_CONF_VARS']['SYS']['fluid']['namespaces']['cartproducts'][] @@ -97,7 +107,7 @@ // update wizard for slugs $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update']['cartProductsSlugUpdater'] = - \Extcode\CartProducts\Updates\SlugUpdater::class; + SlugUpdater::class; // register listTemplateLayouts $GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['products'][] = [$_LLL_be . 'flexforms_template.templateLayout.products.table', 'table']; diff --git a/rector.php b/rector.php index eefb2fb6..6a9f6867 100644 --- a/rector.php +++ b/rector.php @@ -3,91 +3,51 @@ declare(strict_types=1); use Rector\Config\RectorConfig; -use Rector\Core\Configuration\Option; -use Rector\Core\ValueObject\PhpVersion; use Rector\PostRector\Rector\NameImportingPostRector; +use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector; +use Rector\ValueObject\PhpVersion; +use Ssch\TYPO3Rector\CodeQuality\General\ConvertImplicitVariablesToExplicitGlobalsRector; +use Ssch\TYPO3Rector\CodeQuality\General\ExtEmConfRector; use Ssch\TYPO3Rector\Configuration\Typo3Option; -use Ssch\TYPO3Rector\Rector\General\ConvertImplicitVariablesToExplicitGlobalsRector; -use Ssch\TYPO3Rector\Rector\General\ExtEmConfRector; use Ssch\TYPO3Rector\Set\Typo3LevelSetList; - -return static function (RectorConfig $rectorConfig): void { - // If you want to override the number of spaces for your typoscript files you can define it here, the default value is 4 - // $parameters = $rectorConfig->parameters(); - // $parameters->set(Typo3Option::TYPOSCRIPT_INDENT_SIZE, 2); - - $rectorConfig->sets([ +use Ssch\TYPO3Rector\Set\Typo3SetList; + +return RectorConfig::configure() + ->withImportNames(true, true, false, true) + ->withPaths([ + __DIR__ . '/Classes', + __DIR__ . '/Configuration', + __DIR__ . '/Tests', + __DIR__ . '/ext_emconf.php', + __DIR__ . '/ext_localconf.php', + ]) + // uncomment to reach your current PHP version + ->withPhpSets(php81: true) + ->withPhpVersion(PhpVersion::PHP_81) + ->withSets([ + Typo3SetList::CODE_QUALITY, + Typo3SetList::GENERAL, Typo3LevelSetList::UP_TO_TYPO3_12, - ]); - - // Define your target version which you want to support - $rectorConfig->phpVersion(PhpVersion::PHP_74); - - // If you only want to process one/some TYPO3 extension(s), you can specify its path(s) here. - // If you use the option --config change __DIR__ to getcwd() - // $rectorConfig->paths([ - // __DIR__ . '/packages/acme_demo/', - // ]); - - // When you use rector there are rules that require some more actions like creating UpgradeWizards for outdated TCA types. - // To fully support you we added some warnings. So watch out for them. - - // If you use importNames(), you should consider excluding some TYPO3 files. - $rectorConfig->skip([ + ]) + // To have a better analysis from PHPStan, we teach it here some more things + ->withPHPStanConfigs([ + Typo3Option::PHPSTAN_FOR_RECTOR_PATH, + ]) + ->withRules([ + AddVoidReturnTypeWhereNoReturnRector::class, + ConvertImplicitVariablesToExplicitGlobalsRector::class, + ]) + ->withConfiguredRule(ExtEmConfRector::class, [ + ExtEmConfRector::PHP_VERSION_CONSTRAINT => '8.1.0-8.3.99', + ExtEmConfRector::TYPO3_VERSION_CONSTRAINT => '12.4.0-12.4.99', + ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], + ]) + // If you use withImportNames(), you should consider excluding some TYPO3 files. + ->withSkip([ // @see https://github.com/sabbelasichon/typo3-rector/issues/2536 __DIR__ . '/**/Configuration/ExtensionBuilder/*', - // We skip those directories on purpose as there might be node_modules or similar - // that include typescript which would result in false positive processing - __DIR__ . '/**/Resources/**/node_modules/*', - __DIR__ . '/**/Resources/**/NodeModules/*', - __DIR__ . '/**/Resources/**/BowerComponents/*', - __DIR__ . '/**/Resources/**/bower_components/*', - __DIR__ . '/**/Resources/**/build/*', - __DIR__ . '/vendor/*', - __DIR__ . '/Build/*', - __DIR__ . '/public/*', - __DIR__ . '/.github/*', - __DIR__ . '/.Build/*', NameImportingPostRector::class => [ - 'ext_localconf.php', - 'ext_tables.php', 'ClassAliasMap.php', - __DIR__ . '/**/Configuration/*.php', - __DIR__ . '/**/Configuration/**/*.php', ], - ]); - - // If you have trouble that rector cannot run because some TYPO3 constants are not defined add an additional constants file - // @see https://github.com/sabbelasichon/typo3-rector/blob/master/typo3.constants.php - // @see https://github.com/rectorphp/rector/blob/main/docs/static_reflection_and_autoload.md#include-files - // $parameters->set(Option::BOOTSTRAP_FILES, [ - // __DIR__ . '/typo3.constants.php' - // ]); - - // register a single rule - // $rectorConfig->rule(\Ssch\TYPO3Rector\Rector\v9\v0\InjectAnnotationRector::class); - - /** - * Useful rule from RectorPHP itself to transform i.e. GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager') - * to GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class) calls. - * But be warned, sometimes it produces false positives (edge cases), so watch out - */ - // $rectorConfig->rule(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class); - - // 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. - /* $rectorConfig->ruleWithConfiguration(\Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector::class, [ - \Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v10\v0\ExtbasePersistenceTypoScriptRector::FILENAME => __DIR__ . '/packages/acme_demo/Configuration/Extbase/Persistence/Classes.php', - ]); */ - // Add some general TYPO3 rules - $rectorConfig->rule(ConvertImplicitVariablesToExplicitGlobalsRector::class); - $rectorConfig->ruleWithConfiguration(ExtEmConfRector::class, [ - ExtEmConfRector::ADDITIONAL_VALUES_TO_BE_REMOVED => [], - ]); - - // Modernize your TypoScript include statements for files and move from to @import use the FileIncludeToImportStatementVisitor (introduced with TYPO3 9.0) - // $rectorConfig->rule(\Ssch\TYPO3Rector\FileProcessor\TypoScript\Rector\v9\v0\FileIncludeToImportStatementTypoScriptRector::class); -}; + ]) +; From d08e93d1e830709da254d2dcf84cf14cfa421065 Mon Sep 17 00:00:00 2001 From: Gerald R <44193208+rintisch@users.noreply.github.com> Date: Wed, 19 Jun 2024 12:23:15 +0200 Subject: [PATCH 2/6] [BUG] Use label instead of hard-coded text (#161) Replaces the hard-coded text with a proper translation. --- Resources/Private/Language/locallang.xlf | 5 ++++- Resources/Private/Partials/Product/Price.html | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index a86ac201..f1077af7 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -44,6 +44,9 @@ Add to cart + + You save + Please choose ... @@ -204,4 +207,4 @@ - \ No newline at end of file + diff --git a/Resources/Private/Partials/Product/Price.html b/Resources/Private/Partials/Product/Price.html index e401822b..6a76bd7f 100644 --- a/Resources/Private/Partials/Product/Price.html +++ b/Resources/Private/Partials/Product/Price.html @@ -20,7 +20,7 @@
- (Sie sparen: %) + (: %)
@@ -50,4 +50,4 @@ - \ No newline at end of file + From 5534f8171f76293ff222f7eb875933b613d5c5e0 Mon Sep 17 00:00:00 2001 From: Gerald R <44193208+rintisch@users.noreply.github.com> Date: Wed, 19 Jun 2024 12:24:35 +0200 Subject: [PATCH 3/6] [BUGFIX] Register Category model properly (#171) To avoid an error when adding a category to a product it's necessary to register the extended Category model properly. Fixes: #170 --- ext_localconf.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ext_localconf.php b/ext_localconf.php index 5b032aca..ab7c2651 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -114,3 +114,7 @@ $GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['products'][] = [$_LLL_be . 'flexforms_template.templateLayout.products.grid', 'grid']; $GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['teaser_products'][] = [$_LLL_be . 'flexforms_template.templateLayout.products.table', 'table']; $GLOBALS['TYPO3_CONF_VARS']['EXT']['cart_products']['templateLayouts']['teaser_products'][] = [$_LLL_be . 'flexforms_template.templateLayout.products.grid', 'grid']; + +$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][\TYPO3\CMS\Extbase\Domain\Model\Category::class] = [ + 'className' => \Extcode\CartProducts\Domain\Model\Category::class, +]; From 549028717c51e74d7154c8eeff5ed467349bd17a Mon Sep 17 00:00:00 2001 From: Gerald R <44193208+rintisch@users.noreply.github.com> Date: Fri, 21 Jun 2024 22:38:19 +0200 Subject: [PATCH 4/6] [TASK] Add JS files with AssetViewHelper (#135) * [TASK] Add JS files with AssetViewHelper Use AssetViewHelper to add JS from EXT:cart when needed. * [DOCS] Add breaking docu for AssetViewHelper --- ...king-135-AddJsFilesWithAssetViewHelper.rst | 37 +++++++++++++++++++ Documentation/Changelog/5.0/Index.rst | 30 +++++++++++++++ Documentation/Changelog/Index.rst | 1 + .../Private/Partials/Product/CartForm.html | 3 ++ 4 files changed, 71 insertions(+) create mode 100644 Documentation/Changelog/5.0/Breaking-135-AddJsFilesWithAssetViewHelper.rst create mode 100644 Documentation/Changelog/5.0/Index.rst diff --git a/Documentation/Changelog/5.0/Breaking-135-AddJsFilesWithAssetViewHelper.rst b/Documentation/Changelog/5.0/Breaking-135-AddJsFilesWithAssetViewHelper.rst new file mode 100644 index 00000000..b4caf4f6 --- /dev/null +++ b/Documentation/Changelog/5.0/Breaking-135-AddJsFilesWithAssetViewHelper.rst @@ -0,0 +1,37 @@ +.. include:: ../../Includes.txt + +================================================== +Breaking: #135 - Add JS files with AssetViewHelper +================================================== + +See :issue:`135` + +Description +=========== + +EXT:cart v9 uses modularized JavaScript without jQuery (see +:ref:` [TASK] Switch from jQuery to vanilla JavaScript #438 `). + +This allows to add the JavaScript only on pages where it's really needed which +is good for performance. The JavaScript is for detail pages is now loaded with +the TYPO3 :ref:`Asset.script ViewHelper`. + +Affected Installations +====================== + +All installations which overwrite +`Resources/Private/Partials/Product/CartForm.html` are affected. +When using the `CartForm.html` which comes with this extension it will work +without any changes. + +Migration +========= + +The JavaScript in EXT:cart is no longer added via TypoScript. All JavaScript +files are now added via ViewHelper. + +Two ViewHelpers needs to be added in `Resources/Private/Partials/Product/CartForm.html`: + * `` + * `` (only when working with BE Variants). + +.. index:: Template, Frontend diff --git a/Documentation/Changelog/5.0/Index.rst b/Documentation/Changelog/5.0/Index.rst new file mode 100644 index 00000000..d4775fc4 --- /dev/null +++ b/Documentation/Changelog/5.0/Index.rst @@ -0,0 +1,30 @@ +.. include:: ../../Includes.txt + +5.0 Changes +=========== + +**Table of contents** + +.. contents:: + :local: + :depth: 1 + +Breaking Changes +^^^^^^^^^^^^^^^^ + +.. toctree:: + :maxdepth: 1 + :titlesonly: + :glob: + + Breaking-* + +Features +^^^^^^^^ + +.. toctree:: + :maxdepth: 1 + :titlesonly: + :glob: + + Feature-* diff --git a/Documentation/Changelog/Index.rst b/Documentation/Changelog/Index.rst index 5c8df118..41579713 100644 --- a/Documentation/Changelog/Index.rst +++ b/Documentation/Changelog/Index.rst @@ -8,6 +8,7 @@ ChangeLog :maxdepth: 5 :titlesonly: + 5.0/Index 4.0/Index 3.0/Index 2.4/Index diff --git a/Resources/Private/Partials/Product/CartForm.html b/Resources/Private/Partials/Product/CartForm.html index 4b70c6da..39a7890d 100644 --- a/Resources/Private/Partials/Product/CartForm.html +++ b/Resources/Private/Partials/Product/CartForm.html @@ -2,6 +2,8 @@ xmlns:cartproducts="http://typo3.org/ns/Extcode/CartProducts/ViewHelpers" data-namespace-typo3-fluid="true"> + +
+ Date: Fri, 21 Jun 2024 22:39:59 +0200 Subject: [PATCH 5/6] [BUGFIX] Fix availability check for BE variants (#133) * [BUGFIX] Fix availability check for BE variants BE variants can no longer be added to the cart if the requested amount exceeds the stock. The old implementation set the compare quantity to zero which was wrong as it must be the quantity which is in the cart of the customer. * [BUGFIX] Convert quantity to string --- Classes/EventListener/CheckProductAvailability.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/EventListener/CheckProductAvailability.php b/Classes/EventListener/CheckProductAvailability.php index 227219d2..f8342365 100644 --- a/Classes/EventListener/CheckProductAvailability.php +++ b/Classes/EventListener/CheckProductAvailability.php @@ -66,7 +66,7 @@ public function __invoke(CheckProductAvailabilityEvent $event): void return; } - $compareQuantity = 0; + $compareQuantity = (int)$quantity; foreach ($cartProduct->getBeVariants() as $beVariant) { if ( From ed2231ff440506cf22a5515f6a8c78c86a919940 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Fri, 21 Jun 2024 23:10:37 +0200 Subject: [PATCH 6/6] [BUGFIX] Add typo3/cms-install to dev dependencies --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 74f8d6ea..8d9fb4bf 100644 --- a/composer.json +++ b/composer.json @@ -66,6 +66,7 @@ "ssch/typo3-rector": "^2.6", "typo3/cms-dashboard": "^12.4", "typo3/cms-fluid-styled-content": "^12.4", + "typo3/cms-install": "^12.4", "typo3/testing-framework": "^8.0" }, "scripts": {