Skip to content

Commit

Permalink
[TASK] Raise phpstan level to 4, fix a finding
Browse files Browse the repository at this point in the history
  • Loading branch information
extcode committed Oct 16, 2024
1 parent 7964f81 commit 2509493
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Build/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
includes:
- phpstan-baseline.neon
parameters:
level: 3
level: 4
paths:
- ../Classes
- ../Configuration
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/Backend/ActionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected function initializeAction(): void
ConfigurationManager::CONFIGURATION_TYPE_FRAMEWORK
);

$pageId = (int)$this->request->getQueryParams()['id'] ?? 1;
$pageId = (int)($this->request->getQueryParams()['id'] ?? 1);

BackendUtility::readPageAccess(
$pageId,
Expand Down
1 change: 0 additions & 1 deletion Classes/Controller/Cart/CartController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public function showAction(

$currentStepHasError = false;
if ($extbaseAttribute instanceof ExtbaseRequestParameters
&& $extbaseAttribute->getOriginalRequestMappingResults()
&& $extbaseAttribute->getOriginalRequestMappingResults()->hasErrors()
) {
$currentStepHasError = true;
Expand Down
4 changes: 0 additions & 4 deletions Classes/Domain/Model/Cart/BeVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@
* LICENSE file that was distributed with this source code.
*/

use Psr\EventDispatcher\EventDispatcherInterface;

class BeVariant
{
private ?EventDispatcherInterface $eventDispatcher = null;

protected ?Product $product = null;

protected ?BeVariant $parentBeVariant = null;
Expand Down
10 changes: 3 additions & 7 deletions Classes/Domain/Model/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ public function addCoupon(CartCouponInterface $coupon): int

public function removeCoupon(string $couponCode): int
{
if (!$this->coupons[$couponCode]) {
if (!isset($this->coupons[$couponCode])) {
return -1;
}

Expand Down Expand Up @@ -715,7 +715,7 @@ public function changeProductsQuantity(array $productQuantityArray): void
foreach ($productQuantityArray as $productPuid => $quantity) {
$product = $this->products[$productPuid];

if ($product) {
if ($product instanceof Product) {
if (is_array($quantity)) {
$this->subCount($product->getQuantity());
$this->subGross($product->getGross());
Expand Down Expand Up @@ -760,11 +760,7 @@ public function removeProductByIds(array $products): bool
}

$product = $this->products[$productId];
if ($product) {
$this->removeProduct($product, $products[$productId]);
} else {
return false;
}
$this->removeProduct($product, $products[$productId]);

$this->updateServiceAttributes();

Expand Down
4 changes: 0 additions & 4 deletions Tests/Unit/Domain/Model/Cart/BeVariantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,6 @@ protected function getAccessibleMock(
bool $callOriginalClone = true,
bool $callAutoload = true
) {
if ($originalClassName === '') {
throw new \InvalidArgumentException('$originalClassName must not be empty.', 1334701880);
}

$mockBuilder = $this->getMockBuilder($this->buildAccessibleProxy($originalClassName))
->onlyMethods($methods)
->setConstructorArgs($arguments)
Expand Down
4 changes: 0 additions & 4 deletions Tests/Unit/Domain/Model/Order/AbstractAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,6 @@ protected function getAccessibleMock(
bool $callOriginalClone = true,
bool $callAutoload = true
): MockObject {
if ($originalClassName === '') {
throw new \InvalidArgumentException('$originalClassName must not be empty.', 1334701880);
}

$mockBuilder = $this->getMockBuilder($this->buildAccessibleProxy($originalClassName))
->addMethods($methods)
->setConstructorArgs($arguments)
Expand Down

0 comments on commit 2509493

Please sign in to comment.