Fix psalm

This commit is contained in:
Alex P 2022-02-17 18:29:45 +02:00
parent fc89021df4
commit 651099705a
5 changed files with 58 additions and 40 deletions

View file

@ -55,10 +55,12 @@ class PayerFactory {
$national_number = preg_replace( '/[^0-9]/', '', $national_number ); $national_number = preg_replace( '/[^0-9]/', '', $national_number );
$national_number = substr( $national_number, 0, 14 ); $national_number = substr( $national_number, 0, 14 );
$phone = new PhoneWithType( if ( $national_number ) {
'HOME', $phone = new PhoneWithType(
new Phone( $national_number ) 'HOME',
); new Phone( $national_number )
);
}
} }
return new Payer( return new Payer(
new PayerName( new PayerName(
@ -91,10 +93,12 @@ class PayerFactory {
$national_number = preg_replace( '/[^0-9]/', '', $national_number ); $national_number = preg_replace( '/[^0-9]/', '', $national_number );
$national_number = substr( $national_number, 0, 14 ); $national_number = substr( $national_number, 0, 14 );
$phone = new PhoneWithType( if ( $national_number ) {
'HOME', $phone = new PhoneWithType(
new Phone( $national_number ) 'HOME',
); new Phone( $national_number )
);
}
} }
return new Payer( return new Payer(
new PayerName( new PayerName(
@ -176,10 +180,12 @@ class PayerFactory {
if ( null !== $national_number ) { if ( null !== $national_number ) {
$national_number = substr( $national_number, 0, 14 ); $national_number = substr( $national_number, 0, 14 );
$phone = new PhoneWithType( if ( $national_number ) {
'HOME', $phone = new PhoneWithType(
new Phone( $national_number ) 'HOME',
); new Phone( $national_number )
);
}
} }
} }

View file

@ -74,7 +74,10 @@ class ApplicationContextRepository {
$parts = explode( '-', $locale ); $parts = explode( '-', $locale );
if ( count( $parts ) === 3 ) { if ( count( $parts ) === 3 ) {
return substr( $locale, 0, strrpos( $locale, '-' ) ); $ret = substr( $locale, 0, strrpos( $locale, '-' ) );
if ( false !== $ret ) {
return $ret;
}
} }
return 'en'; return 'en';

View file

@ -45,6 +45,8 @@ class CustomerRepository {
} }
$unique_id = substr( $this->prefix . strrev( uniqid() ), 0, self::CLIENT_ID_MAX_LENGTH ); $unique_id = substr( $this->prefix . strrev( uniqid() ), 0, self::CLIENT_ID_MAX_LENGTH );
assert( is_string( $unique_id ) );
WC()->session->set( 'ppcp_guest_customer_id', $unique_id ); WC()->session->set( 'ppcp_guest_customer_id', $unique_id );
return $unique_id; return $unique_id;

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.11.2@6fba5eb554f9507b72932f9c75533d8af593688d"> <files psalm-version="4.20.0@f82a70e7edfc6cf2705e9374c8a0b6a974a779ed">
<file src="modules/ppcp-api-client/services.php"> <file src="modules/ppcp-api-client/services.php">
<UndefinedConstant occurrences="2"> <UndefinedConstant occurrences="2">
<code>PAYPAL_API_URL</code> <code>PAYPAL_API_URL</code>
@ -12,9 +12,6 @@
</UndefinedMethod> </UndefinedMethod>
</file> </file>
<file src="modules/ppcp-api-client/src/Endpoint/IdentityToken.php"> <file src="modules/ppcp-api-client/src/Endpoint/IdentityToken.php">
<InvalidOperand occurrences="1">
<code>$customer_id</code>
</InvalidOperand>
<UndefinedMethod occurrences="1"> <UndefinedMethod occurrences="1">
<code>$response</code> <code>$response</code>
</UndefinedMethod> </UndefinedMethod>
@ -52,9 +49,6 @@
</UndefinedMethod> </UndefinedMethod>
</file> </file>
<file src="modules/ppcp-api-client/src/Endpoint/PaymentTokenEndpoint.php"> <file src="modules/ppcp-api-client/src/Endpoint/PaymentTokenEndpoint.php">
<InvalidOperand occurrences="1">
<code>$id</code>
</InvalidOperand>
<UndefinedMethod occurrences="1"> <UndefinedMethod occurrences="1">
<code>$response</code> <code>$response</code>
</UndefinedMethod> </UndefinedMethod>
@ -212,9 +206,7 @@
<RedundantCast occurrences="1"> <RedundantCast occurrences="1">
<code>(float) $item_total</code> <code>(float) $item_total</code>
</RedundantCast> </RedundantCast>
<RedundantCastGivenDocblockType occurrences="8"> <RedundantCastGivenDocblockType occurrences="6">
<code>(float) $cart-&gt;get_cart_contents_tax()</code>
<code>(float) $cart-&gt;get_discount_tax()</code>
<code>(float) $cart-&gt;get_discount_total()</code> <code>(float) $cart-&gt;get_discount_total()</code>
<code>(float) $cart-&gt;get_shipping_total()</code> <code>(float) $cart-&gt;get_shipping_total()</code>
<code>(float) $cart-&gt;get_total( 'numeric' )</code> <code>(float) $cart-&gt;get_total( 'numeric' )</code>
@ -288,6 +280,9 @@
</UndefinedConstant> </UndefinedConstant>
</file> </file>
<file src="modules/ppcp-button/services.php"> <file src="modules/ppcp-button/services.php">
<PossiblyFalseArgument occurrences="1">
<code>realpath( __FILE__ )</code>
</PossiblyFalseArgument>
<UndefinedConstant occurrences="2"> <UndefinedConstant occurrences="2">
<code>CONNECT_WOO_CLIENT_ID</code> <code>CONNECT_WOO_CLIENT_ID</code>
<code>CONNECT_WOO_SANDBOX_CLIENT_ID</code> <code>CONNECT_WOO_SANDBOX_CLIENT_ID</code>
@ -297,13 +292,9 @@
<InvalidScalarArgument occurrences="1"> <InvalidScalarArgument occurrences="1">
<code>1</code> <code>1</code>
</InvalidScalarArgument> </InvalidScalarArgument>
<MissingClosureParamType occurrences="2"> <MissingClosureParamType occurrences="1">
<code>$default_fields</code>
<code>$id</code> <code>$id</code>
</MissingClosureParamType> </MissingClosureParamType>
<MissingClosureReturnType occurrences="1">
<code>function ( $default_fields, $id ) {</code>
</MissingClosureReturnType>
<MissingReturnType occurrences="3"> <MissingReturnType occurrences="3">
<code>button_renderer</code> <code>button_renderer</code>
<code>dcc_renderer</code> <code>dcc_renderer</code>
@ -440,6 +431,9 @@
<MissingClosureParamType occurrences="1"> <MissingClosureParamType occurrences="1">
<code>$container</code> <code>$container</code>
</MissingClosureParamType> </MissingClosureParamType>
<PossiblyFalseArgument occurrences="1">
<code>realpath( __FILE__ )</code>
</PossiblyFalseArgument>
<UndefinedConstant occurrences="10"> <UndefinedConstant occurrences="10">
<code>CONNECT_WOO_MERCHANT_ID</code> <code>CONNECT_WOO_MERCHANT_ID</code>
<code>CONNECT_WOO_SANDBOX_MERCHANT_ID</code> <code>CONNECT_WOO_SANDBOX_MERCHANT_ID</code>
@ -532,18 +526,13 @@
<FalsableReturnStatement occurrences="1"> <FalsableReturnStatement occurrences="1">
<code>current( $tokens )</code> <code>current( $tokens )</code>
</FalsableReturnStatement> </FalsableReturnStatement>
<MissingReturnType occurrences="3"> <MissingReturnType occurrences="2">
<code>capture_order</code>
<code>process_order</code> <code>process_order</code>
<code>renew</code> <code>renew</code>
</MissingReturnType> </MissingReturnType>
<RedundantCastGivenDocblockType occurrences="6"> <RedundantCastGivenDocblockType occurrences="2">
<code>(int) $customer-&gt;get_id()</code>
<code>(int) $customer-&gt;get_id()</code> <code>(int) $customer-&gt;get_id()</code>
<code>(int) $wc_order-&gt;get_customer_id()</code> <code>(int) $wc_order-&gt;get_customer_id()</code>
<code>(int) $wc_order-&gt;get_id()</code>
<code>(int) $wc_order-&gt;get_id()</code>
<code>(int) $wc_order-&gt;get_id()</code>
</RedundantCastGivenDocblockType> </RedundantCastGivenDocblockType>
<TooManyArguments occurrences="1"> <TooManyArguments occurrences="1">
<code>apply_filters( 'woocommerce_paypal_payments_subscriptions_get_token_for_customer', null, $customer, $wc_order )</code> <code>apply_filters( 'woocommerce_paypal_payments_subscriptions_get_token_for_customer', null, $customer, $wc_order )</code>
@ -571,6 +560,11 @@
<code>\WC_Subscription</code> <code>\WC_Subscription</code>
</UndefinedClass> </UndefinedClass>
</file> </file>
<file src="modules/ppcp-vaulting/services.php">
<PossiblyFalseArgument occurrences="1">
<code>realpath( __FILE__ )</code>
</PossiblyFalseArgument>
</file>
<file src="modules/ppcp-vaulting/src/Assets/MyAccountPaymentsAssets.php"> <file src="modules/ppcp-vaulting/src/Assets/MyAccountPaymentsAssets.php">
<MissingReturnType occurrences="1"> <MissingReturnType occurrences="1">
<code>localize</code> <code>localize</code>
@ -603,6 +597,13 @@
</MissingReturnType> </MissingReturnType>
</file> </file>
<file src="modules/ppcp-wc-gateway/services.php"> <file src="modules/ppcp-wc-gateway/services.php">
<PossiblyFalseArgument occurrences="2">
<code>realpath( __FILE__ )</code>
<code>realpath( __FILE__ )</code>
</PossiblyFalseArgument>
<PossiblyFalseOperand occurrences="1">
<code>substr( $letters, 0, 6 )</code>
</PossiblyFalseOperand>
<PossiblyInvalidArgument occurrences="5"> <PossiblyInvalidArgument occurrences="5">
<code>wp_unslash( $_GET[ SectionsRenderer::KEY ] )</code> <code>wp_unslash( $_GET[ SectionsRenderer::KEY ] )</code>
<code>wp_unslash( $_GET['page'] )</code> <code>wp_unslash( $_GET['page'] )</code>
@ -637,7 +638,6 @@
</file> </file>
<file src="modules/ppcp-wc-gateway/src/Checkout/CheckoutPayPalAddressPreset.php"> <file src="modules/ppcp-wc-gateway/src/Checkout/CheckoutPayPalAddressPreset.php">
<PossiblyNullReference occurrences="3"> <PossiblyNullReference occurrences="3">
<code>phone</code>
<code>phone</code> <code>phone</code>
<code>phone</code> <code>phone</code>
<code>purchase_units</code> <code>purchase_units</code>
@ -764,7 +764,7 @@
</RedundantCast> </RedundantCast>
</file> </file>
<file src="modules/ppcp-wc-gateway/src/WCGatewayModule.php"> <file src="modules/ppcp-wc-gateway/src/WCGatewayModule.php">
<MissingClosureParamType occurrences="15"> <MissingClosureParamType occurrences="13">
<code>$args</code> <code>$args</code>
<code>$args</code> <code>$args</code>
<code>$column</code> <code>$column</code>
@ -774,9 +774,7 @@
<code>$methods</code> <code>$methods</code>
<code>$methods</code> <code>$methods</code>
<code>$notices</code> <code>$notices</code>
<code>$order</code>
<code>$order_actions</code> <code>$order_actions</code>
<code>$recipient</code>
<code>$value</code> <code>$value</code>
<code>$wc_order_id</code> <code>$wc_order_id</code>
<code>$wc_order_id</code> <code>$wc_order_id</code>
@ -793,6 +791,11 @@
<code>$container</code> <code>$container</code>
</MissingClosureParamType> </MissingClosureParamType>
</file> </file>
<file src="modules/ppcp-webhooks/services.php">
<PossiblyFalseArgument occurrences="1">
<code>realpath( __FILE__ )</code>
</PossiblyFalseArgument>
</file>
<file src="modules/ppcp-webhooks/src/Endpoint/ResubscribeEndpoint.php"> <file src="modules/ppcp-webhooks/src/Endpoint/ResubscribeEndpoint.php">
<MissingReturnType occurrences="1"> <MissingReturnType occurrences="1">
<code>handle_request</code> <code>handle_request</code>
@ -918,4 +921,9 @@
</PossiblyNullArgument> </PossiblyNullArgument>
<RedundantCastGivenDocblockType occurrences="1"/> <RedundantCastGivenDocblockType occurrences="1"/>
</file> </file>
<file src="src/services.php">
<PossiblyFalseArgument occurrences="1">
<code>realpath( __FILE__ )</code>
</PossiblyFalseArgument>
</file>
</files> </files>

View file

@ -9,7 +9,6 @@
usePhpDocMethodsWithoutMagicCall="false" usePhpDocMethodsWithoutMagicCall="false"
strictBinaryOperands="true" strictBinaryOperands="true"
rememberPropertyAssignmentsAfterCall="true" rememberPropertyAssignmentsAfterCall="true"
allowPhpStormGenerics="true"
allowStringToStandInForClass="false" allowStringToStandInForClass="false"
memoizeMethodCallResults="false" memoizeMethodCallResults="false"
hoistConstants="false" hoistConstants="false"