src/HookTrait.php

Summary

Maintainability
A
2 hrs
Test Coverage

Avoid deeply nested control flow statements.
Open

                                if ($i <= $index) {
                                    unset($indexes[$k]);
                                }
Severity: Major
Found in src/HookTrait.php - About 45 mins to fix

Method onHookDynamic has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function onHookDynamic(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.php - About 35 mins to fix

Method onHookDynamicShort has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function onHookDynamicShort(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.php - About 35 mins to fix

Avoid too many return statements within this method.
Open

        return isset($this->hooks[$spot][$priority]);
Severity: Major
Found in src/HookTrait.php - About 30 mins to fix

The method hook() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
Open

    public function hook(string $spot, array $args = [], &$brokenBy = null)
    {
        $brokenBy = null;

        $this->_rebindHooksIfCloned();
Severity: Minor
Found in src/HookTrait.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

Missing class import via use statement (line '83', column '39').
Open

                        $fxRefl = new \ReflectionFunction($hookData[0]);
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '144', column '23').
Open

        $fxRefl = new \ReflectionFunction($fx);
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '36', column '43').
Open

                    $dummyInstance = (new \ReflectionClass($class))->newInstanceWithoutConstructor();
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '62', column '24').
Open

        $fxThis = (new \ReflectionFunction($fx))->getClosureThis();
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '24', column '24').
Open

        $fxThis = (new \ReflectionFunction($fx))->getClosureThis();
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '185', column '31').
Open

                    throw new \TypeError('New $this must be an object');
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '171', column '37').
Open

            $getFxThisFxThis = (new \ReflectionFunction($getFxThisFx))->getClosureThis();
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

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

    public function removeHook(string $spot, ?int $priority = null, bool $priorityIsIndex = false)
Severity: Minor
Found in src/HookTrait.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

Missing class import via use statement (line '173', column '27').
Open

                throw new \TypeError('New $this getter must be static');
Severity: Minor
Found in src/HookTrait.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

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

    public function hookHasCallbacks(string $spot, ?int $priority = null, bool $priorityIsIndex = false): bool
Severity: Minor
Found in src/HookTrait.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 _makeHookDynamicFx uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $fxThis = $getFxThisFx($target); // @phpstan-ignore argument.type
                if (!is_object($fxThis)) { // @phpstan-ignore function.alreadyNarrowedType
                    throw new \TypeError('New $this must be an object');
                }
Severity: Minor
Found in src/HookTrait.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 '\Closure' in method '_makeHookDynamicFx'.
Open

                ? \Closure::bind($fx, $fxThis)(...$args)
Severity: Minor
Found in src/HookTrait.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 removeHook uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            unset($this->hooks[$spot]);
        }
Severity: Minor
Found in src/HookTrait.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 '\Closure' in method '_rebindHookFxToFakeInstance'.
Open

                        \Closure::bind(static function () use ($dummyInstance) {
                            foreach (array_keys(get_object_vars($dummyInstance)) as $k) {
                                unset($dummyInstance->{$k});
                            }
                        }, null, $scope)();
Severity: Minor
Found in src/HookTrait.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 '\Closure' in method 'onHookShort'.
Open

                $fxLong = \Closure::bind(function ($ignore, &...$args) use ($fx) {
                    return \Closure::bind($fx, $this)(...$args);
                }, $fxThis, $fxScopeClassRefl->getName());
Severity: Minor
Found in src/HookTrait.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 '\Closure' in method '_rebindHookFxToFakeInstance'.
Open

        return \Closure::bind($fx, $fakeThis);
Severity: Minor
Found in src/HookTrait.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 '\Closure' in method 'onHookShort'.
Open

                    return \Closure::bind($fx, $this)(...$args);
Severity: Minor
Found in src/HookTrait.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 '\Closure' in method '_makeHookDynamicFx'.
Open

                : \Closure::bind($fx, $fxThis)($target, ...$args);
Severity: Minor
Found in src/HookTrait.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 '\WeakReference' in method '_rebindHooksIfCloned'.
Open

        $this->_hookOrigThis = \WeakReference::create($this);
Severity: Minor
Found in src/HookTrait.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 onHook uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $this->hooks[$spot][$priority][$index] = $data;
        }
Severity: Minor
Found in src/HookTrait.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 '\Closure' in method 'onHookShort'.
Open

            $fxLong = \Closure::bind(static function ($ignore, &...$args) use ($fx) {
                return $fx(...$args);
            }, null, $fxScopeClassRefl !== null ? $fxScopeClassRefl->getName() : null);
Severity: Minor
Found in src/HookTrait.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 onHookShort uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $fxLong = $this->_unbindHookFxIfBoundToThis($fx, true);
            if ($fxLong === $fx) {
                $fx = $this->_rebindHookFxToFakeInstance($fx);

Severity: Minor
Found in src/HookTrait.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 removeHook uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                unset($this->hooks[$spot][$priority]);
            }
