1
|
|
|
<?php |
2
|
|
|
namespace TildBJ\Seeder\Utility; |
3
|
|
|
|
4
|
|
|
use TYPO3\CMS\Extbase\Mvc\Cli\ConsoleOutput; |
5
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
6
|
|
|
|
7
|
|
|
/*************************************************************** |
8
|
|
|
* |
9
|
|
|
* Copyright notice |
10
|
|
|
* |
11
|
|
|
* (c) 2017 Dennis Römmich <[email protected]> |
12
|
|
|
* |
13
|
|
|
* All rights reserved |
14
|
|
|
* |
15
|
|
|
* This script is part of the TYPO3 project. The TYPO3 project is |
16
|
|
|
* free software; you can redistribute it and/or modify |
17
|
|
|
* it under the terms of the GNU General Public License as published by |
18
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
19
|
|
|
* (at your option) any later version. |
20
|
|
|
* |
21
|
|
|
* The GNU General Public License can be found at |
22
|
|
|
* http://www.gnu.org/copyleft/gpl.html. |
23
|
|
|
* |
24
|
|
|
* This script is distributed in the hope that it will be useful, |
25
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
26
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
27
|
|
|
* GNU General Public License for more details. |
28
|
|
|
* |
29
|
|
|
* This copyright notice MUST APPEAR in all copies of the script! |
30
|
|
|
***************************************************************/ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Class OutputUtility |
34
|
|
|
* |
35
|
|
|
* @package Sunzinet\XmlExport\Utility |
36
|
|
|
*/ |
37
|
|
|
class OutputUtility implements \TYPO3\CMS\Core\SingletonInterface |
38
|
|
|
{ |
39
|
|
|
/** |
40
|
|
|
* output |
41
|
|
|
* |
42
|
|
|
* @var ConsoleOutput $output |
43
|
|
|
*/ |
44
|
|
|
protected $output; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* OutputUtility constructor. |
48
|
|
|
*/ |
49
|
|
|
public function __construct() |
50
|
|
|
{ |
51
|
|
|
$this->output = GeneralUtility::makeInstance(ConsoleOutput::class); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* log |
56
|
|
|
* |
57
|
|
|
* @param string $message |
58
|
|
|
*/ |
59
|
|
|
public function log($message) |
60
|
|
|
{ |
61
|
|
|
$this->output->outputLine($message); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $message |
66
|
|
|
*/ |
67
|
|
|
public function error($message) |
68
|
|
|
{ |
69
|
|
|
$this->log('<fg=red>' . $message . '</>'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $message |
74
|
|
|
*/ |
75
|
|
|
public function warning($message) |
76
|
|
|
{ |
77
|
|
|
$this->log('<fg=yellow>' . $message . '</>'); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string $message |
82
|
|
|
*/ |
83
|
|
|
public function success($message) |
84
|
|
|
{ |
85
|
|
|
$this->log('<fg=green>' . $message . '</>'); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @param string $message |
90
|
|
|
*/ |
91
|
|
|
public function info($message) |
92
|
|
|
{ |
93
|
|
|
$this->log('<fg=blue>' . $message . '</>'); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param $question |
98
|
|
|
* @param null $default |
99
|
|
|
* @param array|null $autocomplete |
100
|
|
|
* @return string |
101
|
|
|
*/ |
102
|
|
|
public function ask($question, $default = null, array $autocomplete = null) |
103
|
|
|
{ |
104
|
|
|
return $this->output->ask($question, $default, $autocomplete); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param $question |
109
|
|
|
* @param $choices |
110
|
|
|
* @param null $default |
111
|
|
|
* @param bool $multiSelect |
112
|
|
|
* @param bool $attempts |
113
|
|
|
* @return array|int|string |
114
|
|
|
*/ |
115
|
|
|
public function select($question, $choices, $default = null, $multiSelect = false, $attempts = false) |
116
|
|
|
{ |
117
|
|
|
return $this->output->select($question, $choices, $default, $multiSelect, $attempts); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @param null $max |
122
|
|
|
* @return void |
123
|
|
|
*/ |
124
|
|
|
public function progressStart($max = null) |
125
|
|
|
{ |
126
|
|
|
$this->output->progressStart($max); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @param int $step |
131
|
|
|
* @param bool $redraw |
132
|
|
|
* @return void |
133
|
|
|
*/ |
134
|
|
|
public function progressAdvance($step = 1, $redraw = false) |
135
|
|
|
{ |
136
|
|
|
$this->output->progressAdvance($step, $redraw); |
|
|
|
|
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param $current |
141
|
|
|
* @param bool $redraw |
142
|
|
|
* @return void |
143
|
|
|
*/ |
144
|
|
|
public function progressSet($current, $redraw = false) |
145
|
|
|
{ |
146
|
|
|
$this->output->progressSet($current, $redraw); |
|
|
|
|
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @return void |
151
|
|
|
*/ |
152
|
|
|
public function progressFinish() |
153
|
|
|
{ |
154
|
|
|
$this->output->progressFinish; |
|
|
|
|
155
|
|
|
} |
156
|
|
|
} |
157
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.