From a1fcbe25d2e8a7cfa2177d8e8ba80a5177d739bc Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Wed, 5 Aug 2026 09:21:07 +0200 Subject: [PATCH 1/3] [TASK] Make properties of Event private and add explicit getter-methods --- Classes/Event/Document/GenerateDocumentEvent.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Classes/Event/Document/GenerateDocumentEvent.php b/Classes/Event/Document/GenerateDocumentEvent.php index b542071f..c2d52f77 100644 --- a/Classes/Event/Document/GenerateDocumentEvent.php +++ b/Classes/Event/Document/GenerateDocumentEvent.php @@ -11,11 +11,23 @@ * LICENSE file that was distributed with this source code. */ -use Extcode\Cart\Domain\Model\Order\Item; +use Extcode\Cart\Domain\Model\Order\Item as OrderItem; final readonly class GenerateDocumentEvent { - public function __construct(public Item $orderItem, public string $pdfType) + public function __construct( + private OrderItem $orderItem, + private string $type + ) { + } + + public function getOrderItem(): OrderItem + { + return $this->orderItem; + } + + public function getType(): string { + return $this->type; } } From c1a8ae2395d9602c0fabd692d38fca4f30576969 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Wed, 5 Aug 2026 09:24:18 +0200 Subject: [PATCH 2/3] [TASK] Make new event stoppable --- .../Event/Document/GenerateDocumentEvent.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Classes/Event/Document/GenerateDocumentEvent.php b/Classes/Event/Document/GenerateDocumentEvent.php index c2d52f77..8b38eca4 100644 --- a/Classes/Event/Document/GenerateDocumentEvent.php +++ b/Classes/Event/Document/GenerateDocumentEvent.php @@ -12,12 +12,15 @@ */ use Extcode\Cart\Domain\Model\Order\Item as OrderItem; +use Psr\EventDispatcher\StoppableEventInterface; -final readonly class GenerateDocumentEvent +final class GenerateDocumentEvent implements StoppableEventInterface { + private bool $isPropagationStopped = false; + public function __construct( - private OrderItem $orderItem, - private string $type + private readonly OrderItem $orderItem, + private readonly string $type ) { } @@ -30,4 +33,14 @@ public function getType(): string { return $this->type; } + + public function setPropagationStopped(bool $isPropagationStopped): void + { + $this->isPropagationStopped = $isPropagationStopped; + } + + public function isPropagationStopped(): bool + { + return $this->isPropagationStopped; + } } From dd406b50fe215cc1cf794731b70964e92a1fb6d4 Mon Sep 17 00:00:00 2001 From: Daniel Gohlke Date: Wed, 5 Aug 2026 09:48:28 +0200 Subject: [PATCH 3/3] [BUGFIX] Update phpstan baseline and fix expectExceptionMessage --- Build/phpstan-baseline.neon | 36 ++----------------- .../Command/OrderItemCleanupCommandTest.php | 5 +-- Tests/Unit/Domain/Model/Cart/CartTest.php | 26 ++++++-------- 3 files changed, 16 insertions(+), 51 deletions(-) diff --git a/Build/phpstan-baseline.neon b/Build/phpstan-baseline.neon index 626acd8d..57d6090f 100644 --- a/Build/phpstan-baseline.neon +++ b/Build/phpstan-baseline.neon @@ -126,18 +126,6 @@ parameters: count: 1 path: ../Classes/Configuration/Loader/TypoScript/SpecialOptionsLoader.php - - - message: '#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\.$#' - identifier: foreach.nonIterable - count: 1 - path: ../Classes/Configuration/Loader/TypoScript/TaxClassLoader.php - - - - message: '#^Parameter \#1 \$taxClassKey of method Extcode\\Cart\\Domain\\Model\\Cart\\TaxClassFactoryInterface\:\:getTaxClass\(\) expects int, mixed given\.$#' - identifier: argument.type - count: 1 - path: ../Classes/Configuration/Loader/TypoScript/TaxClassLoader.php - - message: '#^Parameter \#2 \$array of function array_key_exists expects array, mixed given\.$#' identifier: argument.type @@ -150,12 +138,6 @@ parameters: count: 1 path: ../Classes/Configuration/Loader/TypoScript/TaxClassLoader.php - - - message: '#^Possibly invalid array key type mixed\.$#' - identifier: offsetAccess.invalidOffset - count: 1 - path: ../Classes/Configuration/Loader/TypoScript/TaxClassLoader.php - - message: '#^Property Extcode\\Cart\\Configuration\\Loader\\TypoScript\\TaxClassLoader\:\:\$settings type has no value type specified in iterable type array\.$#' identifier: missingType.iterableValue @@ -397,7 +379,7 @@ parameters: path: ../Classes/Controller/Backend/Order/OrderController.php - - message: '#^Parameter \#1 \$queryResult of class TYPO3\\CMS\\Extbase\\Pagination\\QueryResultPaginator constructor expects TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface, array\|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface given\.$#' + message: '#^Parameter \#1 \$queryResult of class TYPO3\\CMS\\Extbase\\Pagination\\QueryResultPaginator constructor expects TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface, array\|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface\ given\.$#' identifier: argument.type count: 1 path: ../Classes/Controller/Backend/Order/OrderController.php @@ -2395,17 +2377,11 @@ parameters: path: ../Classes/Domain/Repository/Order/ItemRepository.php - - message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ItemRepository\:\:findAll\(\) return type has no value type specified in iterable type array\|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface\.$#' + message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ItemRepository\:\:findAll\(\) return type has no value type specified in iterable type array\|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface\\.$#' identifier: missingType.iterableValue count: 1 path: ../Classes/Domain/Repository/Order/ItemRepository.php - - - message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ItemRepository\:\:findAll\(\) return type with generic interface TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface does not specify its types\: TKey, TValue$#' - identifier: missingType.generics - count: 1 - path: ../Classes/Domain/Repository/Order/ItemRepository.php - - message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ItemRepository\:\:getFilterConstraints\(\) has parameter \$query with generic interface TYPO3\\CMS\\Extbase\\Persistence\\QueryInterface but does not specify its types\: T$#' identifier: missingType.generics @@ -2491,17 +2467,11 @@ parameters: path: ../Classes/Domain/Repository/Order/ProductRepository.php - - message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ProductRepository\:\:findAll\(\) return type has no value type specified in iterable type array\|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface\.$#' + message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ProductRepository\:\:findAll\(\) return type has no value type specified in iterable type array\|TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface\\.$#' identifier: missingType.iterableValue count: 1 path: ../Classes/Domain/Repository/Order/ProductRepository.php - - - message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ProductRepository\:\:findAll\(\) return type with generic interface TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface does not specify its types\: TKey, TValue$#' - identifier: missingType.generics - count: 1 - path: ../Classes/Domain/Repository/Order/ProductRepository.php - - message: '#^Method Extcode\\Cart\\Domain\\Repository\\Order\\ProductRepository\:\:getFilterConstraints\(\) has parameter \$query with generic interface TYPO3\\CMS\\Extbase\\Persistence\\QueryInterface but does not specify its types\: T$#' identifier: missingType.generics diff --git a/Tests/Functional/Command/OrderItemCleanupCommandTest.php b/Tests/Functional/Command/OrderItemCleanupCommandTest.php index 75db2c9c..a55f0dde 100644 --- a/Tests/Functional/Command/OrderItemCleanupCommandTest.php +++ b/Tests/Functional/Command/OrderItemCleanupCommandTest.php @@ -298,8 +298,9 @@ public function doesNotDeletesNotRelatedRecordsCreatedBeforeCutOffDate(): void #[Test] public function noCutOffDateTerminatesTheCommandWithErrorMessage(): void { - $this->expectException(RuntimeException::class); - $this->expectExceptionMessage('Not enough arguments (missing: "cutOffDate").'); + $this->expectExceptionObject( + new RuntimeException('Not enough arguments (missing: "cutOffDate").') + ); $commandTester = new CommandTester($this->get(OrderItemCleanupCommand::class)); $commandTester->execute([]); diff --git a/Tests/Unit/Domain/Model/Cart/CartTest.php b/Tests/Unit/Domain/Model/Cart/CartTest.php index abf8421e..04b1ca0c 100644 --- a/Tests/Unit/Domain/Model/Cart/CartTest.php +++ b/Tests/Unit/Domain/Model/Cart/CartTest.php @@ -258,14 +258,11 @@ public function resetDifferentOrderNumberThrowsException(): void { $this->grossCart->setOrderNumber('ValidOrderNumber'); - $this->expectException( - LogicException::class - ); - $this->expectExceptionMessage( - 'You can not redeclare the order number of your cart.' - ); - $this->expectExceptionCode( - 1413969668 + $this->expectExceptionObject( + new LogicException( + 'You can not redeclare the order number of your cart.', + 1413969668 + ) ); $this->grossCart->setOrderNumber('NotValidOrderNumber'); @@ -321,14 +318,11 @@ public function resetDifferentInvoiceNumberThrowsException(): void { $this->grossCart->setInvoiceNumber('ValidInvoiceNumber'); - $this->expectException( - LogicException::class - ); - $this->expectExceptionMessage( - 'You can not redeclare the invoice number of your cart.', - ); - $this->expectExceptionCode( - 1413969712 + $this->expectExceptionObject( + new LogicException( + 'You can not redeclare the invoice number of your cart.', + 1413969712 + ) ); $this->grossCart->setInvoiceNumber('NotValidInvoiceNumber');