Skip to content

Commit

Permalink
rector fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
peteeveleigh committed Aug 21, 2024
1 parent de0df7a commit 70b1746
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/FosterCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ class FosterCheckout extends Plugin

public bool $hasCpSettings = false;

public function init()
public function init(): void
{
parent::init();

Craft::setAlias('@fostercheckout', __DIR__);

// Defer most setup tasks until Craft is fully initialized
Craft::$app->onInit(function () {
Craft::$app->onInit(function (): void {
$this->registerComponents();
$this->attachEventHandlers();
$this->registerCustomVariables();
Expand Down Expand Up @@ -83,7 +83,7 @@ private function attachEventHandlers(): void
Event::on(
CraftVariable::class,
CraftVariable::EVENT_INIT,
function (Event $e) {
function (Event $e): void {
/** @var CraftVariable $variable */
$variable = $e->sender;

Expand All @@ -96,7 +96,7 @@ function (Event $e) {
Event::on(
View::class,
View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS,
function (RegisterTemplateRootsEvent $event) {
function (RegisterTemplateRootsEvent $event): void {
$event->roots['foster-checkout'] = __DIR__ . '/templates';
}
);
Expand All @@ -105,7 +105,7 @@ function (RegisterTemplateRootsEvent $event) {
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_SITE_URL_RULES,
function (RegisterUrlRulesEvent $event) {
function (RegisterUrlRulesEvent $event): void {
// Get the paths from the settings
$paths = $this->checkout->paths();
$checkoutPath = $paths['checkout'] ?? 'checkout';
Expand Down
1 change: 1 addition & 0 deletions src/formatters/CheckoutAddressFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function format(AddressInterface $address, array $options = []): string
if (property_exists($address, 'firstName')) {
$address->firstName = null;
}

if (property_exists($address, 'lastName')) {
$address->lastName = null;
}
Expand Down
17 changes: 9 additions & 8 deletions src/services/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function note($page): ?string

$note = null;

if ($elementHandle and $fieldHandle) {
if ($elementHandle && $fieldHandle) {
$global = GlobalSet::find()->handle($elementHandle)->one() ?? null;
$entry = Entry::find()->section($elementHandle)->one() ?? null;
$element = $global ?? $entry;
Expand All @@ -79,7 +79,7 @@ public function note($page): ?string
} else {
$note = null;
}
} catch (InvalidFieldException $e) {
} catch (InvalidFieldException) {
$note = null;
}
}
Expand Down Expand Up @@ -130,13 +130,13 @@ public function lineItemImage(LineItem $lineItem): ?Asset
if ($fieldInfo['level'] === 'variant') {
try {
$image = $variant->getFieldValue($fieldInfo['handle'])->one();
} catch (InvalidFieldException $e) {
} catch (InvalidFieldException) {
$image = null;
}
} else {
try {
$image = $product->getFieldValue($fieldInfo['handle'])->one();
} catch (InvalidFieldException $e) {
} catch (InvalidFieldException) {
$image = null;
}
}
Expand All @@ -151,7 +151,7 @@ public function getCountries(): array
{
try {
return Plugin::getInstance()->getStore()->getStore()->getCountriesList();
} catch (InvalidConfigException $e) {
} catch (InvalidConfigException) {
return [];
}
}
Expand All @@ -163,7 +163,7 @@ public function getRegions(): array
{
try {
return Plugin::getInstance()->getStore()->getStore()->getAdministrativeAreasListByCountryCode();
} catch (InvalidConfigException $e) {
} catch (InvalidConfigException) {
return [];
}
}
Expand All @@ -175,7 +175,7 @@ public function getDiscounts(): array
{
try {
return Plugin::getInstance()->getDiscounts()->allDiscounts;
} catch (InvalidConfigException $e) {
} catch (InvalidConfigException) {
return [];
}
}
Expand All @@ -187,9 +187,10 @@ public function getGateways(): array
{
try {
$gateways = Plugin::getInstance()->gateways->getAllCustomerEnabledGateways();
} catch (InvalidConfigException $e) {
} catch (InvalidConfigException) {
$gateways = [];
}

$gatewaysArr = [];
foreach ($gateways as $gateway) {
$gatewaysArr[] = [
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/checkout/CheckoutAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class CheckoutAsset extends AssetBundle
{
public function init()
public function init(): void
{
$this->sourcePath = __DIR__ . '/dist';
$this->js = ['js/app.js'];
Expand Down

0 comments on commit 70b1746

Please sign in to comment.