Skip to content

Commit

Permalink
[PW-2562] Adjustments for phpcs (Adyen#9)
Browse files Browse the repository at this point in the history
* Fixes and removing phpcs exclude patterns in favor of specific rules suppression

* New phpcs version and ignore/disable sniffs

* Adjusting copyright comment
  • Loading branch information
acampos1916 authored Jul 14, 2020
1 parent d84dfa8 commit d8fe558
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Run PHP Code Sniffer
run: vendor/bin/phpcs --ignore=*vendor/ --ignore=AdyenPayment.php --ignore=Controllers --standard=PSR2 .
run: vendor/bin/phpcs .

- name: Make sure project files are compilable
run: find -L . -path ./vendor -prune -o -path ./tests -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
3 changes: 3 additions & 0 deletions AdyenPayment.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

//phpcs:disable PSR1.Files.SideEffects

namespace AdyenPayment;

use Doctrine\Common\Cache\Cache;
Expand Down Expand Up @@ -236,3 +238,4 @@ private function rebuildAttributeModels()
if (AdyenPayment::isPackage()) {
require_once AdyenPayment::getPackageVendorAutoload();
}
//phpcs:enable PSR1.Files.SideEffects
3 changes: 2 additions & 1 deletion Components/Payload/Providers/ApplicationInfoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use AdyenPayment\AdyenPayment;
use Shopware\Components\Model\ModelManager;
use Shopware\Models\Plugin\Plugin;
use AdyenPayment\Models\Enum\Channel;

/**
* Class ApplicationInfoProvider
Expand Down Expand Up @@ -48,7 +49,7 @@ public function provide(PaymentContext $context): array
'executeThreeD' => true,
'allow3DS2' => true,
],
"channel" => "Web",
"channel" => Channel::WEB,
'origin' => $context->getOrigin(),
'returnUrl' => $returnUrl,
'merchantAccount' => $this->configuration->getMerchantAccount(),
Expand Down
8 changes: 5 additions & 3 deletions Components/Payload/Providers/BrowserInfoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ class BrowserInfoProvider implements PaymentPayloadProvider
*/
public function provide(PaymentContext $context): array
{
$browserInfo = [
'acceptHeader' => $_SERVER['HTTP_ACCEPT'] ?? '',
];
$browserInfo = [];

if (!empty($_SERVER['HTTP_ACCEPT'])) {
$browserInfo['acceptHeader'] = $_SERVER['HTTP_ACCEPT'];
}

return [
'browserInfo' => array_merge($browserInfo, $context->getBrowserInfo()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use AdyenPayment\Models\Enum\NotificationStatus;
use AdyenPayment\Models\Notification;

//phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps, Generic.Files.LineLength.TooLong
class Shopware_Controllers_Backend_AdyenPaymentNotificationsListingExtension extends Shopware_Controllers_Backend_Application
{
protected $model = Notification::class;
Expand Down
1 change: 1 addition & 0 deletions Controllers/Backend/AdyenPaymentRefund.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Shopware\Components\CSRFWhitelistAware;

//phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps, Generic.Files.LineLength.TooLong
class Shopware_Controllers_Backend_AdyenPaymentRefund extends Shopware_Controllers_Backend_ExtJs implements CSRFWhitelistAware
{
public function refundAction()
Expand Down
1 change: 1 addition & 0 deletions Controllers/Backend/TestAdyenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Symfony\Component\HttpFoundation\Response;

//phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps
class Shopware_Controllers_Backend_TestAdyenApi extends Shopware_Controllers_Backend_ExtJs
{
public function runAction()
Expand Down
1 change: 1 addition & 0 deletions Controllers/Frontend/Adyen.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/**
* Class Shopware_Controllers_Frontend_Adyen
*/
//phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps
class Shopware_Controllers_Frontend_Adyen extends Shopware_Controllers_Frontend_Payment
{
/**
Expand Down
1 change: 1 addition & 0 deletions Controllers/Frontend/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Shopware\Components\ContainerAwareEventManager;
use Shopware\Components\CSRFWhitelistAware;

//phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps, Generic.Files.LineLength.TooLong
class Shopware_Controllers_Frontend_Notification extends Shopware_Controllers_Frontend_Payment implements CSRFWhitelistAware
{
/**
Expand Down
14 changes: 7 additions & 7 deletions Controllers/Frontend/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/**
* Class Redirect
*/
//phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps
class Shopware_Controllers_Frontend_Process extends Shopware_Controllers_Frontend_Payment implements CSRFWhitelistAware
{
/**
Expand Down Expand Up @@ -111,18 +112,17 @@ private function handleReturnResult($result)
}

switch ($result['resultCode']) {
case 'Authorised':
case 'Pending':
case 'Received':
case PaymentResultCodes::AUTHORISED:
case PaymentResultCodes::PENDING:
case PaymentResultCodes::RECEIVED:
$paymentStatus = $this->getModelManager()->find(
Status::class,
Status::PAYMENT_STATE_THE_PAYMENT_HAS_BEEN_ORDERED
);
break;
case 'Cancelled':
case 'Error':
case 'Fail':
case 'Refused':
case PaymentResultCodes::CANCELLED:
case PaymentResultCodes::ERROR:
case PaymentResultCodes::REFUSED:
$paymentStatus = $this->getModelManager()->find(
Status::class,
Status::PAYMENT_STATE_THE_PROCESS_HAS_BEEN_CANCELLED
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"require-dev": {
"shopware/shopware": "^5.6",
"phpro/grumphp": "^0.16.1",
"squizlabs/php_codesniffer": "2.*",
"phpcompatibility/php-compatibility": "^9.3",
"dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "^2.16"
"friendsofphp/php-cs-fixer": "^2.16",
"squizlabs/php_codesniffer": "3.*"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
8 changes: 3 additions & 5 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
~ #############
~ ############
~
~ Adyen PrestaShop plugin
~ Adyen Shopware 5 plugin
~
~ @author Adyen BV <[email protected]>
~ @copyright (c) 2020 Adyen B.V.
~ @copyright (c) 2020 Adyen N.V.
~ @license https://opensource.org/licenses/MIT MIT license
~ This file is open source and available under the MIT license.
~ See the LICENSE file for more info.
Expand All @@ -25,9 +25,7 @@
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHP_CodeSniffer"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>Controllers/*</exclude-pattern>
<exclude-pattern>AdyenPayment.php</exclude-pattern>
<arg name="basepath" value="."/>
<file>.</file>
<rule ref="PSR2">
<exclude-pattern>*.js</exclude-pattern>
</rule>
Expand Down
8 changes: 0 additions & 8 deletions ruleset.xml

This file was deleted.

0 comments on commit d8fe558

Please sign in to comment.