Issues (686)

jaxon-examples/examples/upload/code.php (8 issues)

1
<?php
2
3
use Jaxon\App\FuncComponent;
4
use Jaxon\Jaxon;
5
6
class HelloWorld extends FuncComponent
7
{
8
    public function sayHello(bool $isCaps)
9
    {
10
        $text = $isCaps ? 'HELLO WORLD!' : 'Hello World!';
11
        $xResponse = jaxon()->getResponse();
12
        $xResponse->assign('div2', 'innerHTML', $text);
13
        $this->bag('upload')->set('caps', $isCaps);
0 ignored issues
show
The method bag() does not exist on HelloWorld. ( Ignorable by Annotation )

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

13
        $this->/** @scrutinizer ignore-call */ 
14
               bag('upload')->set('caps', $isCaps);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
14
    }
15
16
    public function setColor(string $sColor)
17
    {
18
        $xResponse = jaxon()->getResponse();
19
        $xResponse->assign('div2', 'style.color', $sColor);
20
        $this->bag('upload')->set('color', $sColor);
21
    }
22
23
    public function upload()
24
    {
25
        $xResponse = jaxon()->getResponse();
26
        $files = jaxon()->upload()->files();
27
        $xResponse->dialog->show('Uploaded files', print_r([
0 ignored issues
show
The method show() does not exist on Jaxon\Plugin\ResponsePluginInterface. It seems like you code against a sub-type of Jaxon\Plugin\ResponsePluginInterface such as Jaxon\Plugin\Response\Dialog\DialogPlugin. ( Ignorable by Annotation )

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

27
        $xResponse->dialog->/** @scrutinizer ignore-call */ 
28
                            show('Uploaded files', print_r([
Loading history...
The method show() does not exist on null. ( Ignorable by Annotation )

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

27
        $xResponse->dialog->/** @scrutinizer ignore-call */ 
28
                            show('Uploaded files', print_r([

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Bug Best Practice introduced by
The property dialog does not exist on Jaxon\Response\Response. Since you implemented __get, consider adding a @property annotation.
Loading history...
28
            'bags' => [
29
                'caps' => $this->bag('upload')->get('caps') ? 'yes' : 'no',
30
                'color' => $this->bag('upload')->get('color'),
31
            ],
32
            'photos' => $files['photos'],
33
        ], true), []);
34
        $xResponse->dialog->info('Uploaded ' . count($files['photos']) . ' file(s).');
0 ignored issues
show
The method info() does not exist on Jaxon\Plugin\ResponsePluginInterface. It seems like you code against a sub-type of Jaxon\Plugin\ResponsePluginInterface such as Jaxon\Plugin\Response\Dialog\DialogPlugin. ( Ignorable by Annotation )

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

34
        $xResponse->dialog->/** @scrutinizer ignore-call */ 
35
                            info('Uploaded ' . count($files['photos']) . ' file(s).');
Loading history...
$files['photos'] of type Jaxon\Request\Upload\FileInterface is incompatible with the type Countable|array expected by parameter $value of count(). ( Ignorable by Annotation )

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

34
        $xResponse->dialog->info('Uploaded ' . count(/** @scrutinizer ignore-type */ $files['photos']) . ' file(s).');
Loading history...
35
    }
36
}
37
38
// Register object
39
$jaxon = jaxon();
40
41
// Request processing URI
42
$jaxon->setOption('js.lib.uri', '/js');
43
$jaxon->setOption('js.app.minify', false);
44
45
$jaxon->setOption('upload.enabled', true);
46
$jaxon->setOption('upload.default.dir', __DIR__ . '/files');
47
48
$jaxon->setAppOption('dialogs.default.modal', 'bootbox');
49
$jaxon->setAppOption('dialogs.default.alert', 'toastr');
50
51
$jaxon->callback()->after(function($target, $end) {
0 ignored issues
show
The parameter $target is not used and could be removed. ( Ignorable by Annotation )

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

51
$jaxon->callback()->after(function(/** @scrutinizer ignore-unused */ $target, $end) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
The parameter $end is not used and could be removed. ( Ignorable by Annotation )

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

51
$jaxon->callback()->after(function($target, /** @scrutinizer ignore-unused */ $end) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
52
    jaxon()->di()->getResponseManager()->getResponse()->debug('After upload');
53
});
54
55
$jaxon->register(Jaxon::CALLABLE_CLASS, HelloWorld::class, [
56
    'functions' => [
57
        '*' => [
58
            'bags' => ['upload'],
59
        ],
60
        'upload' => [
61
            'upload' => "'file-select'",
62
        ],
63
    ],
64
]);
65