diff --git a/Build/UnitTestsBootstrap.php b/Build/UnitTestsBootstrap.php index d2cd5570..26a03f23 100644 --- a/Build/UnitTestsBootstrap.php +++ b/Build/UnitTestsBootstrap.php @@ -1,5 +1,18 @@ defineSitePath(); - $requestType = \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_BE | \TYPO3\CMS\Core\Core\SystemEnvironmentBuilder::REQUESTTYPE_CLI; + $requestType = SystemEnvironmentBuilder::REQUESTTYPE_BE | SystemEnvironmentBuilder::REQUESTTYPE_CLI; \TYPO3\TestingFramework\Core\SystemEnvironmentBuilder::run(0, $requestType); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3conf/ext'); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/assets'); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/tests'); - $testbase->createDirectory(\TYPO3\CMS\Core\Core\Environment::getPublicPath() . '/typo3temp/var/transient'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3conf/ext'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/assets'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/tests'); + $testbase->createDirectory(Environment::getPublicPath() . '/typo3temp/var/transient'); // Retrieve an instance of class loader and inject to core bootstrap $classLoader = require $testbase->getPackagesPath() . '/autoload.php'; - \TYPO3\CMS\Core\Core\Bootstrap::initializeClassLoader($classLoader); + Bootstrap::initializeClassLoader($classLoader); // Initialize default TYPO3_CONF_VARS - $configurationManager = new \TYPO3\CMS\Core\Configuration\ConfigurationManager(); + $configurationManager = new ConfigurationManager(); $GLOBALS['TYPO3_CONF_VARS'] = $configurationManager->getDefaultConfiguration(); - $cache = new \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend( + $cache = new PhpFrontend( 'core', - new \TYPO3\CMS\Core\Cache\Backend\NullBackend('production', []) + new NullBackend('production', []) ); // Set all packages to active - if (interface_exists(\TYPO3\CMS\Core\Package\Cache\PackageCacheInterface::class)) { - $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(\TYPO3\CMS\Core\Package\UnitTestPackageManager::class, \TYPO3\CMS\Core\Core\Bootstrap::createPackageCache($cache)); + if (interface_exists(PackageCacheInterface::class)) { + $packageManager = Bootstrap::createPackageManager(UnitTestPackageManager::class, Bootstrap::createPackageCache($cache)); } else { // v10 compatibility layer // @deprecated Will be removed when v10 compat is dropped from testing-framework - $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::createPackageManager(\TYPO3\CMS\Core\Package\UnitTestPackageManager::class, $cache); + $packageManager = Bootstrap::createPackageManager(UnitTestPackageManager::class, $cache); } - \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Core\Package\PackageManager::class, $packageManager); - \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::setPackageManager($packageManager); + GeneralUtility::setSingletonInstance(PackageManager::class, $packageManager); + ExtensionManagementUtility::setPackageManager($packageManager); $testbase->dumpClassLoadingInformation(); - \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances(); + GeneralUtility::purgeInstances(); })(); diff --git a/Build/phpstan-baseline.neon b/Build/phpstan-baseline.neon index 3cfb689d..60803279 100644 --- a/Build/phpstan-baseline.neon +++ b/Build/phpstan-baseline.neon @@ -1,21 +1,205 @@ parameters: ignoreErrors: - - message: "#^Call to an undefined method Extcode\\\\Cart\\\\Service\\\\PaymentMethodsServiceInterface\\:\\:getConfigurationsForType\\(\\)\\.$#" + message: '#^Call to an undefined method Extcode\\Cart\\Service\\PaymentMethodsServiceInterface\:\:getConfigurationsForType\(\)\.$#' + identifier: method.notFound count: 1 path: ../Classes/Controller/Cart/OrderController.php - - message: "#^Call to an undefined method Extcode\\\\Cart\\\\Domain\\\\Model\\\\Cart\\\\CartCouponInterface\\:\\:getTaxClass\\(\\)\\.$#" + message: '#^Instanceof between Extcode\\Cart\\Domain\\Model\\Cart\\ProductInterface and Extcode\\Cart\\Domain\\Model\\Cart\\ProductInterface will always evaluate to true\.$#' + identifier: instanceof.alwaysTrue + count: 1 + path: ../Classes/Domain/Model/Cart/BeVariant.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Domain\\Model\\Cart\\CartCouponInterface\:\:getTaxClass\(\)\.$#' + identifier: method.notFound count: 2 path: ../Classes/Domain/Model/Cart/Cart.php - - message: "#^Call to an undefined method Extcode\\\\Cart\\\\Domain\\\\Model\\\\Cart\\\\CartCouponInterface\\:\\:setCart\\(\\)\\.$#" + message: '#^Call to an undefined method Extcode\\Cart\\Domain\\Model\\Cart\\CartCouponInterface\:\:setCart\(\)\.$#' + identifier: method.notFound count: 1 path: ../Classes/Domain/Model/Cart/Cart.php - - message: "#^Call to an undefined method Extcode\\\\Cart\\\\Service\\\\PaymentMethodsServiceInterface\\:\\:getConfigurationsForType\\(\\)\\.$#" + message: '#^Call to an undefined method Extcode\\Cart\\Service\\PaymentMethodsServiceInterface\:\:getConfigurationsForType\(\)\.$#' + identifier: method.notFound count: 1 path: ../Classes/EventListener/Order/Finish/ClearCart.php + + - + message: '#^Method TYPO3\\CMS\\Form\\Mvc\\Persistence\\FormPersistenceManagerInterface\:\:listForms\(\) invoked with 1 parameter, 2 required\.$#' + identifier: arguments.count + count: 1 + path: ../Classes/Hooks/FormDefinitions.php + + - + message: '#^Parameter \$cacheManager of method Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:__construct\(\) has invalid type Extcode\\Cart\\Hooks\\CacheManager\.$#' + identifier: class.notFound + count: 1 + path: ../Classes/Hooks/ItemsProcFunc.php + + - + message: '#^Parameter \$resourceFactory of method Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:__construct\(\) has invalid type Extcode\\Cart\\Hooks\\ResourceFactory\.$#' + identifier: class.notFound + count: 1 + path: ../Classes/Hooks/ItemsProcFunc.php + + - + message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$cacheManager has unknown class Extcode\\Cart\\Hooks\\CacheManager as its type\.$#' + identifier: class.notFound + count: 1 + path: ../Classes/Hooks/ItemsProcFunc.php + + - + message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$cacheManager is never read, only written\.$#' + identifier: property.onlyWritten + count: 1 + path: ../Classes/Hooks/ItemsProcFunc.php + + - + message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$resourceFactory has unknown class Extcode\\Cart\\Hooks\\ResourceFactory as its type\.$#' + identifier: class.notFound + count: 1 + path: ../Classes/Hooks/ItemsProcFunc.php + + - + message: '#^Property Extcode\\Cart\\Hooks\\ItemsProcFunc\:\:\$resourceFactory is never read, only written\.$#' + identifier: property.onlyWritten + count: 1 + path: ../Classes/Hooks/ItemsProcFunc.php + + - + message: '#^Attribute class TYPO3\\CMS\\Install\\Attribute\\UpgradeWizard is deprecated\: since v14\.0, will be removed in TYPO34 v15\.0\. Use \\TYPO3\\CMS\\Core\\Attribute\\UpgradeWizard instead\.$#' + identifier: attribute.deprecated + count: 1 + path: ../Classes/Updates/ExtcodeCartCTypeMigration.php + + - + message: ''' + #^Class Extcode\\Cart\\Updates\\ExtcodeCartCTypeMigration extends deprecated class TYPO3\\CMS\\Install\\Updates\\AbstractListTypeToCTypeUpdate\: + since v14\.0, will be removed in TYPO34 v15\.0\. Use \\TYPO3\\CMS\\Core\\Upgrades\\AbstractListTypeToCTypeUpdate instead\.$# + ''' + identifier: class.extendsDeprecatedClass + count: 1 + path: ../Classes/Updates/ExtcodeCartCTypeMigration.php + + - + message: '#^Loose comparison using \!\= between non\-empty\-string and '''' will always evaluate to true\.$#' + identifier: notEqual.alwaysTrue + count: 1 + path: ../Classes/Validation/Validator/EmptyValidator.php + + - + message: '#^Access to constant on deprecated class TYPO3\\CMS\\Frontend\\Resource\\FilePathSanitizer\.$#' + identifier: classConstant.deprecatedClass + count: 1 + path: ../Classes/ViewHelpers/IncludeFileViewHelper.php + + - + message: '#^Call to method sanitize\(\) of deprecated class TYPO3\\CMS\\Frontend\\Resource\\FilePathSanitizer\.$#' + identifier: method.deprecatedClass + count: 1 + path: ../Classes/ViewHelpers/IncludeFileViewHelper.php + + - + message: '#^Strict comparison using \!\=\= between '''' and '''' will always evaluate to false\.$#' + identifier: notIdentical.alwaysFalse + count: 1 + path: ../Classes/ViewHelpers/TitleTagViewHelper.php + + - + message: '#^Variable \$arguments on left side of \?\? is never defined\.$#' + identifier: nullCoalesce.variable + count: 1 + path: ../Classes/ViewHelpers/TitleTagViewHelper.php + + - + message: ''' + #^Call to deprecated method addPiFlexFormValue\(\) of class TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility\: + Will be removed in TYPO3 v15$# + ''' + identifier: staticMethod.deprecated + count: 1 + path: ../Configuration/TCA/Overrides/tt_content.php + + - + message: '#^Call to an undefined method PHPUnit\\Framework\\MockObject\\MockBuilder\\:\:disableAutoload\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Cart/BeVariantTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Order\\AbstractAddressTest\:\:getMockForAbstractClass\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php + + - + message: '#^Call to an undefined method PHPUnit\\Framework\\MockObject\\MockBuilder\\:\:addMethods\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php + + - + message: '#^Call to static method PHPUnit\\Framework\\Assert\:\:assertIsArray\(\) with array will always evaluate to true\.$#' + identifier: staticMethod.alreadyNarrowedType + count: 1 + path: ../Tests/Unit/Domain/Model/Order/AbstractAddressTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Order\\AbstractServiceTest\:\:getMockForAbstractClass\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Order/AbstractServiceTest.php + + - + message: '#^Call to new Extcode\\Cart\\Domain\\Model\\Order\\Discount\(\) on a separate line has no effect\.$#' + identifier: new.resultUnused + count: 6 + path: ../Tests/Unit/Domain/Model/Order/DiscountTest.php + + - + message: '#^Call to new Extcode\\Cart\\Domain\\Model\\Order\\Tax\(\) on a separate line has no effect\.$#' + identifier: new.resultUnused + count: 2 + path: ../Tests/Unit/Domain/Model/Order/TaxTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\AbstractProductTest\:\:getMockForAbstractClass\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Product/AbstractProductTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\CategoryTraitTest\:\:getObjectForTrait\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Product/CategoryTraitTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\MeasureTraitTest\:\:getObjectForTrait\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Product/MeasureTraitTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\ServiceAttributeTraitTest\:\:getObjectForTrait\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Product/ServiceAttributeTraitTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\StockTraitTest\:\:getObjectForTrait\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Product/StockTraitTest.php + + - + message: '#^Call to an undefined method Extcode\\Cart\\Tests\\Unit\\Domain\\Model\\Product\\TagTraitTest\:\:getObjectForTrait\(\)\.$#' + identifier: method.notFound + count: 1 + path: ../Tests/Unit/Domain/Model/Product/TagTraitTest.php diff --git a/Build/phpstan.neon b/Build/phpstan.neon index 13c67700..17f3f326 100644 --- a/Build/phpstan.neon +++ b/Build/phpstan.neon @@ -1,10 +1,36 @@ includes: - - phpstan-baseline.neon + - 'phpstan-baseline.neon' + parameters: level: 4 + paths: - ../Classes - ../Configuration - ../Tests - ../ext_emconf.php - ../ext_localconf.php + + disallowedFunctionCalls: + - + function: + - 'var_dump()' + - 'xdebug_break()' + message: 'Do not add debugging' + - + function: 'header()' + message: 'Use API instead' + + disallowedStaticCalls: + - + method: 'TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump()' + message: 'Do not add debugging' + + disallowedSuperglobals: + - + superglobal: + - '$_GET' + - '$_POST' + - '$_FILES' + - '$_SERVER' + message: 'Use API instead' diff --git a/Classes/Controller/Backend/ActionController.php b/Classes/Controller/Backend/ActionController.php index 75ab8d30..bc5dd35c 100644 --- a/Classes/Controller/Backend/ActionController.php +++ b/Classes/Controller/Backend/ActionController.php @@ -12,12 +12,15 @@ */ use TYPO3\CMS\Backend\Utility\BackendUtility; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; +use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; class ActionController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController { protected array $pluginSettings = []; + public function __construct( + protected ConfigurationManagerInterface $configurationManager + ) {} protected function initializeAction(): void { @@ -33,9 +36,7 @@ protected function initializeAction(): void $GLOBALS['BE_USER']->getPagePermsClause(1) ); - $configurationManager = GeneralUtility::makeInstance( - ConfigurationManager::class - ); + $configurationManager = $this->configurationManager; $frameworkConf = $configurationManager->getConfiguration( diff --git a/Classes/Controller/Backend/Order/DocumentController.php b/Classes/Controller/Backend/Order/DocumentController.php index 3df52aa9..4bddb8dc 100644 --- a/Classes/Controller/Backend/Order/DocumentController.php +++ b/Classes/Controller/Backend/Order/DocumentController.php @@ -18,7 +18,6 @@ use Extcode\Cart\Event\Order\NumberGeneratorEvent; use Extcode\CartPdf\Service\PdfService; use Psr\Http\Message\ResponseInterface; -use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; diff --git a/Classes/Controller/Backend/Order/OrderController.php b/Classes/Controller/Backend/Order/OrderController.php index 15cefc8b..556ecb91 100644 --- a/Classes/Controller/Backend/Order/OrderController.php +++ b/Classes/Controller/Backend/Order/OrderController.php @@ -10,7 +10,6 @@ * For the full copyright and license information, please read the * LICENSE file that was distributed with this source code. */ - use Extcode\Cart\Controller\Backend\ActionController; use Extcode\Cart\Domain\Model\Cart\Cart; use Extcode\Cart\Domain\Model\Order\Item; @@ -20,6 +19,7 @@ use Extcode\Cart\Event\Template\Components\ModifyModuleTemplateEvent; use Psr\Http\Message\ResponseInterface; use TYPO3\CMS\Backend\Template\Components\ButtonBar; +use TYPO3\CMS\Backend\Template\Components\ComponentFactory; use TYPO3\CMS\Backend\Template\ModuleTemplate; use TYPO3\CMS\Backend\Template\ModuleTemplateFactory; use TYPO3\CMS\Core\Imaging\IconFactory; @@ -47,7 +47,8 @@ public function __construct( protected readonly IconFactory $iconFactory, protected readonly PersistenceManager $persistenceManager, protected readonly ItemRepository $itemRepository, - private readonly PageRenderer $pageRenderer + private readonly PageRenderer $pageRenderer, + private readonly ComponentFactory $componentFactory ) {} protected function initializeAction(): void @@ -275,9 +276,9 @@ private function setDocHeader(array $buttons): void foreach ($buttons as $button) { $title = $this->getLanguageService()->sL(self::LANG_FILE . $button['title']); - $icon = $this->iconFactory->getIcon($button['icon'], IconSize::SMALL->value); + $icon = $this->iconFactory->getIcon($button['icon'], IconSize::SMALL); - $viewButton = $buttonBar->makeLinkButton() + $viewButton = $this->componentFactory->createLinkButton() ->setHref($button['link']) ->setTitle($title) ->setShowLabelText($button['showLabel']) diff --git a/Classes/Controller/Cart/OrderController.php b/Classes/Controller/Cart/OrderController.php index fb01571d..aabcfd41 100644 --- a/Classes/Controller/Cart/OrderController.php +++ b/Classes/Controller/Cart/OrderController.php @@ -21,15 +21,12 @@ use Extcode\Cart\Event\Order\StockEvent; use Extcode\Cart\Event\ProcessOrderCheckStockEvent; use Extcode\Cart\Validation\Validator\EmptyValidator; -use Psr\EventDispatcher\StoppableEventInterface; use Psr\Http\Message\ResponseInterface; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Annotation\IgnoreValidation; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extbase\Validation\Validator\AbstractGenericObjectValidator; use TYPO3\CMS\Extbase\Validation\Validator\ConjunctionValidator; use TYPO3\CMS\Extbase\Validation\Validator\GenericObjectValidator; -use TYPO3\CMS\Extbase\Validation\ValidatorResolver; class OrderController extends ActionController { @@ -125,7 +122,7 @@ public function createAction( $paymentSettings = $this->paymentMethodsService->getConfigurationsForType('payments', $this->cart->getBillingCountry()); if (isset($paymentSettings['options'][$paymentId]['redirects']['success']['url'])) { - $this->redirectToUri($paymentSettings['options'][$paymentId]['redirects']['success']['url'], 0, 200); + return $this->redirectToUri($paymentSettings['options'][$paymentId]['redirects']['success']['url'], 0, 200); } $this->dispatchModifyViewEvent(); @@ -171,9 +168,7 @@ protected function setDynamicValidation( array $validatorConf ): void { // build custom validation chain - $validatorResolver = GeneralUtility::makeInstance( - ValidatorResolver::class - ); + $validatorResolver = $this->validatorResolver; if ($validatorConf['validator'] === 'Empty') { $validatorConf['validator'] = EmptyValidator::class; @@ -209,36 +204,36 @@ protected function dispatchOrderCreateEvents(Item $orderItem): bool { $createEvent = new CreateEvent($this->cart, $orderItem, $this->configurations); $this->eventDispatcher->dispatch($createEvent); - if ($createEvent instanceof StoppableEventInterface && $createEvent->isPropagationStopped()) { + if ($createEvent->isPropagationStopped()) { return true; } $onlyGenerateNumberOfType = []; if (!empty($this->configurations['autoGenerateNumbers'])) { - $onlyGenerateNumberOfType = array_map('trim', explode(',', (string)$this->configurations['autoGenerateNumbers'])); + $onlyGenerateNumberOfType = array_map(trim(...), explode(',', (string)$this->configurations['autoGenerateNumbers'])); } $generateNumbersEvent = new NumberGeneratorEvent($this->cart, $orderItem, $this->configurations); $generateNumbersEvent->setOnlyGenerateNumberOfType($onlyGenerateNumberOfType); $this->eventDispatcher->dispatch($generateNumbersEvent); - if ($generateNumbersEvent instanceof StoppableEventInterface && $generateNumbersEvent->isPropagationStopped()) { + if ($generateNumbersEvent->isPropagationStopped()) { return true; } $stockEvent = new StockEvent($this->cart, $orderItem, $this->configurations); $this->eventDispatcher->dispatch($stockEvent); - if ($stockEvent instanceof StoppableEventInterface && $stockEvent->isPropagationStopped()) { + if ($stockEvent->isPropagationStopped()) { return true; } $paymentEvent = new PaymentEvent($this->cart, $orderItem, $this->configurations); $this->eventDispatcher->dispatch($paymentEvent); - if ($paymentEvent instanceof StoppableEventInterface && $paymentEvent->isPropagationStopped()) { + if ($paymentEvent->isPropagationStopped()) { return true; } $finishEvent = new FinishEvent($this->cart, $orderItem, $this->configurations); $this->eventDispatcher->dispatch($finishEvent); - if ($finishEvent instanceof StoppableEventInterface && $finishEvent->isPropagationStopped()) { + if ($finishEvent->isPropagationStopped()) { return true; } diff --git a/Classes/Controller/Cart/ProductController.php b/Classes/Controller/Cart/ProductController.php index b93dc4b5..13c7e959 100644 --- a/Classes/Controller/Cart/ProductController.php +++ b/Classes/Controller/Cart/ProductController.php @@ -27,7 +27,7 @@ public function addAction(): ResponseInterface { if (!$this->request->hasArgument('productType')) { // TODO: add own Exception - throw new \Exception('productType is needed'); + throw new \Exception('productType is needed', 5200281451); } $this->restoreSession(); diff --git a/Classes/Domain/Finisher/Form/AddToCartFinisher.php b/Classes/Domain/Finisher/Form/AddToCartFinisher.php index 864c68b3..2b49858c 100644 --- a/Classes/Domain/Finisher/Form/AddToCartFinisher.php +++ b/Classes/Domain/Finisher/Form/AddToCartFinisher.php @@ -37,7 +37,9 @@ public function __construct( protected ConfigurationManagerInterface $configurationManager, protected SessionHandler $sessionHandler, protected CartUtility $cartUtility, - protected EventDispatcherInterface $eventDispatcher + protected EventDispatcherInterface $eventDispatcher, + private readonly ExtensionService $extensionService, + private readonly FlashMessageService $flashMessageService ) { $this->configurations = $this->configurationManager->getConfiguration( ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK, @@ -109,8 +111,8 @@ protected function executeInternal(): ?string true ); - $extensionService = GeneralUtility::makeInstance(ExtensionService::class); - $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class); + $extensionService = $this->extensionService; + $flashMessageService = $this->flashMessageService; // todo: this value has to be taken from the request directly in the future $pluginNamespace = $extensionService->getPluginNamespace( diff --git a/Classes/Domain/Model/Cart/Cart.php b/Classes/Domain/Model/Cart/Cart.php index e635b3aa..3722d051 100644 --- a/Classes/Domain/Model/Cart/Cart.php +++ b/Classes/Domain/Model/Cart/Cart.php @@ -725,34 +725,32 @@ public function changeProductsQuantity(array $productQuantityArray): void foreach ($productQuantityArray as $productPuid => $quantity) { $product = $this->products[$productPuid]; - if ($product instanceof Product) { - if (is_array($quantity)) { + if (is_array($quantity)) { + $this->subCount($product->getQuantity()); + $this->subGross($product->getGross()); + $this->subNet($product->getNet()); + $this->subTax($product->getTax(), $product->getTaxClass()); + + $product->changeVariantsQuantity($quantity); + + $this->addCount($product->getQuantity()); + $this->addGross($product->getGross()); + $this->addNet($product->getNet()); + $this->addTax($product->getTax(), $product->getTaxClass()); + } else { + // only run, if quantity was realy changed + if ($product->getQuantity() != $quantity) { $this->subCount($product->getQuantity()); $this->subGross($product->getGross()); $this->subNet($product->getNet()); $this->subTax($product->getTax(), $product->getTaxClass()); - $product->changeVariantsQuantity($quantity); + $product->changeQuantity($quantity); $this->addCount($product->getQuantity()); $this->addGross($product->getGross()); $this->addNet($product->getNet()); $this->addTax($product->getTax(), $product->getTaxClass()); - } else { - // only run, if quantity was realy changed - if ($product->getQuantity() != $quantity) { - $this->subCount($product->getQuantity()); - $this->subGross($product->getGross()); - $this->subNet($product->getNet()); - $this->subTax($product->getTax(), $product->getTaxClass()); - - $product->changeQuantity($quantity); - - $this->addCount($product->getQuantity()); - $this->addGross($product->getGross()); - $this->addNet($product->getNet()); - $this->addTax($product->getTax(), $product->getTaxClass()); - } } } @@ -791,7 +789,7 @@ public function removeProductById(string $productId): bool public function removeProduct(Product $product, array $productVariantIds = []): bool { - if (is_array($productVariantIds) && !empty($productVariantIds)) { + if (!empty($productVariantIds)) { $product->removeBeVariants($productVariantIds); if (!$product->getBeVariants()) { diff --git a/Classes/Domain/Model/Cart/Product.php b/Classes/Domain/Model/Cart/Product.php index 58d9a08b..fd963f86 100644 --- a/Classes/Domain/Model/Cart/Product.php +++ b/Classes/Domain/Model/Cart/Product.php @@ -312,7 +312,7 @@ public function setQuantityDiscounts(array $quantityDiscounts): void /** * Returns Best Price (min of Price and Special Price) */ - public function getBestPrice(?int $quantity = null): ?float + public function getBestPrice(?int $quantity = null): float { $bestPrice = $this->getQuantityDiscountPrice($quantity); diff --git a/Classes/Domain/Model/Product/CategoryTrait.php b/Classes/Domain/Model/Product/CategoryTrait.php index cc0df96b..88dd1ca0 100644 --- a/Classes/Domain/Model/Product/CategoryTrait.php +++ b/Classes/Domain/Model/Product/CategoryTrait.php @@ -14,7 +14,7 @@ use TYPO3\CMS\Extbase\Domain\Model\Category; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; -trait CategoryTrait +trait CategoryTrait // @phpstan-ignore trait.unused (provided for product extensions) { protected ?Category $category = null; diff --git a/Classes/Domain/Model/Product/FileAndImageTrait.php b/Classes/Domain/Model/Product/FileAndImageTrait.php index b5447e49..ff5ae5ba 100644 --- a/Classes/Domain/Model/Product/FileAndImageTrait.php +++ b/Classes/Domain/Model/Product/FileAndImageTrait.php @@ -13,7 +13,7 @@ use TYPO3\CMS\Extbase\Domain\Model\FileReference; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; -trait FileAndImageTrait +trait FileAndImageTrait // @phpstan-ignore trait.unused (provided for product extensions) { /** * @var ObjectStorage diff --git a/Classes/Domain/Model/Product/MeasureTrait.php b/Classes/Domain/Model/Product/MeasureTrait.php index fb1931f7..eb5cac3a 100644 --- a/Classes/Domain/Model/Product/MeasureTrait.php +++ b/Classes/Domain/Model/Product/MeasureTrait.php @@ -9,7 +9,7 @@ * LICENSE file that was distributed with this source code. */ -trait MeasureTrait +trait MeasureTrait // @phpstan-ignore trait.unused (provided for product extensions) { protected float $priceMeasure = 0.0; diff --git a/Classes/Domain/Model/Product/ServiceAttributeTrait.php b/Classes/Domain/Model/Product/ServiceAttributeTrait.php index cf1face1..039c6e33 100644 --- a/Classes/Domain/Model/Product/ServiceAttributeTrait.php +++ b/Classes/Domain/Model/Product/ServiceAttributeTrait.php @@ -9,7 +9,7 @@ * LICENSE file that was distributed with this source code. */ -trait ServiceAttributeTrait +trait ServiceAttributeTrait // @phpstan-ignore trait.unused (provided for product extensions) { protected float $serviceAttribute1 = 0.0; diff --git a/Classes/Domain/Model/Product/StockTrait.php b/Classes/Domain/Model/Product/StockTrait.php index ffae62dc..b2e7c44f 100644 --- a/Classes/Domain/Model/Product/StockTrait.php +++ b/Classes/Domain/Model/Product/StockTrait.php @@ -11,7 +11,7 @@ * LICENSE file that was distributed with this source code. */ -trait StockTrait +trait StockTrait // @phpstan-ignore trait.unused (provided for product extensions) { protected bool $handleStock = false; diff --git a/Classes/Domain/Model/Product/TagTrait.php b/Classes/Domain/Model/Product/TagTrait.php index 23e238d3..22301e13 100644 --- a/Classes/Domain/Model/Product/TagTrait.php +++ b/Classes/Domain/Model/Product/TagTrait.php @@ -14,7 +14,7 @@ use Extcode\Cart\Domain\Model\Tag; use TYPO3\CMS\Extbase\Persistence\ObjectStorage; -trait TagTrait +trait TagTrait // @phpstan-ignore trait.unused (provided for product extensions) { /** * @var ObjectStorage diff --git a/Classes/EventListener/Order/Create/Number.php b/Classes/EventListener/Order/Create/Number.php index ba1727c4..0d4a7cb2 100644 --- a/Classes/EventListener/Order/Create/Number.php +++ b/Classes/EventListener/Order/Create/Number.php @@ -19,25 +19,11 @@ abstract class Number { - protected PersistenceManager $persistenceManager; - - protected OrderItemRepository $orderItemRepository; - - protected array $options; - abstract protected function getRegistryName(NumberGeneratorEventInterface $event): string; abstract public function __invoke(NumberGeneratorEventInterface $event): void; - public function __construct( - PersistenceManager $persistenceManager, - OrderItemRepository $orderItemRepository, - array $options = [] - ) { - $this->persistenceManager = $persistenceManager; - $this->orderItemRepository = $orderItemRepository; - $this->options = $options; - } + public function __construct(protected PersistenceManager $persistenceManager, protected OrderItemRepository $orderItemRepository, protected array $options = []) {} protected function generateNumber(NumberGeneratorEventInterface $event): string { diff --git a/Classes/EventListener/Order/Create/PersistOrder/Item.php b/Classes/EventListener/Order/Create/PersistOrder/Item.php index 7b245c32..b920f16f 100644 --- a/Classes/EventListener/Order/Create/PersistOrder/Item.php +++ b/Classes/EventListener/Order/Create/PersistOrder/Item.php @@ -17,7 +17,6 @@ use Extcode\Cart\Domain\Repository\Order\ShippingAddressRepository; use Extcode\Cart\Event\Order\PersistOrderEvent; use TYPO3\CMS\Core\Context\Context; -use TYPO3\CMS\Core\Context\UserAspect; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; @@ -27,7 +26,8 @@ public function __construct( private readonly PersistenceManager $persistenceManager, private readonly ItemRepository $itemRepository, private readonly BillingAddressRepository $billingAddressRepository, - private readonly ShippingAddressRepository $shippingAddressRepository + private readonly ShippingAddressRepository $shippingAddressRepository, + private readonly Context $context ) {} public function __invoke(PersistOrderEvent $event): void @@ -39,12 +39,9 @@ public function __invoke(PersistOrderEvent $event): void $orderItem->setPid($storagePid); - $userAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user'); + $userAspect = $this->context->getAspect('frontend.user'); - if ( - $userAspect instanceof UserAspect - && $userAspect->isLoggedIn() - ) { + if ($userAspect->isLoggedIn()) { $frontendUserRepository = GeneralUtility::makeInstance( FrontendUserRepository::class ); diff --git a/Classes/EventListener/Order/Finish/Email.php b/Classes/EventListener/Order/Finish/Email.php index e8dcc94b..48878104 100644 --- a/Classes/EventListener/Order/Finish/Email.php +++ b/Classes/EventListener/Order/Finish/Email.php @@ -34,13 +34,13 @@ public function __invoke(EventInterface $event): void if ( method_exists($paymentMethod, 'isBuyerEmailDisabled') === false - || (method_exists($paymentMethod, 'isBuyerEmailDisabled') && $paymentMethod->isBuyerEmailDisabled() === false) + || $paymentMethod->isBuyerEmailDisabled() === false ) { $this->sendBuyerMail($orderItem, $event->getCart()); } if ( method_exists($paymentMethod, 'isSellerEmailDisabled') === false - || (method_exists($paymentMethod, 'isSellerEmailDisabled') && $paymentMethod->isSellerEmailDisabled() === false) + || $paymentMethod->isSellerEmailDisabled() === false ) { $this->sendSellerMail($orderItem, $event->getCart()); } diff --git a/Classes/EventListener/Template/Components/ModifyButtonBar.php b/Classes/EventListener/Template/Components/ModifyButtonBar.php index ed6b3dad..b9f3a853 100644 --- a/Classes/EventListener/Template/Components/ModifyButtonBar.php +++ b/Classes/EventListener/Template/Components/ModifyButtonBar.php @@ -31,7 +31,7 @@ public function __invoke(ModifyButtonBarEvent $event): void } } - private function modifyListActionButtons(ModifyButtonBarEvent $event) + private function modifyListActionButtons(ModifyButtonBarEvent $event): void { $event->setButtons( array_merge( @@ -51,7 +51,7 @@ private function modifyListActionButtons(ModifyButtonBarEvent $event) ); } - private function modifyShowActionButtons(ModifyButtonBarEvent $event) + private function modifyShowActionButtons(ModifyButtonBarEvent $event): void { $event->setButtons( array_merge( diff --git a/Classes/Hooks/ItemsProcFunc.php b/Classes/Hooks/ItemsProcFunc.php index 139bbdaa..b22e3de8 100644 --- a/Classes/Hooks/ItemsProcFunc.php +++ b/Classes/Hooks/ItemsProcFunc.php @@ -18,7 +18,7 @@ class ItemsProcFunc { protected TemplateLayout $templateLayoutsUtility; - public function __construct() + public function __construct(private readonly ResourceFactory $resourceFactory, private readonly CacheManager $cacheManager) { $this->templateLayoutsUtility = GeneralUtility::makeInstance(TemplateLayout::class); } diff --git a/Classes/Service/TaxClassService.php b/Classes/Service/TaxClassService.php index a1615a45..65ff9000 100644 --- a/Classes/Service/TaxClassService.php +++ b/Classes/Service/TaxClassService.php @@ -39,8 +39,7 @@ public function getTaxClasses(?string $countryCode = null): array $taxClassSettings = $this->settings['taxClasses']; if ( - is_null($countryCode) === false - && array_key_exists($countryCode, $taxClassSettings) + array_key_exists($countryCode, $taxClassSettings) && is_array($taxClassSettings[$countryCode]) ) { $taxClassSettings = $taxClassSettings[$countryCode]; diff --git a/Classes/Updates/ExtcodeCartCTypeMigration.php b/Classes/Updates/ExtcodeCartCTypeMigration.php new file mode 100644 index 00000000..a3f87052 --- /dev/null +++ b/Classes/Updates/ExtcodeCartCTypeMigration.php @@ -0,0 +1,41 @@ + 'pi_plugin1', + * 'pi_plugin2' => 'new_content_element', + * ] + * + * @return array + */ + protected function getListTypeToCTypeMapping(): array + { + return [ + // TODO: Add this mapping yourself! + ]; + } +} diff --git a/Classes/Updates/ListTypeToCTypeUpdate.php b/Classes/Updates/ListTypeToCTypeUpdate.php index 2f046f3a..9c6e24bc 100644 --- a/Classes/Updates/ListTypeToCTypeUpdate.php +++ b/Classes/Updates/ListTypeToCTypeUpdate.php @@ -2,8 +2,8 @@ namespace Extcode\Cart\Updates; -use TYPO3\CMS\Install\Attribute\UpgradeWizard; -use TYPO3\CMS\Install\Updates\AbstractListTypeToCTypeUpdate; +use TYPO3\CMS\Core\Attribute\UpgradeWizard; +use TYPO3\CMS\Core\Upgrades\AbstractListTypeToCTypeUpdate; /* * This file is part of the package extcode/cart. diff --git a/Classes/Utility/CartUtility.php b/Classes/Utility/CartUtility.php index a9881f6e..eace7e31 100644 --- a/Classes/Utility/CartUtility.php +++ b/Classes/Utility/CartUtility.php @@ -87,7 +87,7 @@ public function getNewCart(array $configurations): Cart } if (!isset($currency) || !is_array($currency) || !isset($currency['code']) || !isset($currency['sign']) || !isset($currency['translation'])) { - throw new \InvalidArgumentException('Add propper currency TypoScript configuration.'); + throw new \InvalidArgumentException('Add propper currency TypoScript configuration.', 5910386141); } // TODO: Throw exception if no currency setting is available or make an default because creating a new cart need diff --git a/Classes/ViewHelpers/IncludeFileViewHelper.php b/Classes/ViewHelpers/IncludeFileViewHelper.php index 3b83421f..e4343621 100644 --- a/Classes/ViewHelpers/IncludeFileViewHelper.php +++ b/Classes/ViewHelpers/IncludeFileViewHelper.php @@ -21,6 +21,7 @@ class IncludeFileViewHelper extends AbstractViewHelper { + public function __construct(private readonly PageRenderer $pageRenderer, private readonly TimeTracker $timeTracker) {} public function initializeArguments(): void { parent::initializeArguments(); @@ -48,7 +49,7 @@ public function render(): void $path = $this->arguments['path']; $compress = $this->arguments['compress']; - $pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); + $pageRenderer = $this->pageRenderer; if (ApplicationType::fromRequest($GLOBALS['TYPO3_REQUEST'])->isFrontend()) { try { $path = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize((string)$path); @@ -57,7 +58,7 @@ public function render(): void } catch (InvalidPathException|FileDoesNotExistException|InvalidFileException $e) { $path = null; if ($GLOBALS['TSFE']->tmpl->tt_track) { - GeneralUtility::makeInstance(TimeTracker::class)->setTSlogMessage($e->getMessage(), 3); + $this->timeTracker->setTSlogMessage($e->getMessage(), 3); } } } diff --git a/Classes/ViewHelpers/MetaTagViewHelper.php b/Classes/ViewHelpers/MetaTagViewHelper.php index 01c91e6e..690362a3 100644 --- a/Classes/ViewHelpers/MetaTagViewHelper.php +++ b/Classes/ViewHelpers/MetaTagViewHelper.php @@ -10,7 +10,6 @@ */ use TYPO3\CMS\Core\MetaTag\MetaTagManagerRegistry; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; /** @@ -27,6 +26,7 @@ class MetaTagViewHelper extends AbstractViewHelper { protected string $tagName = 'meta'; + public function __construct(private readonly MetaTagManagerRegistry $metaTagManagerRegistry) {} public function initializeArguments(): void { @@ -46,7 +46,7 @@ public function initializeArguments(): void public function render(): void { - $metaTagManager = GeneralUtility::makeInstance(MetaTagManagerRegistry::class) + $metaTagManager = $this->metaTagManagerRegistry ->getManagerForProperty($this->arguments['property']); $metaTagManager->addProperty( $this->arguments['property'], diff --git a/Classes/ViewHelpers/TitleTagViewHelper.php b/Classes/ViewHelpers/TitleTagViewHelper.php index a4f56815..678e742b 100644 --- a/Classes/ViewHelpers/TitleTagViewHelper.php +++ b/Classes/ViewHelpers/TitleTagViewHelper.php @@ -13,28 +13,21 @@ use Extcode\Cart\PageTitle\PageTitleProvider; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** * ViewHelper to render the page title */ class TitleTagViewHelper extends AbstractViewHelper { - use CompileWithRenderStatic; - public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('pageTitle', 'String', 'The page title'); } - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ): void { + public function render(): void + { $pageTitle = $arguments['pageTitle'] ?? ''; if ($pageTitle !== '') { GeneralUtility::makeInstance(PageTitleProvider::class)->setTitle($pageTitle); diff --git a/Classes/Widgets/PaymentPaidShippingOpen.php b/Classes/Widgets/PaymentPaidShippingOpen.php index 81990dc1..5821795e 100644 --- a/Classes/Widgets/PaymentPaidShippingOpen.php +++ b/Classes/Widgets/PaymentPaidShippingOpen.php @@ -17,12 +17,11 @@ use TYPO3\CMS\Dashboard\Widgets\RequestAwareWidgetInterface; use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface; use TYPO3\CMS\Dashboard\Widgets\WidgetInterface; -use TYPO3\CMS\Fluid\View\StandaloneView; class PaymentPaidShippingOpen implements WidgetInterface, RequestAwareWidgetInterface { private ServerRequestInterface $request; - private StandaloneView|ViewInterface $view; + private ViewInterface $view; public function __construct( private readonly WidgetConfigurationInterface $configuration, diff --git a/Classes/Widgets/Provider/OrdersPerDayProvider.php b/Classes/Widgets/Provider/OrdersPerDayProvider.php index d810e81f..553277b9 100644 --- a/Classes/Widgets/Provider/OrdersPerDayProvider.php +++ b/Classes/Widgets/Provider/OrdersPerDayProvider.php @@ -113,11 +113,8 @@ public function getOrderItemsInPeriod(int $start, int $end): int $this->queryBuilder ->count('*') - ->from('tx_cart_domain_model_order_item'); - - if ($constraints !== []) { - $this->queryBuilder->where(... $constraints); - } + ->from('tx_cart_domain_model_order_item') + ->where(... $constraints); return $this->queryBuilder->executeQuery()->fetchOne(); } diff --git a/Classes/Widgets/Provider/TurnoverPerDayProvider.php b/Classes/Widgets/Provider/TurnoverPerDayProvider.php index 9b69ae34..86ee2d9c 100644 --- a/Classes/Widgets/Provider/TurnoverPerDayProvider.php +++ b/Classes/Widgets/Provider/TurnoverPerDayProvider.php @@ -95,11 +95,8 @@ public function getOrderItemsInPeriod(int $start, int $end): float ->selectLiteral( $this->queryBuilder->expr()->sum('tx_cart_domain_model_order_item.' . $this->options['sum'], 'turnover') ) - ->from('tx_cart_domain_model_order_item'); - - if ($constraints !== []) { - $this->queryBuilder->where(... $constraints); - } + ->from('tx_cart_domain_model_order_item') + ->where(... $constraints); return $this->queryBuilder->executeQuery()->fetchOne() ?? 0; } diff --git a/Configuration/Icons.php b/Configuration/Icons.php index 5a0afe74..47ff99a3 100644 --- a/Configuration/Icons.php +++ b/Configuration/Icons.php @@ -1,28 +1,30 @@ [ - 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'provider' => SvgIconProvider::class, 'source' => 'EXT:cart/Resources/Public/Icons/apps_pagetree_folder_cart_coupons.svg', ], 'apps-pagetree-folder-cart-orders' => [ - 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'provider' => SvgIconProvider::class, 'source' => 'EXT:cart/Resources/Public/Icons/apps_pagetree_folder_cart_orders.svg', ], 'apps-pagetree-page-cart-cart' => [ - 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'provider' => SvgIconProvider::class, 'source' => 'EXT:cart/Resources/Public/Icons/apps_pagetree_page_cart_cart.svg', ], 'ext-cart-wizard-icon' => [ - 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'provider' => SvgIconProvider::class, 'source' => 'EXT:cart/Resources/Public/Icons/cart_plugin_wizard.svg', ], 'ext-cart-module' => [ - 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'provider' => SvgIconProvider::class, 'source' => 'EXT:cart/Resources/Public/Icons/module.svg', ], 'ext-cart-module-order' => [ - 'provider' => \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + 'provider' => SvgIconProvider::class, 'source' => 'EXT:cart/Resources/Public/Icons/module_orders.svg', ], ]; diff --git a/Configuration/TCA/Overrides/tt_content.php b/Configuration/TCA/Overrides/tt_content.php index cbb8484d..358d7d55 100644 --- a/Configuration/TCA/Overrides/tt_content.php +++ b/Configuration/TCA/Overrides/tt_content.php @@ -40,8 +40,9 @@ $GLOBALS['TCA']['tt_content']['types'][$pluginSignature]['showitem'] = 'pi_flexform'; ExtensionManagementUtility::addPiFlexFormValue( - $pluginSignature, - 'FILE:' . $flexFormPath + '*', + 'FILE:' . $flexFormPath, + $pluginSignature ); } } diff --git a/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php b/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php index 2f971431..1a6a277d 100644 --- a/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php +++ b/Tests/Functional/EventListener/Mail/AttachmentFromTypoScriptTest.php @@ -80,7 +80,7 @@ public function filesFromTypoScriptAddedToAttachmentList(): void $attachments = $attachmentEvent->getAttachments(); - self::assertSame(2, count($attachments)); + self::assertCount(2, $attachments); self::assertContains(GeneralUtility::getFileAbsFileName('EXT:cart_example/Resources/Public/Files/Extension.pdf'), $attachments); self::assertContains(GeneralUtility::getFileAbsFileName('EXT:cart_example/Resources/Public/Icons/Extension.svg'), $attachments); } diff --git a/Tests/Unit/Domain/Model/Cart/CartTest.php b/Tests/Unit/Domain/Model/Cart/CartTest.php index eccb7fdd..cd733845 100644 --- a/Tests/Unit/Domain/Model/Cart/CartTest.php +++ b/Tests/Unit/Domain/Model/Cart/CartTest.php @@ -60,15 +60,6 @@ public function setUp(): void public function tearDown(): void { - unset($this->grossCart); - unset($this->netCart); - - unset($this->taxClasses); - - unset($this->normalTaxClass); - unset($this->reducedTaxClass); - unset($this->freeTaxClass); - parent::tearDown(); } diff --git a/Tests/Unit/Domain/Model/Cart/ProductTest.php b/Tests/Unit/Domain/Model/Cart/ProductTest.php index c8edf292..7bdaa0b8 100644 --- a/Tests/Unit/Domain/Model/Cart/ProductTest.php +++ b/Tests/Unit/Domain/Model/Cart/ProductTest.php @@ -69,17 +69,6 @@ public function setUp(): void public function tearDown(): void { - unset( - $this->product, - $this->productType, - $this->productId, - $this->title, - $this->sku, - $this->price, - $this->quantity, - $this->taxClass - ); - parent::tearDown(); } diff --git a/Tests/Unit/Domain/Model/Cart/TaxClassTest.php b/Tests/Unit/Domain/Model/Cart/TaxClassTest.php index 2d646eef..0626becd 100644 --- a/Tests/Unit/Domain/Model/Cart/TaxClassTest.php +++ b/Tests/Unit/Domain/Model/Cart/TaxClassTest.php @@ -46,14 +46,6 @@ public function setUp(): void public function tearDown(): void { - unset( - $this->id, - $this->value, - $this->calc, - $this->title, - $this->fixture - ); - parent::tearDown(); } diff --git a/Tests/Unit/Service/TaxClassServiceTest.php b/Tests/Unit/Service/TaxClassServiceTest.php index 80996f99..c99c82fe 100644 --- a/Tests/Unit/Service/TaxClassServiceTest.php +++ b/Tests/Unit/Service/TaxClassServiceTest.php @@ -48,16 +48,14 @@ public function parsingTaxClassesFromTypoScriptWithoutCountryCodeReturnsDirectly $taxClasses = $this->createSubject($settings)->getTaxClasses($countryCode); - self::assertIsArray( - $taxClasses - ); - self::assertEquals( 3, count($taxClasses) ); $firstTaxClasses = $taxClasses[1]; + + // @phpstan-ignore-next-line staticMethod.alreadyNarrowedType self::assertInstanceOf( TaxClass::class, $firstTaxClasses @@ -115,16 +113,14 @@ public function parsingTaxClassesFromTypoScriptWithCountryCodeReturnsCountrySpec $taxClasses = $this->createSubject($settings)->getTaxClasses($countryCode); - self::assertIsArray( - $taxClasses - ); - self::assertEquals( 3, count($taxClasses) ); $firstTaxClasses = $taxClasses[1]; + + // @phpstan-ignore-next-line staticMethod.alreadyNarrowedType self::assertInstanceOf( TaxClass::class, $firstTaxClasses @@ -199,16 +195,14 @@ public function parsingTaxClassesFromTypoScriptWithNotConfiguredCountryCodeRetur $taxClasses = $this->createSubject($settings)->getTaxClasses($countryCode); - self::assertIsArray( - $taxClasses - ); - self::assertEquals( 3, count($taxClasses) ); $firstTaxClasses = $taxClasses[1]; + + // @phpstan-ignore-next-line staticMethod.alreadyNarrowedType self::assertInstanceOf( TaxClass::class, $firstTaxClasses diff --git a/composer.json b/composer.json index 6e30a450..b8936744 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,8 @@ "allow-plugins": { "typo3/class-alias-loader": true, "typo3/cms-composer-installers": true, - "sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true + "sbuerk/typo3-cmscomposerinstallers-testingframework-bridge": true, + "phpstan/extension-installer": true } }, "extra": { @@ -51,19 +52,26 @@ "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "ext-json": "*", "ext-openssl": "*", - "typo3/cms-core": "^13.4", - "typo3/cms-extbase": "^13.4", - "typo3/cms-fluid": "^13.4" + "typo3/cms-core": "14.2.x-dev", + "typo3/cms-extbase": "14.2.x-dev", + "typo3/cms-fluid": "14.2.x-dev", + "typo3/cms-form": "14.2.x-dev", + "typo3/cms-frontend": "14.2.x-dev" }, "require-dev": { - "codappix/typo3-php-datasets": "^2.0", + "codappix/typo3-php-datasets": "^2.1", "friendsofphp/php-cs-fixer": "^3.64", - "phpstan/phpstan": "^1.12", - "ssch/typo3-rector": "^2.9", - "typo3/cms-beuser": "^13.4", - "typo3/cms-dashboard": "^13.4", - "typo3/cms-form": "^13.4", - "typo3/testing-framework": "^8.2" + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "spaze/phpstan-disallowed-calls": "^4.7", + "staabm/phpstan-todo-by": "^0.3", + "typo3/cms-beuser": "14.2.x-dev", + "typo3/cms-dashboard": "14.2.x-dev", + "typo3/cms-form": "14.2.x-dev", + "typo3/testing-framework": "^9.0", + "ssch/typo3-rector": "^3.11" }, "scripts": { "test:cgl": [ @@ -107,7 +115,8 @@ ] }, "suggest": { - "typo3/cms-dashboard": "^13.4", - "typo3/cms-form": "^13.4" - } + "typo3/cms-dashboard": "14.2.x-dev", + "typo3/cms-form": "14.2.x-dev" + }, + "minimum-stability": "dev" } diff --git a/ext_localconf.php b/ext_localconf.php index 24086288..3d5add58 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -25,8 +25,7 @@ [ CartPreviewController::class => 'show', CurrencyController::class => 'update', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ] ); ExtensionUtility::configurePlugin( @@ -51,8 +50,7 @@ PaymentController::class => 'update', ProductController::class => 'add, remove', ShippingController::class => 'update', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ] ); ExtensionUtility::configurePlugin( @@ -63,8 +61,7 @@ ], [ CurrencyController::class => 'edit, update', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ] ); ExtensionUtility::configurePlugin( @@ -75,8 +72,7 @@ ], [ \Extcode\Cart\Controller\Order\OrderController::class => 'list, show', - ], - ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT + ] ); // register "cart:" namespace diff --git a/rector.php b/rector.php index 2c72b1d6..feb85ce7 100644 --- a/rector.php +++ b/rector.php @@ -29,7 +29,7 @@ ->withSets([ Typo3SetList::CODE_QUALITY, Typo3SetList::GENERAL, - Typo3LevelSetList::UP_TO_TYPO3_13, + Typo3LevelSetList::UP_TO_TYPO3_14, ]) // To have a better analysis from PHPStan, we teach it here some more things ->withPHPStanConfigs([