@@ -106,7 +106,11 @@ private function parseJsonFile(string $configFilePath):object {
106106 }
107107
108108 private function parseIniFile (string $ configFilePath ):object {
109- $ ini = @parse_ini_file ($ configFilePath , true , INI_SCANNER_RAW );
109+ set_error_handler (static function ():bool {
110+ return true ;
111+ });
112+ $ ini = parse_ini_file ($ configFilePath , true , INI_SCANNER_RAW );
113+ restore_error_handler ();
110114 if ($ ini === false ) {
111115 throw new ConfigurationParseException ("Syntax error " );
112116 }
@@ -169,36 +173,13 @@ private function parseExecuteString(string $executeString):object {
169173 $ length = strlen ($ executeString );
170174
171175 for ($ i = 0 ; $ i < $ length ; $ i ++) {
172- $ char = $ executeString [$ i ];
173-
174- if ($ quote !== null ) {
175- if ($ char === $ quote ) {
176- $ quote = null ;
177- }
178- else {
179- $ currentToken .= $ char ;
180- }
181- $ tokenInProgress = true ;
182- continue ;
183- }
184-
185- if ($ char === "' " || $ char === '" ' ) {
186- $ quote = $ char ;
187- $ tokenInProgress = true ;
188- continue ;
189- }
190-
191- if (ctype_space ($ char )) {
192- if ($ tokenInProgress ) {
193- $ tokens []= $ currentToken ;
194- $ currentToken = "" ;
195- $ tokenInProgress = false ;
196- }
197- continue ;
198- }
199-
200- $ currentToken .= $ char ;
201- $ tokenInProgress = true ;
176+ $ this ->consumeExecuteCharacter (
177+ $ executeString [$ i ],
178+ $ tokens ,
179+ $ currentToken ,
180+ $ quote ,
181+ $ tokenInProgress ,
182+ );
202183 }
203184
204185 if ($ quote !== null ) {
@@ -219,6 +200,77 @@ private function parseExecuteString(string $executeString):object {
219200 return $ execute ;
220201 }
221202
203+ /**
204+ * @param array<int, string> $tokens
205+ * @param string|null $quote
206+ */
207+ private function consumeExecuteCharacter (
208+ string $ char ,
209+ array &$ tokens ,
210+ string &$ currentToken ,
211+ ?string &$ quote ,
212+ bool &$ tokenInProgress ,
213+ ):void {
214+ if ($ quote !== null ) {
215+ $ this ->consumeQuotedExecuteCharacter (
216+ $ char ,
217+ $ currentToken ,
218+ $ quote ,
219+ $ tokenInProgress ,
220+ );
221+ return ;
222+ }
223+
224+ if ($ char === "' " || $ char === '" ' ) {
225+ $ quote = $ char ;
226+ $ tokenInProgress = true ;
227+ return ;
228+ }
229+
230+ if (ctype_space ($ char )) {
231+ $ this ->finaliseExecuteToken (
232+ $ tokens ,
233+ $ currentToken ,
234+ $ tokenInProgress ,
235+ );
236+ return ;
237+ }
238+
239+ $ currentToken .= $ char ;
240+ $ tokenInProgress = true ;
241+ }
242+
243+ private function consumeQuotedExecuteCharacter (
244+ string $ char ,
245+ string &$ currentToken ,
246+ ?string &$ quote ,
247+ bool &$ tokenInProgress ,
248+ ):void {
249+ if ($ char === $ quote ) {
250+ $ quote = null ;
251+ }
252+ else {
253+ $ currentToken .= $ char ;
254+ }
255+
256+ $ tokenInProgress = true ;
257+ }
258+
259+ /** @param array<int, string> $tokens */
260+ private function finaliseExecuteToken (
261+ array &$ tokens ,
262+ string &$ currentToken ,
263+ bool &$ tokenInProgress ,
264+ ):void {
265+ if (!$ tokenInProgress ) {
266+ return ;
267+ }
268+
269+ $ tokens []= $ currentToken ;
270+ $ currentToken = "" ;
271+ $ tokenInProgress = false ;
272+ }
273+
222274 private function recursiveMerge (object $ json , object $ diff ):object {
223275 foreach ($ diff as $ key => $ value ) {
224276 if (property_exists ($ json , $ key )) {
0 commit comments