Issues (53)

src/Traits/HasMethodsTrait.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Nip\View\Traits;
6
7
use Closure;
8
9
/**
10
 * Trait HasMethodsTrait.
11
 */
12
trait HasMethodsTrait
13
{
14
    /**
15
     * Magic method used to call extension functions.
16
     *
17 11
     * @param string $name
18
     * @param array $arguments
19 11
     *
20 11
     * @return mixed
21
     */
22
    public function __call($name, $arguments)
23
    {
24
        return $this->getFunction($name)->call(null, $arguments);
0 ignored issues
show
The method getFunction() does not exist on Nip\View\Traits\HasMethodsTrait. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        return $this->/** @scrutinizer ignore-call */ getFunction($name)->call(null, $arguments);
Loading history...
25 11
    }
26
27 11
    public function addMethod($name, callable $callable): void
28 11
    {
29
        $this->registerFunction($name, $callable);
0 ignored issues
show
The method registerFunction() does not exist on Nip\View\Traits\HasMethodsTrait. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
        $this->/** @scrutinizer ignore-call */ 
30
               registerFunction($name, $callable);
Loading history...
30
    }
31 11
32
    /**
33
     * @param Closure[] $methods
34
     */
35
    public function addMethods(array $methods)
36
    {
37 11
        foreach ($methods as $name => $closure) {
38
            $this->addMethod($name, $closure);
39 11
        }
40 11
    }
41
}
42