fix bug, add type hints, fix annotations

This commit is contained in:
Steffen Mahler 2020-07-27 08:06:03 +02:00
parent 6f76bb4a97
commit a06bca38d4
10 changed files with 29 additions and 15 deletions

View File

@ -9,7 +9,7 @@ class AppointmentSlot extends Booking
* @param \Webkul\BookingProduct\Contracts\BookingProduct $bookingProduct
* @return bool
*/
public function haveSufficientQuantity($qty, $bookingProduct)
public function haveSufficientQuantity(int $qty, $bookingProduct): bool
{
return true;
}

View File

@ -158,7 +158,7 @@ class Booking extends Virtual
* @param int $qty
* @return bool
*/
public function haveSufficientQuantity($qty)
public function haveSufficientQuantity(int $qty): bool
{
return true;
}

View File

@ -795,7 +795,13 @@ class Cart
*/
public function isItemsHaveSufficientQuantity(): bool
{
foreach ($this->getCart()->items as $item) {
$cart = cart()->getCart();
if (! $cart) {
return false;
}
foreach ($cart->items as $item) {
if (! $this->isItemHaveQuantity($item)) {
return false;
}

View File

@ -261,11 +261,11 @@ class Product extends Model implements ProductContract
}
/**
* @param integer $qty
* @param int $qty
*
* @return bool
*/
public function haveSufficientQuantity($qty)
public function haveSufficientQuantity(int $qty): bool
{
return $this->getTypeInstance()->haveSufficientQuantity($qty);
}

View File

@ -99,11 +99,11 @@ class ProductFlat extends Model implements ProductFlatContract
}
/**
* @param integer $qty
* @param int $qty
*
* @return bool
*/
public function haveSufficientQuantity($qty)
public function haveSufficientQuantity(int $qty): bool
{
return $this->product->haveSufficientQuantity($qty);
}

View File

@ -350,7 +350,7 @@ abstract class AbstractType
*
* @return bool
*/
public function haveSufficientQuantity($qty)
public function haveSufficientQuantity(int $qty): bool
{
return $this->haveSufficientQuantity;
}
@ -555,7 +555,7 @@ abstract class AbstractType
if ($haveSpecialPrice) {
$this->product->special_price = min($this->product->special_price, $customerGroupPrice);
} else {
$haveSpecialPrice = true;
$haveSpecialPrice = true;
$this->product->special_price = $customerGroupPrice;
}

View File

@ -685,7 +685,15 @@ class Bundle extends AbstractType
}
foreach ($item->children as $childItem) {
$childItem->product->getTypeInstance()->validateCartItem($childItem);
$childResult = $childItem->product->getTypeInstance()->validateCartItem($childItem);
if ($childResult->isItemInactive()) {
$result->itemIsInactive();
}
if ($childResult->isCartDirty()) {
$result->cartIsDirty();
}
$price += $childItem->base_price * $childItem->quantity;
}

View File

@ -592,7 +592,7 @@ class Configurable extends AbstractType
* @param int $qty
* @return bool
*/
public function haveSufficientQuantity($qty)
public function haveSufficientQuantity(int $qty): bool
{
$backorders = core()->getConfigData('catalog.inventory.stock_options.backorders');

View File

@ -53,12 +53,12 @@ class Simple extends AbstractType
* @param int $qty
* @return bool
*/
public function haveSufficientQuantity($qty)
public function haveSufficientQuantity(int $qty): bool
{
$backorders = core()->getConfigData('catalog.inventory.stock_options.backorders');
$backorders = ! is_null ($backorders) ? $backorders : false;
return $qty <= $this->totalQuantity() ? true : $backorders;
}
}

View File

@ -13,7 +13,7 @@ class Virtual extends AbstractType
/**
* These blade files will be included in product edit page
*
*
* @var array
*/
protected $additionalViews = [
@ -60,7 +60,7 @@ class Virtual extends AbstractType
* @param int $qty
* @return bool
*/
public function haveSufficientQuantity($qty)
public function haveSufficientQuantity(int $qty): bool
{
return $qty <= $this->totalQuantity() ? true : false;
}