Skip to content

Commit 12c21c5

Browse files
authored
Merge pull request #3534 from woocommerce/PCP-4570-qit-warnings
Fix QIT warnings
2 parents 2c59a00 + 727492e commit 12c21c5

File tree

73 files changed

+173
-217
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+173
-217
lines changed

modules/ppcp-admin-notices/src/Renderer/Renderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function render(): bool {
8080

8181
printf(
8282
'<div class="notice notice-%s %s" %s%s><p>%s</p></div>',
83-
$message->type(),
83+
esc_attr( $message->type() ),
8484
( $message->is_dismissible() ) ? 'is-dismissible' : '',
8585
( $message->wrapper() ? sprintf( 'data-ppcp-wrapper="%s"', esc_attr( $message->wrapper() ) ) : '' ),
8686
// Use `empty()` in condition, to avoid false phpcs warning.

modules/ppcp-api-client/src/Endpoint/OrderEndpoint.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ public function with_bn_code( string $bn_code ): OrderEndpoint {
176176
public function create(
177177
array $items,
178178
string $shipping_preference,
179-
Payer $payer = null,
179+
?Payer $payer = null,
180180
string $payment_method = '',
181181
array $request_data = array(),
182-
PaymentSource $payment_source = null
182+
?PaymentSource $payment_source = null
183183
): Order {
184184
$bearer = $this->bearer->bearer();
185185
$data = array(
@@ -444,9 +444,7 @@ public function order( string $id ): Order {
444444
}
445445
$response = $this->request( $url, $args );
446446
if ( is_wp_error( $response ) ) {
447-
$error = new RuntimeException(
448-
__( 'Could not retrieve order.', 'woocommerce-paypal-payments' )
449-
);
447+
$error = new RuntimeException( 'Could not retrieve order.' );
450448
$this->logger->warning( $error->getMessage() );
451449

452450
throw $error;
@@ -456,7 +454,7 @@ public function order( string $id ): Order {
456454

457455
if ( 404 === $status_code || empty( $response['body'] ) ) {
458456
$error = new RuntimeException(
459-
__( 'Could not retrieve order.', 'woocommerce-paypal-payments' ),
457+
'Could not retrieve order.',
460458
404
461459
);
462460
$this->logger->warning(

modules/ppcp-api-client/src/Endpoint/WebhookEndpoint.php

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ public function create( Webhook $hook ): Webhook {
113113
$response = $this->request( $url, $args );
114114

115115
if ( is_wp_error( $response ) ) {
116-
throw new RuntimeException(
117-
__( 'Not able to create a webhook.', 'woocommerce-paypal-payments' )
118-
);
116+
throw new RuntimeException( 'Not able to create a webhook.' );
119117
}
120118

121119
$json = json_decode( $response['body'] );
@@ -151,9 +149,7 @@ public function list(): array {
151149
$response = $this->request( $url, $args );
152150

153151
if ( is_wp_error( $response ) ) {
154-
throw new RuntimeException(
155-
__( 'Not able to load webhooks list.', 'woocommerce-paypal-payments' )
156-
);
152+
throw new RuntimeException( 'Not able to load webhooks list.' );
157153
}
158154

159155
$json = json_decode( $response['body'] );
@@ -195,9 +191,7 @@ public function delete( Webhook $hook ): void {
195191
$response = $this->request( $url, $args );
196192

197193
if ( $response instanceof WP_Error ) {
198-
throw new RuntimeException(
199-
__( 'Not able to delete the webhook.', 'woocommerce-paypal-payments' )
200-
);
194+
throw new RuntimeException( 'Not able to delete the webhook.' );
201195
}
202196

203197
$status_code = (int) wp_remote_retrieve_response_code( $response );
@@ -250,9 +244,7 @@ public function simulate( Webhook $hook, string $event_type, ?string $resource_v
250244
$response = $this->request( $url, $args );
251245

252246
if ( is_wp_error( $response ) ) {
253-
throw new RuntimeException(
254-
__( 'Not able to simulate webhook.', 'woocommerce-paypal-payments' )
255-
);
247+
throw new RuntimeException( 'Not able to simulate webhook.' );
256248
}
257249
$json = json_decode( $response['body'] );
258250
$status_code = (int) wp_remote_retrieve_response_code( $response );
@@ -312,9 +304,7 @@ public function verify_event(
312304
);
313305
$response = $this->request( $url, $args );
314306
if ( is_wp_error( $response ) ) {
315-
$error = new RuntimeException(
316-
__( 'Not able to verify webhook event.', 'woocommerce-paypal-payments' )
317-
);
307+
$error = new RuntimeException( 'Not able to verify webhook event.' );
318308
$this->logger->log(
319309
'warning',
320310
$error->getMessage(),
@@ -340,9 +330,7 @@ public function verify_event(
340330
public function verify_current_request_for_webhook( Webhook $webhook ): bool {
341331

342332
if ( ! $webhook->id() ) {
343-
$error = new RuntimeException(
344-
__( 'Not a valid webhook to verify.', 'woocommerce-paypal-payments' )
345-
);
333+
$error = new RuntimeException( 'Not a valid webhook to verify.' );
346334
$this->logger->log( 'warning', $error->getMessage(), array( 'webhook' => $webhook ) );
347335
throw $error;
348336
}
@@ -369,11 +357,7 @@ public function verify_current_request_for_webhook( Webhook $webhook ): bool {
369357

370358
$error = new RuntimeException(
371359
sprintf(
372-
// translators: %s is the headers key.
373-
__(
374-
'Not a valid webhook event. Header %s is missing',
375-
'woocommerce-paypal-payments'
376-
),
360+
'Not a valid webhook event. Header %s is missing',
377361
$key
378362
)
379363
);

modules/ppcp-api-client/src/Entity/Amount.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Amount {
4141
* @param Money $money The money.
4242
* @param AmountBreakdown|null $breakdown The breakdown.
4343
*/
44-
public function __construct( Money $money, AmountBreakdown $breakdown = null ) {
44+
public function __construct( Money $money, ?AmountBreakdown $breakdown = null ) {
4545
$this->money = $money;
4646
$this->breakdown = $breakdown;
4747
}

modules/ppcp-api-client/src/Entity/AuthorizationStatus.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ public function __construct( string $status, ?AuthorizationStatusDetails $detail
6262
if ( ! in_array( $status, self::VALID_STATUS, true ) ) {
6363
throw new RuntimeException(
6464
sprintf(
65-
// translators: %s is the current status.
66-
__( '%s is not a valid status', 'woocommerce-paypal-payments' ),
65+
'%s is not a valid status',
6766
$status
6867
)
6968
);

modules/ppcp-api-client/src/Entity/Item.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@ public function __construct(
114114
Money $unit_amount,
115115
int $quantity,
116116
string $description = '',
117-
Money $tax = null,
117+
?Money $tax = null,
118118
string $sku = '',
119119
string $category = 'PHYSICAL_GOODS',
120120
string $url = '',
121121
string $image_url = '',
122122
float $tax_rate = 0,
123-
string $cart_item_key = null
123+
?string $cart_item_key = null
124124
) {
125125

126126
$this->name = $name;

modules/ppcp-api-client/src/Entity/Order.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
1111

12+
use DateTime;
13+
1214
/**
1315
* Class Order
1416
*/
@@ -25,7 +27,7 @@ class Order {
2527
/**
2628
* The create time.
2729
*
28-
* @var \DateTime|null
30+
* @var DateTime|null
2931
*/
3032
private $create_time;
3133

@@ -60,7 +62,7 @@ class Order {
6062
/**
6163
* The update time.
6264
*
63-
* @var \DateTime|null
65+
* @var DateTime|null
6466
*/
6567
private $update_time;
6668

@@ -86,18 +88,18 @@ class Order {
8688
* @param PaymentSource|null $payment_source The payment source.
8789
* @param Payer|null $payer The payer.
8890
* @param string $intent The intent.
89-
* @param \DateTime|null $create_time The create time.
90-
* @param \DateTime|null $update_time The update time.
91+
* @param DateTime|null $create_time The create time.
92+
* @param DateTime|null $update_time The update time.
9193
*/
9294
public function __construct(
9395
string $id,
9496
array $purchase_units,
9597
OrderStatus $order_status,
96-
PaymentSource $payment_source = null,
97-
Payer $payer = null,
98+
?PaymentSource $payment_source = null,
99+
?Payer $payer = null,
98100
string $intent = 'CAPTURE',
99-
\DateTime $create_time = null,
100-
\DateTime $update_time = null,
101+
?DateTime $create_time = null,
102+
?DateTime $update_time = null,
101103
$links = null
102104
) {
103105

@@ -124,7 +126,7 @@ public function id(): string {
124126
/**
125127
* Returns the create time.
126128
*
127-
* @return \DateTime|null
129+
* @return DateTime|null
128130
*/
129131
public function create_time() {
130132
return $this->create_time;
@@ -133,7 +135,7 @@ public function create_time() {
133135
/**
134136
* Returns the update time.
135137
*
136-
* @return \DateTime|null
138+
* @return DateTime|null
137139
*/
138140
public function update_time() {
139141
return $this->update_time;

modules/ppcp-api-client/src/Entity/OrderStatus.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public function __construct( string $status ) {
5151
if ( ! in_array( $status, self::VALID_STATUS, true ) ) {
5252
throw new RuntimeException(
5353
sprintf(
54-
// translators: %s is the current status.
55-
__( '%s is not a valid status', 'woocommerce-paypal-payments' ),
54+
'%s is not a valid status',
5655
$status
5756
)
5857
);

modules/ppcp-api-client/src/Entity/Payer.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
1111

12+
use DateTime;
13+
1214
/**
1315
* Class Payer
1416
* The customer who sends the money.
@@ -39,7 +41,7 @@ class Payer {
3941
/**
4042
* The birth date.
4143
*
42-
* @var \DateTime|null
44+
* @var DateTime|null
4345
*/
4446
private $birthdate;
4547

@@ -71,18 +73,18 @@ class Payer {
7173
* @param string $email_address The email.
7274
* @param string $payer_id The payer id.
7375
* @param Address|null $address The address.
74-
* @param \DateTime|null $birthdate The birth date.
76+
* @param DateTime|null $birthdate The birth date.
7577
* @param PhoneWithType|null $phone The phone.
7678
* @param PayerTaxInfo|null $tax_info The tax info.
7779
*/
7880
public function __construct(
7981
?PayerName $name,
8082
string $email_address,
8183
string $payer_id,
82-
Address $address = null,
83-
\DateTime $birthdate = null,
84-
PhoneWithType $phone = null,
85-
PayerTaxInfo $tax_info = null
84+
?Address $address = null,
85+
?DateTime $birthdate = null,
86+
?PhoneWithType $phone = null,
87+
?PayerTaxInfo $tax_info = null
8688
) {
8789

8890
$this->name = $name;
@@ -133,7 +135,7 @@ public function payer_id(): string {
133135
/**
134136
* Returns the birth date.
135137
*
136-
* @return \DateTime|null
138+
* @return DateTime|null
137139
*/
138140
public function birthdate() {
139141
return $this->birthdate;

modules/ppcp-api-client/src/Entity/PayerTaxInfo.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public function __construct(
5151
if ( ! in_array( $type, self::VALID_TYPES, true ) ) {
5252
throw new RuntimeException(
5353
sprintf(
54-
// translators: %s is the current type.
55-
__( '%s is not a valid tax type.', 'woocommerce-paypal-payments' ),
54+
'%s is not a valid tax type.',
5655
$type
5756
)
5857
);

0 commit comments

Comments
 (0)