vistart/yii2-models

View on GitHub

Showing 197 of 197 total issues

Avoid using static access to class '\yii\helpers\Json' in method 'validateRange'.
Open

            Json::decode($this->$rangeAttribute);
Severity: Minor
Found in traits/NotificationRangeTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method register() has an NPath complexity of 446. The configured NPath complexity threshold is 200.
Open

    public function register($associatedModels = [], $authRoles = [])
    {
        if (!$this->isNewRecord) {
            return false;
        }
Severity: Minor
Found in traits/RegistrationTrait.php by phpmd

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

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

Avoid using static access to class '\yii\behaviors\BlameableBehavior' in method 'getBlameableBehaviors'.
Open

                'class' => BlameableBehavior::className(),
Severity: Minor
Found in traits/BlameableTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\helpers\Number' in method 'generateId'.
Open

                $result = Number::randomNumber($this->idAttributePrefix, $this->idAttributeLength);
Severity: Minor
Found in traits/IDTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\helpers\Ip' in method 'getIpv6Address'.
Open

        return Ip::LongtoIPv6(Ip::populateIPv6([
                    $this->{$this->ipAttribute1},
                    $this->{$this->ipAttribute2},
                    $this->{$this->ipAttribute3},
                    $this->{$this->ipAttribute4}
Severity: Minor
Found in traits/IPTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\Yii' in method 'deregister'.
Open

                Yii::error($ex->errorInfo, static::className() . '\deregister');
Severity: Minor
Found in traits/RegistrationTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\Models\models\BaseUserRelationModel' in method 'groups'.
Open

            return $this->andWhere([$model->multiBlamesAttribute => BaseUserRelationModel::getEmptyGroupJson()]);
Severity: Minor
Found in queries/BaseUserRelationQuery.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\Models\queries\BaseRedisMessageQuery' in method 'init'.
Open

            $this->queryClass = BaseRedisMessageQuery::className();
Severity: Minor
Found in models/BaseRedisMessageModel.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\yii\caching\TagDependency' in method 'getBlameableRules'.
Open

            TagDependency::invalidate($cache, [$this->getEntityRulesCacheTag()]);
Severity: Minor
Found in traits/BlameableTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'vistart\Models\traits\Yii' in method 'deleteChildren'.
Open

            Yii::warning($ex->errorInfo, static::className() . '\delete');
Severity: Minor
Found in traits/SelfBlameableTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\Models\queries\BaseMongoBlameableQuery' in method 'init'.
Open

            $this->queryClass = BaseMongoBlameableQuery::className();
Severity: Minor
Found in models/BaseMongoBlameableModel.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\Models\queries\BaseMongoEntityQuery' in method 'find'.
Open

            $self->queryClass = BaseMongoEntityQuery::className();
Severity: Minor
Found in models/BaseMongoEntityModel.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\Models\queries\BaseRedisEntityQuery' in method 'find'.
Open

            $self->queryClass = BaseRedisEntityQuery::className();
Severity: Minor
Found in models/BaseRedisEntityModel.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The 'getIsConfirmed()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    public function getIsConfirmed()
    {
        $cAttribute = $this->confirmationAttribute;
        return is_string($cAttribute) ? $this->$cAttribute > static::$confirmFalse : true;
    }
Severity: Minor
Found in traits/ConfirmationTrait.php by phpmd

BooleanGetMethodName

Since: 0.2

Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

Example

class Foo {
    /**
     * @return boolean
     */
    public function getFoo() {} // bad
    /**
     * @return bool
     */
    public function isFoo(); // ok
    /**
     * @return boolean
     */
    public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}

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

The method getWebRequest uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $request = Yii::$app->request;
        }
Severity: Minor
Found in traits/IPTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class '\vistart\helpers\Ip' in method 'setIpAddress'.
Open

        $ipType = Ip::judgeIPtype($ipAddress);
Severity: Minor
Found in traits/IPTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\vistart\Models\queries\BaseMongoMessageQuery' in method 'init'.
Open

            $this->queryClass = BaseMongoMessageQuery::className();
Severity: Minor
Found in models/BaseMongoMessageModel.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

The method onInitCache uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $sender->cachePrefix = $sender::className();
        }
Severity: Minor
Found in traits/EntityTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method instantiate uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $model = new static;
        }
Severity: Minor
Found in traits/EntityTrait.php by phpmd

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class 'vistart\Models\traits\Yii' in method 'deleteChildren'.
Open

                Yii::error($ex->errorInfo, static::className() . '\delete');
Severity: Minor
Found in traits/SelfBlameableTrait.php by phpmd

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Severity
Category
Status
Source
Language