Severity: Minor
Found in src/HookTrait.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 unused local variables such as '$spot'.
Open

            foreach ($this->hooks as $spot => $hooksByPriority) {
Severity: Minor
Found in src/HookTrait.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Avoid unused local variables such as '$priority'.
Open

                foreach ($hooksByPriority as $priority => $hooksByIndex) {
Severity: Minor
Found in src/HookTrait.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Avoid unused local variables such as '$index'.
Open

                    foreach ($hooksByIndex as $index => $hookData) {
Severity: Minor
Found in src/HookTrait.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

Avoid unused parameters such as '$ignore'.
Open

                $fxLong = \Closure::bind(function ($ignore, &...$args) use ($fx) {
Severity: Minor
Found in src/HookTrait.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

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

        $instanceWithoutConstructorCache = new class {
Severity: Minor
Found in src/HookTrait.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 $fx. Configured minimum length is 3.
Open

    private function _unbindHookFxIfBoundToThis(\Closure $fx, bool $isShort): \Closure
Severity: Minor
Found in src/HookTrait.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

Avoid variables with short names like $fx. Configured minimum length is 3.
Open

    public function onHookDynamic(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.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

Avoid variables with short names like $fx. Configured minimum length is 3.
Open

    public function onHookShort(string $spot, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.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

Avoid variables with short names like $fx. Configured minimum length is 3.
Open

    public function onHookDynamicShort(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.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

Avoid variables with short names like $fx. Configured minimum length is 3.
Open

    public function onHook(string $spot, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.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

Avoid variables with short names like $fx. Configured minimum length is 3.
Open

    private function _rebindHookFxToFakeInstance(\Closure $fx): \Closure
Severity: Minor
Found in src/HookTrait.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

Avoid variables with short names like $fx. Configured minimum length is 3.
Open

    private function _makeHookDynamicFx(?\Closure $getFxThisFx, \Closure $fx, bool $isShort): \Closure
Severity: Minor
Found in src/HookTrait.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

Property name "$_hookIndexCounter" should not be prefixed with an underscore to indicate visibility
Open

    private int $_hookIndexCounter = 0;
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Property name "$_hookOrigThis" should not be prefixed with an underscore to indicate visibility
Open

    private ?\WeakReference $_hookOrigThis = null;
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 124 characters
Open

                            throw (new Exception('Object cannot be cloned with hook bound to a different object than this'))
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 131 characters
Open

    public function onHookDynamicShort(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

    /** @var array<string, array<int, array<int<0, max>, array{\Closure, list<mixed>}>>> Configured hooks (callbacks). */
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

     * @param ($priorityIsIndex is true ? int<0, max> : int|null) $priority        filter specific priority, null for all
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

     * @return array<int<0, max>, mixed>|mixed Array of responses indexed by hook indexes or value specified to breakHook
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 128 characters
Open

                        if (get_class($fxThis) === static::class || preg_match('~^Atk4\\\(?:Core|Data)~', get_class($fxThis))) {
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

     * @param ($priorityIsIndex is true ? int<0, max> : int|null) $priority        filter specific priority, null for all
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

Line exceeds 120 characters; contains 126 characters
Open

    public function onHookDynamic(string $spot, \Closure $getFxThisFx, \Closure $fx, array $args = [], int $priority = 5): int
Severity: Minor
Found in src/HookTrait.php by phpcodesniffer

The variable $_instances is not named in camelCase.
Open

    private function _rebindHookFxToFakeInstance(\Closure $fx): \Closure
    {
        $fxThis = (new \ReflectionFunction($fx))->getClosureThis();

        $instanceWithoutConstructorCache = new class {
Severity: Minor
Found in src/HookTrait.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_instances is not named in camelCase.
Open

    private function _rebindHookFxToFakeInstance(\Closure $fx): \Closure
    {
        $fxThis = (new \ReflectionFunction($fx))->getClosureThis();

        $instanceWithoutConstructorCache = new class {
Severity: Minor
Found in src/HookTrait.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $_instances is not named in camelCase.
Open

    private function _rebindHookFxToFakeInstance(\Closure $fx): \Closure
    {
        $fxThis = (new \ReflectionFunction($fx))->getClosureThis();

        $instanceWithoutConstructorCache = new class {
Severity: Minor
Found in src/HookTrait.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The method _unbindHookFxIfBoundToThis is not named in camelCase.
Open

    private function _unbindHookFxIfBoundToThis(\Closure $fx, bool $isShort): \Closure
    {
        $fxThis = (new \ReflectionFunction($fx))->getClosureThis();
        if ($fxThis !== $this) {
            return $fx;
Severity: Minor
Found in src/HookTrait.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _rebindHooksIfCloned is not named in camelCase.
Open

    private function _rebindHooksIfCloned(): void
    {
        if ($this->_hookOrigThis !== null) {
            $hookOrigThis = $this->_hookOrigThis->get();
            if ($hookOrigThis === $this) {
Severity: Minor
Found in src/HookTrait.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _rebindHookFxToFakeInstance is not named in camelCase.
Open

    private function _rebindHookFxToFakeInstance(\Closure $fx): \Closure
    {
        $fxThis = (new \ReflectionFunction($fx))->getClosureThis();

        $instanceWithoutConstructorCache = new class {
Severity: Minor
Found in src/HookTrait.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

The method _makeHookDynamicFx is not named in camelCase.
Open

    private function _makeHookDynamicFx(?\Closure $getFxThisFx, \Closure $fx, bool $isShort): \Closure
    {
        if ($getFxThisFx !== null) {
            $getFxThisFxThis = (new \ReflectionFunction($getFxThisFx))->getClosureThis();
            if ($getFxThisFxThis !== null) {
Severity: Minor
Found in src/HookTrait.php by phpmd

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status