vistart/yii2-models

View on GitHub

Showing 197 of 197 total issues

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

            $ips = Ip::splitIPv6(Ip::IPv6toLong($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\BaseBlameableQuery' in method 'init'.
Open

            $this->queryClass = BaseBlameableQuery::className();
Severity: Minor
Found in models/BaseUserRelationGroupModel.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 'getCanBeLogon()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    public function getCanBeLogon()
    {
        if (!$this->enableLoginAttribute) {
            return false;
        }
Severity: Minor
Found in traits/AdditionalAccountTrait.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 'getContentCanBeEdited()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    public function getContentCanBeEdited()
    {
        if ($this->contentAttribute === false) {
            return false;
        }
Severity: Minor
Found in traits/BlameableTrait.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 register() has a Cyclomatic Complexity of 18. The configured cyclomatic complexity threshold is 10.
Open

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

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

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

Only one argument is allowed per line in a multi-line function call
Open

            parent::rules(), $this->passwordHashRules, $this->passwordResetTokenRules, $this->sourceRules, $this->statusRules, $this->authKeyRules, $this->accessTokenRules
Severity: Minor
Found in traits/UserTrait.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

            parent::rules(), $this->passwordHashRules, $this->passwordResetTokenRules, $this->sourceRules, $this->statusRules, $this->authKeyRules, $this->accessTokenRules
Severity: Minor
Found in traits/UserTrait.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

            parent::rules(), $this->passwordHashRules, $this->passwordResetTokenRules, $this->sourceRules, $this->statusRules, $this->authKeyRules, $this->accessTokenRules
Severity: Minor
Found in traits/UserTrait.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

            parent::rules(), $this->passwordHashRules, $this->passwordResetTokenRules, $this->sourceRules, $this->statusRules, $this->authKeyRules, $this->accessTokenRules
Severity: Minor
Found in traits/UserTrait.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

            parent::rules(), $this->passwordHashRules, $this->passwordResetTokenRules, $this->sourceRules, $this->statusRules, $this->authKeyRules, $this->accessTokenRules
Severity: Minor
Found in traits/UserTrait.php by phpcodesniffer

Only one argument is allowed per line in a multi-line function call
Open

            parent::rules(), $this->passwordHashRules, $this->passwordResetTokenRules, $this->sourceRules, $this->statusRules, $this->authKeyRules, $this->accessTokenRules
Severity: Minor
Found in traits/UserTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 156 characters
Open

            [[$this->otherGuidAttribute, $this->createdByAttribute], 'unique', 'targetAttribute' => [$this->otherGuidAttribute, $this->createdByAttribute]],
Severity: Minor
Found in traits/UserRelationTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 140 characters
Open

        return array_merge($rules, $this->getRemarkRules(), $this->getFavoriteRules(), $this->getGroupsRules(), $this->getOtherGuidRules());
Severity: Minor
Found in traits/UserRelationTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 161 characters
Open

            if (($this->expiredRemovingCallback instanceof Closure || is_array($this->expiredRemovingCallback)) && is_callable($this->expiredRemovingCallback)) {
Severity: Minor
Found in traits/TimestampTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 174 characters
Open

            return date('Y-m-d H:i:s', strtotime(($offset >= 0 ? "+$offset" : $offset) . " seconds", is_string($time) ? strtotime($time) : (is_int($time) ? $time : time())));
Severity: Minor
Found in traits/TimestampTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 171 characters
Open

            $inverse = (int) static::find()->recipients($initiator)->initiators($recipient)->andWhere([$model->mutualTypeAttribute => static::$mutualTypeNormal])->count();
Severity: Minor
Found in traits/UserRelationTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 125 characters
Open

            $relation = new static([$createdByAttribute => $user, $otherGuidAttribute => $other, 'userClass' => $userClass]);
Severity: Minor
Found in traits/UserRelationTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 130 characters
Open

        if (empty($parent) || $this->guid == $parent->guid || $parent->hasAncestor($this) || $parent->hasReachedAncestorLimit()) {

Line exceeds 120 characters; contains 123 characters
Open

        return $this->hasMany(static::className(), [$this->parentAttribute => $this->refIdAttribute])->inverseOf('parent');

Line exceeds 120 characters; contains 171 characters
Open

            parent::rules(), $this->passwordHashRules, $this->passwordResetTokenRules, $this->sourceRules, $this->statusRules, $this->authKeyRules, $this->accessTokenRules
Severity: Minor
Found in traits/UserTrait.php by phpcodesniffer
Severity
Category
Status
Source
Language