Completed
Push — master ( 49d562...d01d83 )
by Aydin
02:44 queued 10s
created

examples/disabled-items.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use PhpSchool\CliMenu\CliMenu;
4
use PhpSchool\CliMenu\Builder\CliMenuBuilder;
5
6
require_once(__DIR__ . '/../vendor/autoload.php');
7
8
$itemCallable = function (CliMenu $menu) {
9
    echo $menu->getSelectedItem()->getText();
10
};
11
12
$menu = (new CliMenuBuilder)
0 ignored issues
show
The method end() does not seem to exist on object<PhpSchool\CliMenu\Builder\CliMenuBuilder>.

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...
13
    ->setTitle('Basic CLI Menu Disabled Items')
14
    ->addItem('First Item', $itemCallable)
15
    ->addItem('Second Item', $itemCallable, false, true)
16
    ->addItem('Third Item', $itemCallable, false, true)
17
    ->addSubMenu('sub-menu-1', 'Submenu')
0 ignored issues
show
'Submenu' is of type string, but the function expects a object<Closure>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
18
        ->setTitle('Basic CLI Menu Disabled Items > Submenu')
19
        ->addItem('You can go in here!', $itemCallable)
20
        ->end()
21
    ->addSubMenu('sub-menu-2', 'Disabled Submenu')
22
        ->setTitle('Basic CLI Menu Disabled Items > Disabled Submenu')
23
        ->addItem('Nope can\'t see this!', $itemCallable)
24
        ->disableMenu()
25
        ->end()
26
    ->addLineBreak('-')
27
    ->build();
28
29
$menu->open();
30