1 | <?php |
||
12 | class ConfigProcessor |
||
13 | { |
||
14 | protected $processedConfig = []; |
||
15 | protected $unprocessedConfig = []; |
||
16 | protected $nameOfItemsToMerge = []; |
||
17 | protected $expander; |
||
18 | |||
19 | public function __construct($expander = null) |
||
23 | |||
24 | /** |
||
25 | * By default, string config items always REPLACE, not MERGE when added |
||
26 | * from different sources. This method will allow applications to alter |
||
27 | * this behavior for specific items so that strings from multiple sources |
||
28 | * will be merged together into an array instead. |
||
29 | */ |
||
30 | public function useMergeStrategyForKeys($itemName) |
||
39 | |||
40 | /** |
||
41 | * Extend the configuration to be processed with the |
||
42 | * configuration provided by the specified loader. |
||
43 | * |
||
44 | * @param ConfigLoaderInterface $loader |
||
45 | */ |
||
46 | public function extend(ConfigLoaderInterface $loader) |
||
50 | |||
51 | /** |
||
52 | * Extend the configuration to be processed with |
||
53 | * the provided nested array. |
||
54 | * |
||
55 | * @param array $data |
||
56 | */ |
||
57 | public function add($data) |
||
62 | |||
63 | /** |
||
64 | * Extend the configuration to be processed with |
||
65 | * the provided nested array. Also record the name |
||
66 | * of the data source, if applicable. |
||
67 | * |
||
68 | * @param array $data |
||
69 | * @param string $source |
||
70 | */ |
||
71 | protected function addFromSource($data, $source = '') |
||
79 | |||
80 | /** |
||
81 | * Process all of the configuration that has been collected, |
||
82 | * and return a nested array. |
||
83 | * |
||
84 | * @return array |
||
85 | */ |
||
86 | public function export($referenceArray = []) |
||
97 | |||
98 | /** |
||
99 | * To aid in debugging: return the source of each configuration item. |
||
100 | * n.b. Must call this function *before* export and save the result |
||
101 | * if persistence is desired. |
||
102 | */ |
||
103 | public function sources() |
||
114 | |||
115 | /** |
||
116 | * Get the configuration to be processed, and clear out the |
||
117 | * 'unprocessed' list. |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | protected function fetchUnprocessed() |
||
127 | |||
128 | /** |
||
129 | * Use a map-reduce to evaluate the items to be processed, |
||
130 | * and merge them into the processed array. |
||
131 | * |
||
132 | * @param array $processed |
||
133 | * @param array $toBeProcessed |
||
134 | * @return array |
||
135 | */ |
||
136 | protected function process(array $processed, array $toBeProcessed, $referenceArray = []) |
||
142 | |||
143 | /** |
||
144 | * Process a single configuration file from the 'to be processed' |
||
145 | * list. By default this is a no-op. Override this method to |
||
146 | * provide any desired configuration preprocessing, e.g. dot-notation |
||
147 | * expansion of the configuration keys, etc. |
||
148 | * |
||
149 | * @param array $config |
||
150 | * @return array |
||
151 | */ |
||
152 | protected function preprocess(array $config) |
||
156 | |||
157 | /** |
||
158 | * Evaluate one item in the 'to be evaluated' list, and then |
||
159 | * merge it into the processed configuration (the 'carry'). |
||
160 | * |
||
161 | * @param array $processed |
||
162 | * @param array $config |
||
163 | * @return array |
||
164 | */ |
||
165 | protected function reduceOne(array $processed, array $config) |
||
169 | |||
170 | /** |
||
171 | * Evaluate one configuration item. |
||
172 | * |
||
173 | * @param array $processed |
||
|
|||
174 | * @param array $config |
||
175 | * @return array |
||
176 | */ |
||
177 | protected function evaluate(array $config, $referenceArray = []) |
||
184 | } |
||
185 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.