Completed
Push — develop ( 3c1b70...55bb1b )
by Tom
03:03
created

Magento1Initializer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace N98\Magento\Application;
4
5
use RuntimeException;
6
use Symfony\Component\Console\Helper\FormatterHelper;
7
use Symfony\Component\Console\Helper\HelperSet;
8
use Symfony\Component\Console\Output\ConsoleOutput;
9
10
class Magento1Initializer
11
{
12
    /**
13
     * @var \Symfony\Component\Console\Helper\HelperSet
14
     */
15
    private $helperSet;
16
17
    /**
18
     * Magento1Initializer constructor.
19
     * @param \Symfony\Component\Console\Helper\HelperSet $helperSet
20
     */
21
    public function __construct(HelperSet $helperSet)
22
    {
23
        $this->helperSet = $helperSet;
24
    }
25
26
    /**
27
     * @return \N98\Magento\Framework\App\Magerun
28
     * @throws \Exception
29
     */
30
    public function init()
31
    {
32
        $magentoHint = <<<MAGENTOHINT
33
You are running a Magento 1.x instance. This version of n98-magerun is not compatible
34
with Magento 1.x. Please use n98-magerun (version 1) for this shop.
35
36
A current version of the software can be downloaded from the website:
37
38
<info>Download with curl
39
------------------</info>
40
41
    <comment>curl -O https://files.magerun.net/n98-magerun.phar</comment>
42
43
<info>Download with wget
44
------------------</info>
45
46
    <comment>wget https://files.magerun.net/n98-magerun.phar</comment>
47
48
MAGENTOHINT;
49
50
        $output = new ConsoleOutput();
51
52
        /** @var $formatter FormatterHelper */
53
        $formatter = $this->helperSet->get('formatter');
54
55
        $output->writeln([
0 ignored issues
show
Documentation introduced by
array('', $formatter->fo...rue), '', $magentoHint) is of type array<integer,string,{"0..."string","3":"string"}>, but the function expects a string|object<Symfony\Co...onsole\Output\iterable>.

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...
56
            '',
57
            $formatter->formatBlock('Compatibility Notice', 'bg=blue;fg=white', true),
58
            '',
59
            $magentoHint,
60
        ]);
61
62
        throw new RuntimeException('This version of n98-magerun is not compatible with Magento 1');
63
    }
64
}
65