Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jan 3, 2024
1 parent e5e3557 commit 0fb19a0
Show file tree
Hide file tree
Showing 22 changed files with 28 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/Cart/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function getShipping(): Shipping
/**
* Update the shipping address and driver.
*/
public function updateShipping(array $attributes = [], string $driver = null): void
public function updateShipping(array $attributes = [], ?string $driver = null): void
{
if (! is_null($driver)) {
$this->getShipping()->setAttribute('driver', $driver);
Expand Down
2 changes: 1 addition & 1 deletion src/Fields/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Items extends MorphMany
/**
* Create a new relation field instance.
*/
public function __construct(string $label = null, Closure|string $modelAttribute = null, Closure|string $relation = null)
public function __construct(?string $label = null, Closure|string|null $modelAttribute = null, Closure|string|null $relation = null)
{
parent::__construct($label ?: __('Products'), $modelAttribute ?: 'items', $relation);

Expand Down
2 changes: 1 addition & 1 deletion src/Fields/OrderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OrderStatus extends Select
/**
* Create a new field instance.
*/
public function __construct(string $label = null, Closure|string $modelAttribute = 'status')
public function __construct(?string $label = null, Closure|string $modelAttribute = 'status')
{
parent::__construct($label ?: __('Status'), $modelAttribute);

Expand Down
3 changes: 1 addition & 2 deletions src/Fields/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use Illuminate\Support\Number;
use Illuminate\Support\Str;

class Price extends Meta
{
Expand All @@ -19,7 +18,7 @@ class Price extends Meta
/**
* Create a new price field instance.
*/
public function __construct(string $label, string $currency = null)
public function __construct(string $label, ?string $currency = null)
{
$this->currency = $currency ?: Bazar::getCurrency();

Expand Down
3 changes: 1 addition & 2 deletions src/Fields/Transactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Cone\Root\Fields\URL;
use Illuminate\Http\Request;
use Illuminate\Support\Number as NumberFormatter;
use Illuminate\Support\Str;

class Transactions extends HasMany
{
Expand All @@ -28,7 +27,7 @@ class Transactions extends HasMany
/**
* Create a new relation field instance.
*/
public function __construct(string $label = null, Closure|string $modelAttribute = null, Closure|string $relation = null)
public function __construct(?string $label = null, Closure|string|null $modelAttribute = null, Closure|string|null $relation = null)
{
parent::__construct($label ?: __('Transactions'), $modelAttribute ?: 'transactions', $relation);

Expand Down
4 changes: 2 additions & 2 deletions src/Gateway/CashDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CashDriver extends Driver
/**
* Process the payment.
*/
public function pay(Order $order, float $amount = null, array $attributes = []): Transaction
public function pay(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
$transaction = parent::pay($order, $amount, array_merge($attributes, [
'completed_at' => time(),
Expand All @@ -31,7 +31,7 @@ public function pay(Order $order, float $amount = null, array $attributes = []):
/**
* Process the refund.
*/
public function refund(Order $order, float $amount = null, array $attributes = []): Transaction
public function refund(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
$transaction = parent::refund($order, $amount, array_merge($attributes, [
'completed_at' => time(),
Expand Down
4 changes: 2 additions & 2 deletions src/Gateway/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ abstract class Driver extends BaseDriver
/**
* Process the payment.
*/
public function pay(Order $order, float $amount = null, array $attributes = []): Transaction
public function pay(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
return $order->pay($amount, $this->name, $attributes);
}

/**
* Process the refund.
*/
public function refund(Order $order, float $amount = null, array $attributes = []): Transaction
public function refund(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
return $order->refund($amount, $this->name, $attributes);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gateway/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function getDefaultDriver(): string
/**
* Get the available drivers for the given model.
*/
public function getAvailableDrivers(Itemable $model = null): array
public function getAvailableDrivers(?Itemable $model = null): array
{
foreach (array_keys(array_diff_key($this->customCreators, parent::getDrivers())) as $key) {
if (! isset($this->drivers[$key])) {
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Gateway/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface Manager
/**
* Get the available drivers for the given model.
*/
public function getAvailableDrivers(Itemable $model = null): array;
public function getAvailableDrivers(?Itemable $model = null): array;
}
4 changes: 2 additions & 2 deletions src/Interfaces/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public function transactions(): HasMany;
*
* @return \Cone\Bazar\Models\Transaction
*/
public function pay(float $amount = null, string $driver = null, array $attributes = []): Transaction;
public function pay(?float $amount = null, ?string $driver = null, array $attributes = []): Transaction;

/**
* Create a refund transaction for the order.
*
* @return \Cone\Bazar\Models\Transaction
*/
public function refund(float $amount = null, string $driver = null, array $attributes = []): Transaction;
public function refund(?float $amount = null, ?string $driver = null, array $attributes = []): Transaction;

/**
* Get the total paid amount.
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function pending(): bool;
/**
* Mark the transaction as completed.
*/
public function markAsCompleted(DateTimeInterface $date = null): void;
public function markAsCompleted(?DateTimeInterface $date = null): void;

/**
* Mark the transaction as pending.
Expand Down
4 changes: 2 additions & 2 deletions src/Interfaces/Priceable.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ interface Priceable
/**
* Get the price by the given type and currency.
*/
public function getPrice(string $currency = null): ?float;
public function getPrice(?string $currency = null): ?float;

/**
* Get the formatted price by the given type and currency.
*/
public function getFormattedPrice(string $currency = null): ?string;
public function getFormattedPrice(?string $currency = null): ?string;

/**
* Determine if the stockable model is free.
Expand Down
2 changes: 1 addition & 1 deletion src/Interfaces/Shipping/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ interface Manager
/**
* Get the available drivers for the given model.
*/
public function getAvailableDrivers(Itemable $model = null): array;
public function getAvailableDrivers(?Itemable $model = null): array;
}
4 changes: 2 additions & 2 deletions src/Models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function uniqueIds(): array
/**
* Create a payment transaction for the order.
*/
public function pay(float $amount = null, string $driver = null, array $attributes = []): Transaction
public function pay(?float $amount = null, ?string $driver = null, array $attributes = []): Transaction
{
if (! $this->payable()) {
throw new TransactionFailedException("Order #{$this->getKey()} is fully paid.");
Expand All @@ -225,7 +225,7 @@ public function pay(float $amount = null, string $driver = null, array $attribut
/**
* Create a refund transaction for the order.
*/
public function refund(float $amount = null, string $driver = null, array $attributes = []): Transaction
public function refund(?float $amount = null, ?string $driver = null, array $attributes = []): Transaction
{
if (! $this->refundable()) {
throw new TransactionFailedException("Order #{$this->getKey()} is fully refunded.");
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Support\Number;
use Illuminate\Support\Str;
use Throwable;

class Shipping extends Model implements Contract
Expand Down Expand Up @@ -112,7 +111,7 @@ public function shippable(): MorphTo
protected function driver(): Attribute
{
return new Attribute(
get: static function (string $value = null): string {
get: static function (?string $value = null): string {
return $value ?: Manager::getDefaultDriver();
}
);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function pending(): bool
/**
* Mark the transaction as completed.
*/
public function markAsCompleted(DateTimeInterface $date = null): void
public function markAsCompleted(?DateTimeInterface $date = null): void
{
$date = $date ?: Date::now();

Expand Down
2 changes: 1 addition & 1 deletion src/Rules/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Option implements ValidationRule
*
* @return void
*/
public function __construct(Product $product, Variant $variant = null)
public function __construct(Product $product, ?Variant $variant = null)
{
$this->product = $product;
$this->variant = $variant;
Expand Down
2 changes: 1 addition & 1 deletion src/Shipping/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getDefaultDriver(): string
/**
* Get the available drivers for the given model.
*/
public function getAvailableDrivers(Itemable $model = null): array
public function getAvailableDrivers(?Itemable $model = null): array
{
foreach (array_keys(array_diff_key($this->customCreators, parent::getDrivers())) as $key) {
if (! isset($this->drivers[$key])) {
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/HasPrices.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function formattedPrice(): Attribute
/**
* Get the price by the given type and currency.
*/
public function getPrice(string $currency = null): ?float
public function getPrice(?string $currency = null): ?float
{
$currency ??= Bazar::getCurrency();

Expand All @@ -59,7 +59,7 @@ public function getPrice(string $currency = null): ?float
/**
* Get the formatted price by the given type and currency.
*/
public function getFormattedPrice(string $currency = null): ?string
public function getFormattedPrice(?string $currency = null): ?string
{
$currency ??= Bazar::getCurrency();

Expand Down
1 change: 0 additions & 1 deletion src/Traits/InteractsWithDiscounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Cone\Bazar\Support\Facades\Discount;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Support\Number;
use Illuminate\Support\Str;

trait InteractsWithDiscounts
{
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/InteractsWithItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function shipping(): MorphOne
protected function currency(): Attribute
{
return new Attribute(
get: static function (string $value = null): string {
get: static function (?string $value = null): string {
return $value ?: Bazar::getCurrency();
}
);
Expand Down
4 changes: 2 additions & 2 deletions tests/Gateway/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ class FailingDriver extends Driver
{
protected string $name = 'failing';

public function pay(Order $order, float $amount = null, array $attributes = []): Transaction
public function pay(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
throw new Exception();
}

public function refund(Order $order, float $amount = null, array $attributes = []): Transaction
public function refund(Order $order, ?float $amount = null, array $attributes = []): Transaction
{
throw new Exception();
}
Expand Down

0 comments on commit 0fb19a0

Please sign in to comment.