Test Setup Failed
Push — upgrade-cakephp4 ( 25b5b0 )
by giu
04:14
created

ConsoleShell::_getOptionParser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.9666
1
<?php
2
/**
3
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
4
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
5
 *
6
 * Licensed under The MIT License
7
 * For full copyright and license information, please see the LICENSE.txt
8
 * Redistributions of files must retain the above copyright notice.
9
 *
10
 * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
11
 * @link      http://cakephp.org CakePHP(tm) Project
12
 * @since     3.0.0
13
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
14
 */
15
namespace App\Shell;
16
17
use Cake\Console\ConsoleOptionParser;
18
use Cake\Console\Shell;
19
use Cake\Log\Log;
20
use Psy\Shell as PsyShell;
21
22
/**
23
 * Simple console wrapper around Psy\Shell.
24
 */
25
class ConsoleShell extends Shell
0 ignored issues
show
Deprecated Code introduced by
The class Cake\Console\Shell has been deprecated: 3.6.0 ShellDispatcher and Shell will be removed in 5.0 ( Ignorable by Annotation )

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

25
class ConsoleShell extends /** @scrutinizer ignore-deprecated */ Shell
Loading history...
26
{
27
28
    /**
29
     * Start the shell and interactive console.
30
     *
31
     * @return int|null
32
     */
33
    public function main()
34
    {
35
        if (!class_exists('Psy\Shell')) {
36
            $this->err('<error>Unable to load Psy\Shell.</error>');
37
            $this->err('');
38
            $this->err('Make sure you have installed psysh as a dependency,');
39
            $this->err('and that Psy\Shell is registered in your autoloader.');
40
            $this->err('');
41
            $this->err('If you are using composer run');
42
            $this->err('');
43
            $this->err('<info>$ php composer.phar require --dev psy/psysh</info>');
44
            $this->err('');
45
46
            return self::CODE_ERROR;
47
        }
48
49
        $this->out("You can exit with <info>`CTRL-C`</info> or <info>`exit`</info>");
50
        $this->out('');
51
52
        Log::drop('debug');
53
        Log::drop('error');
54
        $this->_io->setLoggers(false);
55
        restore_error_handler();
56
        restore_exception_handler();
57
58
        $psy = new PsyShell();
59
        $psy->run();
60
    }
61
62
    /**
63
     * Display help for this console.
64
     *
65
     * @return \Cake\Console\ConsoleOptionParser
66
     */
67
    public function _getOptionParser()
68
    {
69
        $parser = new ConsoleOptionParser('console');
70
        $parser->description(
0 ignored issues
show
Bug introduced by
The method description() does not exist on Cake\Console\ConsoleOptionParser. ( Ignorable by Annotation )

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

70
        $parser->/** @scrutinizer ignore-call */ 
71
                 description(

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...
71
            'This shell provides a REPL that you can use to interact ' .
72
            'with your application in an interactive fashion. You can use ' .
73
            'it to run adhoc queries with your models, or experiment ' .
74
            'and explore the features of CakePHP and your application.' .
75
            "\n\n" .
76
            'You will need to have psysh installed for this Shell to work.'
77
        );
78
79
        return $parser;
80
    }
81
}
82