dmitry-kulikov/yii2-braintree

View on GitHub

Showing 265 of 271 total issues

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 class \tuyakhov\braintree\ActiveForm
Open

class ActiveForm extends \yii\bootstrap\ActiveForm
Severity: Minor
Found in src/ActiveForm.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

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

                ['customerId'],
Severity: Critical
Found in src/BraintreeForm.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 "Company Name" 3 times.
Open

            'customer_company' => 'Company Name',
Severity: Critical
Found in src/BraintreeForm.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.

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

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

                ['customer_firstName', 'customer_lastName'],
Severity: Critical
Found in src/BraintreeForm.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_expirationDate" 4 times.
Open

                ['creditCard_number', 'creditCard_expirationDate', 'creditCard_cvv', 'customerId'],
Severity: Critical
Found in src/BraintreeForm.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.

Reference to undeclared property \tuyakhov\braintree\ActiveForm->fieldClass
Open

        $this->fieldClass = ActiveField::class;
Severity: Minor
Found in src/ActiveForm.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

Reference to undeclared property \tuyakhov\braintree\ActiveField->inputOptions
Open

        $this->inputOptions = array_merge(
Severity: Minor
Found in src/ActiveField.php by phan

Reference to undeclared class \yii\bootstrap\ActiveForm (Did you mean class \tuyakhov\braintree\ActiveForm)
Open

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

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

            $this->addErrorFromResponse($result['result']);
Severity: Critical
Found in src/BraintreeForm.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 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

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.

Call to method underscore from undeclared class \yii\helpers\Inflector
Open

                'data-braintree-name' => Inflector::underscore($inputName[0]),
Severity: Critical
Found in src/ActiveField.php by phan
Severity
Category
Status
Source
Language