1 | <?php |
||
11 | class Builder |
||
12 | { |
||
13 | /** @var array */ |
||
14 | protected $questions = []; |
||
15 | |||
16 | /** @var array */ |
||
17 | protected $config = []; |
||
18 | |||
19 | /** @var string */ |
||
20 | protected $envFile; |
||
21 | |||
22 | /** @var EnvLoader */ |
||
23 | protected $envLoader; |
||
24 | |||
25 | /** @var EnvWriter */ |
||
26 | protected $envWriter; |
||
27 | |||
28 | /** @var IO */ |
||
29 | protected $io; |
||
30 | |||
31 | /** @var array */ |
||
32 | protected $answers = []; |
||
33 | |||
34 | |||
35 | /** |
||
36 | * Application constructor. |
||
37 | * |
||
38 | * This builds with the CLImateInterface as a default, but this |
||
39 | * can be overridden by the setIOHandler() method. |
||
40 | * |
||
41 | * @throws ConfigurationException |
||
42 | * @param string $envFile |
||
43 | * @param array $config |
||
44 | */ |
||
45 | public function __construct(string $envFile, array $config = []) |
||
60 | |||
61 | /** |
||
62 | * Set some of the optional config elements. |
||
63 | * |
||
64 | * @throws ConfigurationException |
||
65 | * @param array $config |
||
66 | */ |
||
67 | public function setConfig(array $config) |
||
85 | |||
86 | /** |
||
87 | * Get the Builder's configuration options. |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | public function getConfig() |
||
95 | |||
96 | /** |
||
97 | * Set the EnvLoader. |
||
98 | * |
||
99 | * @param EnvLoader $envLoader |
||
100 | */ |
||
101 | public function setEnvLoader(EnvLoader $envLoader) |
||
105 | |||
106 | /** |
||
107 | * Add in an IOHanderInterface object. |
||
108 | * |
||
109 | * @param IOHandlerInterface $ioHandler |
||
110 | */ |
||
111 | public function setIOHandler(IOHandlerInterface $ioHandler) |
||
115 | |||
116 | /** |
||
117 | * Set the IO. |
||
118 | * |
||
119 | * @param IO $io |
||
120 | */ |
||
121 | public function setIO(IO $io) |
||
125 | |||
126 | /** |
||
127 | * Override the EnvWriter. |
||
128 | * |
||
129 | * @param EnvWriter $envWriter |
||
130 | */ |
||
131 | public function setEnvWriter(EnvWriter $envWriter) |
||
135 | |||
136 | /** |
||
137 | * Run the builder |
||
138 | * |
||
139 | * @throws \Exception |
||
140 | * @return array |
||
141 | */ |
||
142 | public function run() |
||
159 | |||
160 | /** |
||
161 | * Write the answers to a file. |
||
162 | * |
||
163 | * @return bool The status of the write operation. |
||
164 | */ |
||
165 | public function write() |
||
177 | |||
178 | /** |
||
179 | * Set a question to ask the user. |
||
180 | * |
||
181 | * @param string $name The name of the env variable to read/use |
||
182 | * @param string $prompt The prompt you want to give the user |
||
183 | * @param string $default A default answer, if any. |
||
184 | * @param bool $required Is a response required? |
||
185 | */ |
||
186 | public function ask($name, $prompt, $default = '', $required = false) |
||
194 | |||
195 | /** |
||
196 | * Return all of the questions. |
||
197 | * |
||
198 | * @return array |
||
199 | */ |
||
200 | public function getQuestions() |
||
204 | } |
||
205 |
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.