dmitry-kulikov/yii2-braintree

View on GitHub
src/Braintree.php

Summary

Maintainability
B
4 hrs
Test Coverage

Braintree has 29 functions (exceeds 20 allowed). Consider refactoring.
Open

class Braintree extends Component
{
    public $environment = 'sandbox';
    public $merchantId;
    public $publicKey;
Severity: Minor
Found in src/Braintree.php - About 3 hrs to fix

    The class Braintree has 21 public methods. Consider refactoring Braintree to keep number of public methods under 10.
    Open

    class Braintree extends Component
    {
        public $environment = 'sandbox';
        public $merchantId;
        public $publicKey;
    Severity: Minor
    Found in src/Braintree.php by phpmd

    TooManyPublicMethods

    Since: 0.1

    A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

    By default it ignores methods starting with 'get' or 'set'.

    Example

    Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

    Function setOptions has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function setOptions(array $values): Braintree
        {
            if (!empty($values)) {
                foreach ($values as $key => $value) {
                    if ($key === 'amount') {
    Severity: Minor
    Found in src/Braintree.php - About 45 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Class "Braintree" has 29 methods, which is greater than 20 authorized. Split it into smaller classes.
    Open

    class Braintree extends Component
    Severity: Major
    Found in src/Braintree.php by sonar-php

    A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

    The class Braintree has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13.
    Open

    class Braintree extends Component
    {
        public $environment = 'sandbox';
        public $merchantId;
        public $publicKey;
    Severity: Minor
    Found in src/Braintree.php by phpmd

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

    Source https://phpmd.org/rules/design.html#couplingbetweenobjects

    The method getPlanById has a boolean flag argument $allowCaching, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getPlanById(string $planId, bool $allowCaching = true): ?Plan
    Severity: Minor
    Found in src/Braintree.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method sale has a boolean flag argument $storeInVaultOnSuccess, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function sale(bool $submitForSettlement = true, bool $storeInVaultOnSuccess = true): array
    Severity: Minor
    Found in src/Braintree.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method getPlanIds has a boolean flag argument $allowCaching, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getPlanIds(bool $allowCaching = true): array
    Severity: Minor
    Found in src/Braintree.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method sale has a boolean flag argument $submitForSettlement, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function sale(bool $submitForSettlement = true, bool $storeInVaultOnSuccess = true): array
    Severity: Minor
    Found in src/Braintree.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    The method getAllPlans has a boolean flag argument $allowCaching, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public function getAllPlans(bool $allowCaching = true): array
    Severity: Minor
    Found in src/Braintree.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Define a constant instead of duplicating this literal "result" 9 times.
    Open

            return ['status' => $result->success, 'result' => $result];
    Severity: Critical
    Found in src/Braintree.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Rename "$plans" which has the same name as the field declared at line 51.
    Wontfix

            $plans = $this->getAllPlans($allowCaching);
    Severity: Major
    Found in src/Braintree.php by sonar-php

    Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

    Noncompliant Code Example

    class Foo {
      public $myField;
    
      public function doSomething() {
        $myField = 0;
        ...
      }
    }
    

    See

    Define a constant instead of duplicating this literal "status" 9 times.
    Open

            return ['status' => $result->success, 'result' => $result];
    Severity: Critical
    Found in src/Braintree.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "options" 3 times.
    Open

            $this->options['options']['submitForSettlement'] = $submitForSettlement;
    Severity: Critical
    Found in src/Braintree.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "amount" 5 times.
    Open

                    'amount' => $amount,
    Severity: Critical
    Found in src/Braintree.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "customerId" 8 times.
    Open

            if (isset($this->options['customerId'])) {
    Severity: Critical
    Found in src/Braintree.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Rename "$plans" which has the same name as the field declared at line 51.
    Wontfix

            $plans = $this->getAllPlans($allowCaching);
    Severity: Major
    Found in src/Braintree.php by sonar-php

    Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

    Noncompliant Code Example

    class Foo {
      public $myField;
    
      public function doSomething() {
        $myField = 0;
        ...
      }
    }
    

    See

    Define a constant instead of duplicating this literal "billing" 3 times.
    Open

            if (isset($this->options['billing'])) {
    Severity: Critical
    Found in src/Braintree.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "creditCard" 4 times.
    Open

            $sendArray = $this->options['creditCard'];
    Severity: Critical
    Found in src/Braintree.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Call to method merchantId from undeclared class \Braintree\Configuration
    Open

                Configuration::$attribute($this->$attribute);
    Severity: Critical
    Found in src/Braintree.php by phan

    Assigning array<string></string> to property but \tuyakhov\braintree\Braintree->options is array<string>&gt;|array<string></string></string>
    Open

            $this->options['amount'] = round($amount, 2);
    Severity: Minor
    Found in src/Braintree.php by phan

    Class extends undeclared class \yii\base\Component
    Open

    class Braintree extends Component
    Severity: Critical
    Found in src/Braintree.php by phan

    Possibly zero references to public property \tuyakhov\braintree\Braintree->environment
    Open

        public $environment = 'sandbox';
    Severity: Minor
    Found in src/Braintree.php by phan

    Assigning array<string></string> to property but \tuyakhov\braintree\Braintree->options is array<string></string>
    Open

            $this->options['options']['storeInVaultOnSuccess'] = $storeInVaultOnSuccess;
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method sale from undeclared class \Braintree\Transaction
    Open

            $result = Transaction::sale($this->options);
    Severity: Critical
    Found in src/Braintree.php by phan

    Return type of getAllPlans() is undeclared type \Braintree\Plan[]
    Open

        public function getAllPlans(bool $allowCaching = true): array
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of getPlanById() is undeclared type ?\Braintree\Plan
    Open

        public function getPlanById(string $planId, bool $allowCaching = true): ?Plan
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method __construct from undeclared class \yii\base\InvalidConfigException
    Open

                    throw new InvalidConfigException(
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method delete from undeclared class \Braintree\PaymentMethod
    Open

            $result = PaymentMethod::delete($this->options['paymentMethodToken']);
    Severity: Critical
    Found in src/Braintree.php by phan

    Reference to undeclared class \yii\base\Component
    Open

            parent::init();
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method create from undeclared class \Braintree\Address
    Open

            $result = Address::create($sendArray);
    Severity: Critical
    Found in src/Braintree.php by phan

    @throws type of init has undeclared type \yii\base\InvalidConfigException
    Open

        public function init()
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method generate from undeclared class \Braintree\ClientToken
    Open

                $this->clientToken = ClientToken::generate($params);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method sale from undeclared class \Braintree\Transaction
    Open

            $result = Transaction::sale(
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method all from undeclared class \Braintree\Plan
    Open

                $this->plans = Plan::all();
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method create from undeclared class \Braintree\CreditCard
    Open

            $result = CreditCard::create($sendArray);
    Severity: Critical
    Found in src/Braintree.php by phan

    Reference to instance property id from undeclared class \Braintree\Plan
    Open

                if ($plan->id === $planId) {
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of findTransaction() is undeclared type \Braintree\Transaction
    Open

        public function findTransaction(string $id): Transaction
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method sale from undeclared class \Braintree\Transaction
    Open

            $result = Transaction::sale(
    Severity: Critical
    Found in src/Braintree.php by phan

    Return type of searchTransaction() is undeclared type \Braintree\ResourceCollection
    Open

        public function searchTransaction($params = []): ResourceCollection
    Severity: Minor
    Found in src/Braintree.php by phan

    Possibly zero write references to public property \tuyakhov\braintree\Braintree->merchantId
    Open

        public $merchantId;
    Severity: Minor
    Found in src/Braintree.php by phan

    Property \tuyakhov\braintree\Braintree->plans has undeclared type \Braintree\Plan[]
    Open

        protected $plans;
    Severity: Minor
    Found in src/Braintree.php by phan

    Possibly zero references to public method \tuyakhov\braintree\Braintree::getUrlManager()
    Open

        public function getUrlManager(): UrlManager
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method update from undeclared class \Braintree\PaymentMethod
    Open

            $result = PaymentMethod::update($this->options['paymentMethodToken'], $this->options['paymentMethod']);
    Severity: Critical
    Found in src/Braintree.php by phan

    Assigning array<string></string> to property but \tuyakhov\braintree\Braintree->options is array<string></string>
    Open

                $this->options['customer']['id'] = $this->options['customerId'];
    Severity: Minor
    Found in src/Braintree.php by phan

    Possibly zero references to public property \tuyakhov\braintree\Braintree->privateKey
    Open

        public $privateKey;
    Severity: Minor
    Found in src/Braintree.php by phan

    Possibly zero references to public method \tuyakhov\braintree\Braintree::init()
    Open

        public function init()
    Severity: Minor
    Found in src/Braintree.php by phan

    Argument #2 of this call to \strtr is typically a literal or constant but isn't, but argument #1 (which is typically a variable) is a literal or constant. The arguments may be in the wrong order.
    Invalid

                        strtr(
    Severity: Minor
    Found in src/Braintree.php by phan

    Reference to instance property id from undeclared class \Braintree\Plan
    Open

                $planIds[] = $plan->id;
    Severity: Minor
    Found in src/Braintree.php by phan

    Possibly zero references to public property \tuyakhov\braintree\Braintree->publicKey
    Open

        public $publicKey;
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method create from undeclared class \Braintree\PaymentMethod
    Open

            $result = PaymentMethod::create($this->options['paymentMethod']);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method create from undeclared class \Braintree\Customer
    Open

            $result = Customer::create($this->options['customer']);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method getValue from undeclared class \yii\helpers\ArrayHelper
    Open

                $optionalValue = ArrayHelper::getValue($values, $optionalParamName);
    Severity: Critical
    Found in src/Braintree.php by phan

    Possibly zero references to public method \tuyakhov\braintree\Braintree::getClientToken()
    Open

        public function getClientToken($params = []): string
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of getPlanById() is undeclared type \Braintree\Plan
    Open

        public function getPlanById(string $planId, bool $allowCaching = true): ?Plan
    Severity: Minor
    Found in src/Braintree.php by phan

    Possibly zero references to public method \tuyakhov\braintree\Braintree::findTransaction()
    Open

        public function findTransaction(string $id): Transaction
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method find from undeclared class \Braintree\Transaction
    Open

            return Transaction::find($id);
    Severity: Critical
    Found in src/Braintree.php by phan

    Return type of findMerchant() is undeclared type \Braintree\MerchantAccount
    Open

        public function findMerchant(string $merchantId): MerchantAccount
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of createSubscription() is undeclared type \Braintree\Result\Error (Did you mean class \Error)
    Open

        public function createSubscription(array $params)
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of updateSubscription() is undeclared type \Braintree\Result\Successful
    Open

        public function updateSubscription(string $subscriptionId, array $params)
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of parseWebhookNotification() is undeclared type \Braintree\WebhookNotification
    Open

        public function parseWebhookNotification(string $signature, $payload): WebhookNotification
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method submitForSettlement from undeclared class \Braintree\Transaction
    Open

                $result = Transaction::submitForSettlement($retryResult->transaction->id);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method search from undeclared class \Braintree\Transaction
    Open

            return Transaction::search($params);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method cancel from undeclared class \Braintree\Subscription
    Open

            return Subscription::cancel($subscriptionId);
    Severity: Critical
    Found in src/Braintree.php by phan

    Return type of searchSubscription() is undeclared type \Braintree\ResourceCollection
    Open

        public function searchSubscription($params = []): ResourceCollection
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of findSubscription() is undeclared type \Braintree\Subscription
    Open

        public function findSubscription(string $subscriptionId): Subscription
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method find from undeclared class \Braintree\MerchantAccount
    Open

            return MerchantAccount::find($merchantId);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method find from undeclared class \Braintree\Customer
    Open

            return Customer::find($customerId);
    Severity: Critical
    Found in src/Braintree.php by phan

    Return type of createSubscription() is undeclared type \Braintree\Result\Successful
    Open

        public function createSubscription(array $params)
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of cancelSubscription() is undeclared type \Braintree\Result\Successful
    Open

        public function cancelSubscription(string $subscriptionId)
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method parse from undeclared class \Braintree\WebhookNotification
    Open

            return WebhookNotification::parse($signature, $payload);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method find from undeclared class \Braintree\Subscription
    Open

            return Subscription::find($subscriptionId);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method update from undeclared class \Braintree\Subscription
    Open

            return Subscription::update($subscriptionId, $params);
    Severity: Critical
    Found in src/Braintree.php by phan

    Return type of cancelSubscription() is undeclared type \Braintree\Result\Error (Did you mean class \Error)
    Open

        public function cancelSubscription(string $subscriptionId)
    Severity: Minor
    Found in src/Braintree.php by phan

    Call to method retryCharge from undeclared class \Braintree\Subscription
    Open

            $retryResult = Subscription::retryCharge($subscriptionId, $amount);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method search from undeclared class \Braintree\Subscription
    Open

            return Subscription::search($params);
    Severity: Critical
    Found in src/Braintree.php by phan

    Call to method create from undeclared class \Braintree\Subscription
    Open

            return Subscription::create($params);
    Severity: Critical
    Found in src/Braintree.php by phan

    Return type of findCustomer() is undeclared type \Braintree\Customer
    Open

        public function findCustomer(string $customerId): Customer
    Severity: Minor
    Found in src/Braintree.php by phan

    Return type of updateSubscription() is undeclared type \Braintree\Result\Error (Did you mean class \Error)
    Open

        public function updateSubscription(string $subscriptionId, array $params)
    Severity: Minor
    Found in src/Braintree.php by phan

    Avoid excessively long variable names like $storeInVaultOnSuccess. Keep variable name length under 20.
    Open

        public function sale(bool $submitForSettlement = true, bool $storeInVaultOnSuccess = true): array
    Severity: Minor
    Found in src/Braintree.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid variables with short names like $id. Configured minimum length is 3.
    Wontfix

        public function findTransaction(string $id): Transaction
    Severity: Minor
    Found in src/Braintree.php by phpmd

    ShortVariable

    Since: 0.2

    Detects when a field, local, or parameter has a very short name.

    Example

    class Something {
        private $q = 15; // VIOLATION - Field
        public static function main( array $as ) { // VIOLATION - Formal
            $r = 20 + $this->q; // VIOLATION - Local
            for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                $r += $this->q;
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#shortvariable

    There are no issues that match your filters.

    Category
    Status