diff --git a/includes/class-wc-order-item.php b/includes/class-wc-order-item.php index 38ea6f73ca3..026b0c51dc4 100644 --- a/includes/class-wc-order-item.php +++ b/includes/class-wc-order-item.php @@ -1,23 +1,25 @@ set_object_read( true ); } - $type = 'line_item' === $this->get_type() ? 'product' : $this->get_type(); + $type = 'line_item' === $this->get_type() ? 'product' : $this->get_type(); $this->data_store = WC_Data_Store::load( 'order-item-' . $type ); if ( $this->get_id() > 0 ) { $this->data_store->read( $this ); @@ -78,7 +85,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { */ public function apply_changes() { if ( function_exists( 'array_replace' ) ) { - $this->data = array_replace( $this->data, $this->changes ); + $this->data = array_replace( $this->data, $this->changes ); // phpcs:ignore PHPCompatibility.PHP.NewFunctions.array_replaceFound } else { // PHP 5.2 compatibility. foreach ( $this->changes as $key => $change ) { $this->data[ $key ] = $change; @@ -96,7 +103,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Get order ID this meta belongs to. * - * @param string $context + * @param string $context What the value is for. Valid values are 'view' and 'edit'. * @return int */ public function get_order_id( $context = 'view' ) { @@ -106,7 +113,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Get order item name. * - * @param string $context + * @param string $context What the value is for. Valid values are 'view' and 'edit'. * @return string */ public function get_name( $context = 'view' ) { @@ -119,11 +126,12 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { * @return string */ public function get_type() { - return; + return ''; } /** * Get quantity. + * * @return int */ public function get_quantity() { @@ -132,6 +140,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Get tax status. + * * @return string */ public function get_tax_status() { @@ -141,7 +150,6 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Get tax class. * - * @param string $context * @return string */ public function get_tax_class() { @@ -150,6 +158,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Get parent order object. + * * @return WC_Order */ public function get_order() { @@ -165,8 +174,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Set order ID. * - * @param int $value - * @throws WC_Data_Exception + * @param int $value Order ID. */ public function set_order_id( $value ) { $this->set_prop( 'order_id', absint( $value ) ); @@ -175,8 +183,7 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Set order item name. * - * @param string $value - * @throws WC_Data_Exception + * @param string $value Item name. */ public function set_name( $value ) { $this->set_prop( 'name', wc_clean( $value ) ); @@ -191,11 +198,11 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { /** * Type checking. * - * @param string|array $type + * @param string|array $type Type. * @return boolean */ public function is_type( $type ) { - return is_array( $type ) ? in_array( $this->get_type(), $type ) : $type === $this->get_type(); + return is_array( $type ) ? in_array( $this->get_type(), $type, true ) : $type === $this->get_type(); } /** @@ -216,7 +223,12 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { if ( method_exists( $this, 'get_subtotal' ) ) { $subtotal_taxes = WC_Tax::calc_tax( $this->get_subtotal(), $tax_rates, false ); - $this->set_taxes( array( 'total' => $taxes, 'subtotal' => $subtotal_taxes ) ); + $this->set_taxes( + array( + 'total' => $taxes, + 'subtotal' => $subtotal_taxes, + ) + ); } else { $this->set_taxes( array( 'total' => $taxes ) ); } @@ -293,9 +305,10 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { */ /** - * offsetSet for ArrayAccess - * @param string $offset - * @param mixed $value + * OffsetSet for ArrayAccess. + * + * @param string $offset Offset. + * @param mixed $value Value. */ public function offsetSet( $offset, $value ) { if ( 'item_meta_array' === $offset ) { @@ -317,8 +330,9 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { } /** - * offsetUnset for ArrayAccess - * @param string $offset + * OffsetUnset for ArrayAccess. + * + * @param string $offset Offset. */ public function offsetUnset( $offset ) { $this->maybe_read_meta_data(); @@ -340,8 +354,9 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { } /** - * offsetExists for ArrayAccess - * @param string $offset + * OffsetExists for ArrayAccess. + * + * @param string $offset Offset. * @return bool */ public function offsetExists( $offset ) { @@ -353,8 +368,9 @@ class WC_Order_Item extends WC_Data implements ArrayAccess { } /** - * offsetGet for ArrayAccess - * @param string $offset + * OffsetGet for ArrayAccess. + * + * @param string $offset Offset. * @return mixed */ public function offsetGet( $offset ) {