From 1003bab0f9df066b969bbf64cc044999a3032a92 Mon Sep 17 00:00:00 2001 From: Luke Holder Date: Tue, 11 Jul 2023 21:01:08 +0800 Subject: [PATCH] Fix formatting and code style --- src/elements/Order.php | 10 ++++------ .../conditions/products/ProductTypeConditionRule.php | 12 +++++++----- src/elements/db/ProductQuery.php | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/elements/Order.php b/src/elements/Order.php index 6bb7511249..56061cdf25 100644 --- a/src/elements/Order.php +++ b/src/elements/Order.php @@ -47,8 +47,6 @@ use craft\commerce\records\Transaction as TransactionRecord; use craft\commerce\validators\StoreCountryValidator; use craft\db\Query; -use craft\elements\Address; -use craft\elements\Address as AddressElement; use craft\elements\Address as AddressElement; use craft\elements\User; use craft\errors\ElementNotFoundException; @@ -2873,7 +2871,7 @@ public function getAdjustmentsTotal(): float public function getShippingAddress(): ?AddressElement { if (!isset($this->_shippingAddress) && $this->shippingAddressId) { - /** @var Address|null $address */ + /** @var AddressElement|null $address */ $address = AddressElement::find()->ownerId($this->id)->id($this->shippingAddressId)->one(); $this->_shippingAddress = $address; } @@ -2932,7 +2930,7 @@ public function removeShippingAddress(): void public function getEstimatedShippingAddress(): ?AddressElement { if (!isset($this->_estimatedShippingAddress) && $this->estimatedShippingAddressId) { - /** @var Address|null $address */ + /** @var AddressElement|null $address */ $address = AddressElement::find()->owner($this)->id($this->estimatedShippingAddressId)->one(); $this->_estimatedShippingAddress = $address; } @@ -2967,7 +2965,7 @@ public function setEstimatedShippingAddress(AddressElement|array|null $address): public function getBillingAddress(): ?AddressElement { if (!isset($this->_billingAddress) && $this->billingAddressId) { - /** @var Address|null $address */ + /** @var AddressElement|null $address */ $address = AddressElement::find()->ownerId($this->id)->id($this->billingAddressId)->one(); $this->_billingAddress = $address; } @@ -3090,7 +3088,7 @@ public function hasMatchingAddresses(?array $attributes = null): bool public function getEstimatedBillingAddress(): ?AddressElement { if (!isset($this->_estimatedBillingAddress) && $this->estimatedBillingAddressId) { - /** @var Address|null $address */ + /** @var AddressElement|null $address */ $address = AddressElement::find()->owner($this)->id($this->estimatedBillingAddressId)->one(); $this->_estimatedBillingAddress = $address; } diff --git a/src/elements/conditions/products/ProductTypeConditionRule.php b/src/elements/conditions/products/ProductTypeConditionRule.php index 481fbf252f..3a15b5df75 100644 --- a/src/elements/conditions/products/ProductTypeConditionRule.php +++ b/src/elements/conditions/products/ProductTypeConditionRule.php @@ -41,7 +41,7 @@ public function getLabel(): string protected function options(): array { return collect(Plugin::getInstance()->getProductTypes()->getAllProductTypes()) - ->map(fn(ProductType $productType) => ['value' => $productType->uid , 'label' => $productType->name]) + ->map(fn(ProductType $productType) => ['value' => $productType->uid, 'label' => $productType->name]) ->all(); } @@ -58,13 +58,15 @@ public function getExclusiveQueryParams(): array */ public function modifyQuery(ElementQueryInterface $query): void { - /** @var ProductQuery $query */ $productTypes = Plugin::getInstance()->getProductTypes()->getAllProductTypes(); - /** @var ProductQuery $query */ - $query->type($this->paramValue(function(string $value) use ($productTypes) { + /** @var string[] $value */ + $value = $this->paramValue(function(string $value) use ($productTypes) { return ArrayHelper::firstWhere($productTypes, 'uid', $value)?->handle; - })); + }); + + /** @var ProductQuery $query */ + $query->type($value); } /** diff --git a/src/elements/db/ProductQuery.php b/src/elements/db/ProductQuery.php index 4062b03f45..22cdd69ca2 100644 --- a/src/elements/db/ProductQuery.php +++ b/src/elements/db/ProductQuery.php @@ -412,7 +412,7 @@ public function defaultSku(mixed $value): ProductQuery * ->all(); * ``` * - * @param string|string[]|ProductType|null $value The property value + * @param ProductType|string|null|array $value The property value * @return static self reference */ public function type(mixed $value): ProductQuery