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) |
||
13 | ->setTitle('CLI Menu') |
||
14 | ->addItem('First Item', $itemCallable) |
||
15 | ->addItem('Second Item', $itemCallable) |
||
16 | ->addLineBreak('-') |
||
17 | ->addSubMenu('sub-menu-1', 'Options') |
||
0 ignored issues
–
show
|
|||
18 | ->setTitle('CLI Menu > Options') |
||
19 | ->addItem('First option', function (CliMenu $menu) { |
||
20 | echo sprintf('Executing option: %s', $menu->getSelectedItem()->getText()); |
||
21 | }) |
||
22 | ->addSubMenu('sub-menu-nested-1', 'Secret Options') |
||
0 ignored issues
–
show
'Secret Options' 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...
|
|||
23 | ->setTitle('CLI Menu > Options > Secret Options') |
||
24 | ->addItem('First secret option', function (CliMenu $menu) { |
||
25 | echo sprintf('Executing secret option: %s', $menu->getSelectedItem()->getText()); |
||
26 | }) |
||
27 | ->addLineBreak('-') |
||
28 | ->end() |
||
29 | ->addLineBreak('-') |
||
30 | ->end() |
||
31 | ->setWidth(70) |
||
32 | ->setBackgroundColour('yellow') |
||
33 | ->build(); |
||
34 | |||
35 | $menu->open(); |
||
36 |
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: