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/Classes/Event/Document/GenerateDocumentEvent.php b/Classes/Event/Document/GenerateDocumentEvent.php index b542071f..8b38eca4 100644 --- a/Classes/Event/Document/GenerateDocumentEvent.php +++ b/Classes/Event/Document/GenerateDocumentEvent.php @@ -11,11 +11,36 @@ * 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; +use Psr\EventDispatcher\StoppableEventInterface; -final readonly class GenerateDocumentEvent +final class GenerateDocumentEvent implements StoppableEventInterface { - public function __construct(public Item $orderItem, public string $pdfType) + private bool $isPropagationStopped = false; + + public function __construct( + private readonly OrderItem $orderItem, + private readonly string $type + ) { + } + + public function getOrderItem(): OrderItem + { + return $this->orderItem; + } + + public function getType(): string + { + return $this->type; + } + + public function setPropagationStopped(bool $isPropagationStopped): void + { + $this->isPropagationStopped = $isPropagationStopped; + } + + public function isPropagationStopped(): bool { + return $this->isPropagationStopped; } } 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');