1 | <?php |
||
22 | abstract class AbstractAnsibleCommand |
||
23 | { |
||
24 | /** |
||
25 | * @var ProcessBuilder |
||
26 | */ |
||
27 | protected $processBuilder; |
||
28 | |||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | private $options; |
||
33 | |||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | private $parameters; |
||
38 | |||
39 | /** |
||
40 | * @var array |
||
41 | */ |
||
42 | private $baseOptions; |
||
43 | |||
44 | /** |
||
45 | * @param ProcessBuilder $processBuilder |
||
46 | */ |
||
47 | public function __construct(ProcessBuilder $processBuilder) |
||
54 | |||
55 | /** |
||
56 | * Get parameter string which will be used to call ansible. |
||
57 | * |
||
58 | * @param bool $asArray |
||
59 | * @return string[] |
||
60 | */ |
||
61 | protected function prepareArguments(bool $asArray = true) |
||
75 | |||
76 | /** |
||
77 | * Add an Option. |
||
78 | * |
||
79 | * @param string $name |
||
80 | * @param string $value |
||
81 | */ |
||
82 | protected function addOption(string $name, string $value): void |
||
86 | |||
87 | /** |
||
88 | * Add a parameter. |
||
89 | * |
||
90 | * @param string $name |
||
91 | */ |
||
92 | protected function addParameter(string $name): void |
||
96 | |||
97 | /** |
||
98 | * Get all options as array. |
||
99 | * |
||
100 | * @return array |
||
101 | */ |
||
102 | protected function getOptions(): array |
||
112 | |||
113 | /** |
||
114 | * Get all parameters as array. |
||
115 | * |
||
116 | * @return array |
||
117 | */ |
||
118 | protected function getParameters(): array |
||
122 | |||
123 | |||
124 | /** |
||
125 | * Add base options to internal storage. |
||
126 | * |
||
127 | * @param string $baseOption |
||
128 | * @return $this |
||
129 | */ |
||
130 | protected function addBaseoption(string $baseOption) |
||
136 | |||
137 | /** |
||
138 | * Generate base options string. |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | protected function getBaseOptions(): string |
||
146 | |||
147 | /** |
||
148 | * Check if param is array or string and implode with glue if necessary. |
||
149 | * |
||
150 | * @param string|array $param |
||
151 | * @param string $glue |
||
152 | * @return string |
||
153 | */ |
||
154 | protected function checkParam($param, string $glue = ' '): string |
||
162 | |||
163 | /** |
||
164 | * Creates process with processBuilder builder and executes it. |
||
165 | * |
||
166 | * @param null $callback |
||
167 | * @return int|string |
||
168 | */ |
||
169 | protected function runProcess($callback) |
||
191 | } |
||
192 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.