codesniffer cleanup

This commit is contained in:
David Remer 2020-06-29 13:35:37 +03:00
parent 51465324a0
commit 4478ec87f2
13 changed files with 51 additions and 55 deletions

View file

@ -29,4 +29,4 @@ jobs:
- name: Run test suite
run: ./vendor/bin/phpunit
- name: Run cs
run: ./vendor/bin/phpcs src modules.local/ppcp-wc-gateway modules.local/ppcp-button/src/ --standard=Inpsyde
run: ./vendor/bin/phpcs src modules.local/ppcp-wc-gateway modules.local/ppcp-button/src/ modules.local/ppcp-onboarding/src/ --standard=Inpsyde

View file

@ -47,7 +47,7 @@ class SmartButton implements SmartButtonInterface
echo '<div id="ppc-button"></div>';
};
$dccRenderer = static function ($id = null) {
$dccRenderer = static function (string $id = null) {
if (!$id) {
$id = 'ppcp-hosted-fields';
}
@ -142,7 +142,6 @@ class SmartButton implements SmartButtonInterface
10
);
if (
$this->settings->has('dcc_checkout_enabled')
&& wc_string_to_bool($this->settings->get('dcc_checkout_enabled'))
) {
@ -252,7 +251,8 @@ class SmartButton implements SmartButtonInterface
if ($payee->merchantId()) {
$params['merchant-id'] = $payee->merchantId();
}
$disableFunding = $this->settings->has('disable_funding') ? $this->settings->get('disable_funding') : [];
$disableFunding = $this->settings->has('disable_funding') ?
$this->settings->get('disable_funding') : [];
if (is_array($disableFunding) && count($disableFunding)) {
$params['disable-funding'] = implode(',', $disableFunding);
}
@ -260,10 +260,9 @@ class SmartButton implements SmartButtonInterface
return $smartButtonUrl;
}
private function attributes() : array {
$attributes = [
//'data-partner-attribution-id' => '',
];
private function attributes(): array
{
$attributes = [];
try {
$clientToken = $this->identityToken->generate();
$attributes['data-client-token'] = $clientToken->token();

View file

@ -148,7 +148,12 @@ class ChangeCartEndpoint implements EndpointInterface
$variationId = $this->productDataStore->find_matching_product_variation($product, $variations);
//ToDo: Check stock status for variation.
return false !== $this->cart->add_to_cart($product->get_id(), $quantity, $variationId, $variations);
return false !== $this->cart->add_to_cart(
$product->get_id(),
$quantity,
$variationId,
$variations
);
}
private function generatePurchaseUnits(): array

View file

@ -1,21 +0,0 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\Button\Endpoint;
class CreateWcOrderEndpoint implements EndpointInterface
{
public const ENDPOINT = 'ppc-create-wc-order';
public static function nonce(): string
{
return self::ENDPOINT;
}
public function handleRequest(): bool
{
}
}

View file

@ -13,17 +13,17 @@ class RequestData
{
$stream = file_get_contents('php://input');
$json = json_decode($stream, true);
add_filter('nonce_user_logged_out', array($this, 'nonceFix'), 100);
add_filter('nonce_user_logged_out', [$this, 'nonceFix'], 100);
if (
! isset($json['nonce'])
|| !wp_verify_nonce($json['nonce'], $nonce)
) {
remove_filter('nonce_user_logged_out', array($this, 'nonceFix'), 100);
remove_filter('nonce_user_logged_out', [$this, 'nonceFix'], 100);
throw new RuntimeException(
__('Could not validate nonce.', 'woocommerce-paypal-commerce-gateway')
);
}
remove_filter('nonce_user_logged_out', array($this, 'nonceFix'), 100);
remove_filter('nonce_user_logged_out', [$this, 'nonceFix'], 100);
return $this->sanitize($json);
}
@ -34,9 +34,11 @@ class RequestData
* the nonce validation will fail. this fixes this problem:
*
* @wp-hook nonce_user_logged_out
* @see https://github.com/woocommerce/woocommerce/blob/69e3835041113bee80379c1037e97e26815a699b/includes/class-wc-session-handler.php#L288-L296 * @return int
* @see https://github.com/woocommerce/woocommerce/blob/69e3835041113bee80379c1037e97e26815a699b/includes/class-wc-session-handler.php#L288-L296
* @return int
*/
public function nonceFix() {
public function nonceFix(): int
{
return 0;
}

View file

@ -57,9 +57,10 @@ class OrderTablePaymentStatusColumn
if ($this->isCaptured($wcOrder)) {
$this->renderCompletedStatus();
} else {
$this->renderIncompletedStatus();
return;
}
$this->renderIncompletedStatus();
}
private function renderForOrder(\WC_Order $order): bool

View file

@ -125,7 +125,8 @@ class WcGateway extends WcGatewayBase
return false;
}
private function renderAuthorizationMessageForStatus(string $status) {
private function renderAuthorizationMessageForStatus(string $status)
{
$messageMapping = [
AuthorizedPaymentsProcessor::SUCCESSFUL => AuthorizeOrderActionNotice::SUCCESS,
@ -137,7 +138,9 @@ class WcGateway extends WcGatewayBase
$this->notice->displayMessage($displayMessage);
}
public function generate_ppcp_onboarding_html($a, $b) {
public function generate_ppcp_onboarding_html($a, $b)
{
$this->onboardingRenderer->render();
}
}

View file

@ -63,7 +63,9 @@ class AuthorizedPaymentsProcessor
return true;
}
public function lastStatus() : string {
public function lastStatus(): string
{
return $this->lastStatus;
}

View file

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
class FullyOnboardedSettings extends StartSettings implements SettingsFields
{
public function fields(): array
@ -127,7 +127,9 @@ class FullyOnboardedSettings extends StartSettings implements SettingsFields
];
}
private function creditCards() : array {
private function creditCards(): array
{
return [
'credit_card_settings' => [

View file

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
class ProgressiveSettings extends StartSettings implements SettingsFields
{

View file

@ -1,9 +1,9 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
trait SettingsTrait
{

View file

@ -1,12 +1,11 @@
<?php
declare(strict_types=1);
namespace Inpsyde\PayPalCommerce\WcGateway\Settings;
class StartSettings implements SettingsFields
{
use SettingsTrait;
public function fields(): array

4
yarn.lock Normal file
View file

@ -0,0 +1,4 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1