Improve type check

This commit is contained in:
Alex P 2021-11-03 10:20:39 +02:00
parent 38ee07e547
commit edd441f5da
3 changed files with 4 additions and 4 deletions

View file

@ -728,7 +728,7 @@ class SmartButton implements SmartButtonInterface {
private function payerData() { private function payerData() {
$customer = WC()->customer; $customer = WC()->customer;
if ( ! is_user_logged_in() || ! is_a( $customer, \WC_Customer::class ) ) { if ( ! is_user_logged_in() || ! ( $customer instanceof \WC_Customer ) ) {
return null; return null;
} }
return $this->payer_factory->from_customer( $customer )->to_array(); return $this->payer_factory->from_customer( $customer )->to_array();
@ -757,7 +757,7 @@ class SmartButton implements SmartButtonInterface {
if ( if (
$this->environment->current_environment_is( Environment::SANDBOX ) $this->environment->current_environment_is( Environment::SANDBOX )
&& defined( 'WP_DEBUG' ) && \WP_DEBUG && is_user_logged_in() && defined( 'WP_DEBUG' ) && \WP_DEBUG && is_user_logged_in()
&& WC()->customer && WC()->customer->get_billing_country() && WC()->customer instanceof \WC_Customer && WC()->customer->get_billing_country()
&& 2 === strlen( WC()->customer->get_billing_country() ) && 2 === strlen( WC()->customer->get_billing_country() )
) { ) {
$params['buyer-country'] = WC()->customer->get_billing_country(); $params['buyer-country'] = WC()->customer->get_billing_country();

View file

@ -285,7 +285,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 instanceof \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'];
return $this->api_endpoint->create( return $this->api_endpoint->create(

View file

@ -112,7 +112,7 @@ class SubscriptionModule implements ModuleInterface {
* @return void * @return void
*/ */
protected function renew( $order, $container ) { protected function renew( $order, $container ) {
if ( ! is_a( $order, \WC_Order::class ) ) { if ( ! ( $order instanceof \WC_Order ) ) {
return; return;
} }