Fix new psalm errors

This commit is contained in:
Alex P 2022-11-09 10:12:34 +02:00
parent c3f1f0feaf
commit 8801a847ea
8 changed files with 25 additions and 29 deletions

View file

@ -154,9 +154,9 @@ class Capture {
/**
* Returns the seller protection object.
*
* @return \stdClass
* @return object
*/
public function seller_protection() : \stdClass {
public function seller_protection() {
return (object) array( 'status' => $this->seller_protection );
}

View file

@ -19,7 +19,7 @@ class Token {
/**
* The Token data.
*
* @var \stdClass
* @var object
*/
private $json;
@ -33,10 +33,10 @@ class Token {
/**
* Token constructor.
*
* @param \stdClass $json The JSON object.
* @param object $json The JSON object.
* @throws RuntimeException When The JSON object is not valid.
*/
public function __construct( \stdClass $json ) {
public function __construct( $json ) {
if ( ! isset( $json->created ) ) {
$json->created = time();
}
@ -122,11 +122,11 @@ class Token {
/**
* Validates whether a JSON object can be transformed to a Token object.
*
* @param \stdClass $json The JSON object.
* @param object $json The JSON object.
*
* @return bool
*/
private function validate( \stdClass $json ): bool {
private function validate( $json ): bool {
$property_map = array(
'created' => 'is_int',
'expires_in' => 'is_int',

View file

@ -9,8 +9,6 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
use stdClass;
/**
* Class Webhook
*/
@ -33,16 +31,16 @@ class Webhook {
/**
* The event types.
*
* @var string[]
* @var object[]
*/
private $event_types;
/**
* Webhook constructor.
*
* @param string $url The URL of the webhook.
* @param stdClass[] $event_types The associated event types.
* @param string $id The id of the webhook.
* @param string $url The URL of the webhook.
* @param object[] $event_types The associated event types.
* @param string $id The id of the webhook.
*/
public function __construct( string $url, array $event_types, string $id = '' ) {
$this->url = $url;
@ -73,7 +71,7 @@ class Webhook {
/**
* Returns the event types.
*
* @return stdClass[]
* @return object[]
*/
public function event_types(): array {

View file

@ -10,7 +10,6 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
use DateTime;
use stdClass;
/**
* Class WebhookEvent
@ -69,7 +68,7 @@ class WebhookEvent {
/**
* The resource that triggered the webhook event notification.
*
* @var stdClass
* @var object
*/
private $resource;
@ -83,9 +82,9 @@ class WebhookEvent {
* @param string $event_type The event that triggered the webhook event notification, such as 'CHECKOUT.ORDER.APPROVED'.
* @param string $summary A summary description for the event notification.
* @param string $resource_version The resource version in the webhook notification, such as '1.0'.
* @param stdClass $resource The resource that triggered the webhook event notification.
* @param object $resource The resource that triggered the webhook event notification.
*/
public function __construct( string $id, ?DateTime $create_time, string $resource_type, string $event_version, string $event_type, string $summary, string $resource_version, stdClass $resource ) {
public function __construct( string $id, ?DateTime $create_time, string $resource_type, string $event_version, string $event_type, string $summary, string $resource_version, $resource ) {
$this->id = $id;
$this->create_time = $create_time;
$this->resource_type = $resource_type;
@ -162,9 +161,9 @@ class WebhookEvent {
/**
* The resource that triggered the webhook event notification.
*
* @return stdClass
* @return object
*/
public function resource(): stdClass {
public function resource() {
return $this->resource;
}
}

View file

@ -9,7 +9,6 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
use stdClass;
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
@ -21,12 +20,12 @@ class PaymentTokenFactory {
/**
* Returns a PaymentToken based off a PayPal Response object.
*
* @param \stdClass $data The JSON object.
* @param object $data The JSON object.
*
* @return PaymentToken
* @throws RuntimeException When JSON object is malformed.
*/
public function from_paypal_response( stdClass $data ): PaymentToken {
public function from_paypal_response( $data ): PaymentToken {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'No id for payment token given', 'woocommerce-paypal-payments' )

View file

@ -33,12 +33,12 @@ class WebhookEventFactory {
/**
* Returns a Webhook based of a PayPal JSON response.
*
* @param stdClass $data The JSON object.
* @param object $data The JSON object.
*
* @return WebhookEvent
* @throws RuntimeException When JSON object is malformed.
*/
public function from_paypal_response( stdClass $data ): WebhookEvent {
public function from_paypal_response( $data ): WebhookEvent {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'ID for webhook event not found.', 'woocommerce-paypal-payments' )

View file

@ -9,7 +9,6 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\ApiClient\Factory;
use stdClass;
use WooCommerce\PayPalCommerce\ApiClient\Entity\Webhook;
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
@ -28,7 +27,7 @@ class WebhookFactory {
*/
public function for_url_and_events( string $url, array $event_types ): Webhook {
$event_types = array_map(
static function ( string $type ): stdClass {
static function ( string $type ) {
return (object) array( 'name' => $type );
},
$event_types
@ -53,12 +52,12 @@ class WebhookFactory {
/**
* Returns a Webhook based of a PayPal JSON response.
*
* @param stdClass $data The JSON object.
* @param object $data The JSON object.
*
* @return Webhook
* @throws RuntimeException When JSON object is malformed.
*/
public function from_paypal_response( stdClass $data ): Webhook {
public function from_paypal_response( $data ): Webhook {
if ( ! isset( $data->id ) ) {
throw new RuntimeException(
__( 'No id for webhook given.', 'woocommerce-paypal-payments' )

View file

@ -152,6 +152,7 @@
<MixedStringOffsetAssignment errorLevel="info"/>
<ParamNameMismatch errorLevel="info"/>
<RedundantCastGivenDocblockType errorLevel="info"/>
<RiskyCast errorLevel="info"/>
<TooManyArguments>
<errorLevel type="suppress">