1 | <?php |
||
37 | class JsonParser implements ConfigurationParserInterface |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * The key for the configuration snippet that contains the additional vendor directory configuration. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | const ADDITIONAL_VENDOR_DIRS = 'additional-vendor-dirs'; |
||
46 | |||
47 | /** |
||
48 | * The key with the libraries of the additional vendor directory. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | const LIBRARIES = 'libraries'; |
||
53 | |||
54 | /** |
||
55 | * The key with the absolut/relative path to the vendor directory. |
||
56 | * |
||
57 | * @var string |
||
58 | */ |
||
59 | const VENDOR_DIR = 'vendor-dir'; |
||
60 | |||
61 | /** |
||
62 | * The key for the flag to decide whether or not the vendor is relative to the installation directory. |
||
63 | * |
||
64 | * @var string |
||
65 | */ |
||
66 | const RELATIVE = 'relative'; |
||
67 | |||
68 | /** |
||
69 | * The utility class that provides array handling functionality. |
||
70 | * |
||
71 | * @var \TechDivision\Import\Configuration\Jms\Utils\ArrayUtilInterface |
||
72 | */ |
||
73 | protected $arrayUtil; |
||
74 | |||
75 | /** |
||
76 | * Initializes the parser with the array utility instance. |
||
77 | * |
||
78 | * @param \TechDivision\Import\Configuration\Jms\Utils\ArrayUtilInterface $arrayUtil The utility instance |
||
79 | */ |
||
80 | public function __construct(ArrayUtilInterface $arrayUtil) |
||
84 | |||
85 | /** |
||
86 | * Parsing the configuration and merge it recursively. |
||
87 | * |
||
88 | * @param string $installationDir The assumed Magento installation directory |
||
89 | * @param string $defaultConfigurationDir The default configuration directory |
||
90 | * @param array $directories An array with diretories to parse |
||
91 | * |
||
92 | * @return string The parsed configuration as string |
||
93 | */ |
||
94 | public function parse(string $installationDir, string $defaultConfigurationDir, array $directories) : string |
||
111 | |||
112 | /** |
||
113 | * Process the passed directory and merges/replaces the found |
||
114 | * configurations into the passed main configuration. |
||
115 | * |
||
116 | * @param array $main The main configuration to merge/replace the found configurations into |
||
117 | * @param string $directory The directory to be parsed for addtional configuration files |
||
118 | * |
||
119 | * @return void |
||
120 | * @throws \Exception Is thrown if the configuration can not be loaded from the configuration files |
||
121 | */ |
||
122 | protected function process(array &$main, string $directory) : void |
||
137 | |||
138 | /** |
||
139 | * Process the configuration files found in the additional vendor directories |
||
140 | * and merge/replace its content in the also passed main configuration file. |
||
141 | * |
||
142 | * @param array $main The main configuration to merge/replace the additional configuration files to |
||
143 | * @param string $installationDir The assumed Magento installation directory |
||
144 | * @param string $defaultConfigurationDir The default configuration directory |
||
145 | * |
||
146 | * @return void |
||
147 | */ |
||
148 | protected function processAdditionalVendorDirs(array &$main, string $installationDir, string $defaultConfigurationDir) : void |
||
184 | |||
185 | /** |
||
186 | * Return's the array utility instance. |
||
187 | * |
||
188 | * @return \TechDivision\Import\Configuration\Jms\Utils\ArrayUtilInterface The utility instance |
||
189 | */ |
||
190 | protected function getArrayUtil() : ArrayUtilInterface |
||
194 | |||
195 | /** |
||
196 | * Replaces the values of the first array with the ones from the arrays |
||
197 | * that has been passed as additional arguments. |
||
198 | * |
||
199 | * @param array ...$arrays The arrays with the values that has to be replaced |
||
200 | * |
||
201 | * @return array The array with the replaced values |
||
202 | */ |
||
203 | protected function replace(...$arrays) |
||
207 | |||
208 | /** |
||
209 | * List the filenames of a directory. |
||
210 | * |
||
211 | * @param string $directory The directory to list |
||
212 | * @param string $suffix The suffix of the files to list |
||
213 | * |
||
214 | * @return array A list of filenames |
||
215 | */ |
||
216 | protected function listContents($directory = '', $suffix = '.*') |
||
243 | } |
||
244 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.