Issues (686)

jaxon-examples/examples/container/code.php (5 issues)

1
<?php
2
3
use Jaxon\Jaxon;
4
use Jaxon\App\FuncComponent;
5
use Service\ExampleInterface;
6
7
// Register the namespace with a third-party autoloader
8
$loader = new Keradus\Psr4Autoloader;
9
$loader->register();
10
$loader->addNamespace('Service', classDir('/namespace/service'));
11
12
class HelloWorld extends FuncComponent
13
{
14
    protected $service;
15
16
    public function __construct(ExampleInterface $service)
17
    {
18
        $this->service = $service;
19
    }
20
21
    public function sayHello(bool $isCaps, $sMessage)
22
    {
23
        $sMessage = $this->service->message($isCaps) . ', ' . $sMessage;
0 ignored issues
show
Bug Best Practice introduced by
The property service does not exist on HelloWorld. Did you maybe forget to declare it?
Loading history...
24
        $this->response->assign('div2', 'innerHTML', $sMessage);
0 ignored issues
show
Bug Best Practice introduced by
The property response does not exist on HelloWorld. Did you maybe forget to declare it?
Loading history...
25
    }
26
27
    public function setColor(string $sColor)
28
    {
29
        $sColor = $this->service->color($sColor);
0 ignored issues
show
Bug Best Practice introduced by
The property service does not exist on HelloWorld. Did you maybe forget to declare it?
Loading history...
30
        $this->response->assign('div2', 'style.color', $sColor);
0 ignored issues
show
Bug Best Practice introduced by
The property response does not exist on HelloWorld. Did you maybe forget to declare it?
Loading history...
31
    }
32
}
33
34
// Register object
35
$jaxon = jaxon();
36
37
$jaxon->app()->setup(configFile('container.php', 'lib'));
0 ignored issues
show
The call to configFile() has too many arguments starting with 'lib'. ( Ignorable by Annotation )

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

37
$jaxon->app()->setup(/** @scrutinizer ignore-call */ configFile('container.php', 'lib'));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
38
$jaxon->setOption('core.decode_utf8', true);
39
40
$jaxon->register(Jaxon::CALLABLE_CLASS, HelloWorld::class);
41