auto fix phpcs errors

This commit is contained in:
Kirill Braslavsky 2021-03-17 13:59:18 +02:00
parent 6b61205474
commit d04cd56cd9
3 changed files with 16 additions and 16 deletions

View file

@ -151,9 +151,9 @@ class CreateOrderEndpoint implements EndpointInterface {
*/ */
public function handle_request(): bool { public function handle_request(): bool {
try { try {
$data = $this->request_data->read_request( $this->nonce() ); $data = $this->request_data->read_request( $this->nonce() );
$this->parsed_request_data = $data; $this->parsed_request_data = $data;
$wc_order = null; $wc_order = null;
if ( 'pay-now' === $data['context'] ) { if ( 'pay-now' === $data['context'] ) {
$wc_order = wc_get_order( (int) $data['order_id'] ); $wc_order = wc_get_order( (int) $data['order_id'] );
if ( ! is_a( $wc_order, \WC_Order::class ) ) { if ( ! is_a( $wc_order, \WC_Order::class ) ) {
@ -180,9 +180,9 @@ class CreateOrderEndpoint implements EndpointInterface {
$this->validate_paynow_form( $data['form'] ); $this->validate_paynow_form( $data['form'] );
} }
//if we are here so the context is not 'checkout' as it exits before. Therefore, a PayPal order is not created yet. // if we are here so the context is not 'checkout' as it exits before. Therefore, a PayPal order is not created yet.
//It would be a good idea to refactor the checkout process in the future. // It would be a good idea to refactor the checkout process in the future.
$order = $this->create_paypal_order($wc_order); $order = $this->create_paypal_order( $wc_order );
wp_send_json_success( $order->to_array() ); wp_send_json_success( $order->to_array() );
return true; return true;
} catch ( \RuntimeException $error ) { } catch ( \RuntimeException $error ) {
@ -194,8 +194,8 @@ class CreateOrderEndpoint implements EndpointInterface {
'details' => is_a( $error, PayPalApiException::class ) ? $error->details() : array(), 'details' => is_a( $error, PayPalApiException::class ) ? $error->details() : array(),
) )
); );
} catch (\Exception $exception){ } catch ( \Exception $exception ) {
wc_add_notice($exception->getMessage(), 'error'); wc_add_notice( $exception->getMessage(), 'error' );
} }
return false; return false;
@ -208,7 +208,7 @@ class CreateOrderEndpoint implements EndpointInterface {
* *
* @throws RuntimeException If create order request fails. * @throws RuntimeException If create order request fails.
*/ */
private function create_paypal_order(\WC_Order $wc_order = null): Order { private function create_paypal_order( \WC_Order $wc_order = null ): Order {
$needs_shipping = WC()->cart && WC()->cart->needs_shipping(); $needs_shipping = WC()->cart && WC()->cart->needs_shipping();
$shipping_address_is_fix = $needs_shipping && 'checkout' === $this->parsed_request_data['context']; $shipping_address_is_fix = $needs_shipping && 'checkout' === $this->parsed_request_data['context'];
@ -225,7 +225,7 @@ class CreateOrderEndpoint implements EndpointInterface {
/** /**
* Returns the Payer entity based on the request data. * Returns the Payer entity based on the request data.
* *
* @param array $data The request data. * @param array $data The request data.
* @param \WC_Order|null $wc_order The order. * @param \WC_Order|null $wc_order The order.
* *
* @return Payer|null * @return Payer|null
@ -280,11 +280,11 @@ class CreateOrderEndpoint implements EndpointInterface {
$payee_preferred = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ? $payee_preferred = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ?
PaymentMethod::PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED PaymentMethod::PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED
: PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; : PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED;
} catch (NotFoundException $exception){ } catch ( NotFoundException $exception ) {
$payee_preferred = PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; $payee_preferred = PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED;
} }
$payment_method = new PaymentMethod( $payee_preferred ); $payment_method = new PaymentMethod( $payee_preferred );
return $payment_method; return $payment_method;
} }
@ -295,7 +295,7 @@ class CreateOrderEndpoint implements EndpointInterface {
* *
* @throws \Exception On Error. * @throws \Exception On Error.
*/ */
private function process_checkout_form(string $form_values ) { private function process_checkout_form( string $form_values ) {
$form_values = explode( '&', $form_values ); $form_values = explode( '&', $form_values );
$parsed_values = array(); $parsed_values = array();

View file

@ -33,7 +33,7 @@ trait ProcessPaymentTrait {
$wc_order = wc_get_order( $order_id ); $wc_order = wc_get_order( $order_id );
if ( ! is_a( $wc_order, \WC_Order::class ) ) { if ( ! is_a( $wc_order, \WC_Order::class ) ) {
wc_add_notice( wc_add_notice(
__('Couldn\'t find order to process', 'woocommerce-paypal-payments' ), __( 'Couldn\'t find order to process', 'woocommerce-paypal-payments' ),
'error' 'error'
); );

View file

@ -123,11 +123,11 @@ class OrderProcessor {
/** /**
* Processes a given WooCommerce order and captured/authorizes the connected PayPal orders. * Processes a given WooCommerce order and captured/authorizes the connected PayPal orders.
* *
* @param \WC_Order $wc_order The WooCommerce order. * @param \WC_Order $wc_order The WooCommerce order.
* *
* @return bool * @return bool
*/ */
public function process( \WC_Order $wc_order): bool { public function process( \WC_Order $wc_order ): bool {
$order = $this->session_handler->order(); $order = $this->session_handler->order();
if ( ! $order ) { if ( ! $order ) {
return false; return false;