@@ -10,13 +10,14 @@ class Converter
1010
1111 public const CHECK_OPTIONS_TAG = '@TODO CHECK OPTIONS ' ;
1212
13+ public static bool $ escapeWithDoubleEncode = false ;
14+
1315 protected static string $ indent = '' ;
1416
1517 protected static bool $ hasComments = false ;
1618
1719 /**
18- * @param array<SplFileInfo> $files
19- * @return int
20+ * @param array<SplFileInfo> $files
2021 */
2122 public static function execute (array $ files ): int
2223 {
@@ -48,7 +49,7 @@ public static function execute(array $files): int
4849 } elseif ($ formBuilderMethod === 'close ' ) {
4950 $ result = static ::buildFormClose ();
5051
51- } elseif (in_array ($ formBuilderMethod , ['label ' , 'labelRequired ' ])) {
52+ } elseif (\ in_array ($ formBuilderMethod , ['label ' , 'labelRequired ' ])) {
5253 $ result = static ::buildLabel (
5354 $ formBuilderArgs [0 ],
5455 $ formBuilderArgs [1 ] ?? '' ,
@@ -57,7 +58,7 @@ public static function execute(array $files): int
5758 $ formBuilderMethod === 'labelRequired '
5859 );
5960
60- } elseif (in_array ($ formBuilderMethod , ['input ' , 'text ' , 'number ' , 'date ' , 'time ' , 'datetime ' , 'week ' , 'month ' , 'range ' , 'search ' , 'email ' , 'tel ' , 'url ' , 'color ' , 'hidden ' ])) {
61+ } elseif (\ in_array ($ formBuilderMethod , ['input ' , 'text ' , 'number ' , 'date ' , 'time ' , 'datetime ' , 'week ' , 'month ' , 'range ' , 'search ' , 'email ' , 'tel ' , 'url ' , 'color ' , 'hidden ' ])) {
6162 if ($ formBuilderMethod === 'input ' ) {
6263 $ formBuilderMethod = trim (array_shift ($ formBuilderArgs ), '\'" ' );
6364 }
@@ -70,7 +71,7 @@ public static function execute(array $files): int
7071 $ formBuilderArgs [2 ] ?? ''
7172 );
7273
73- } elseif (in_array ($ formBuilderMethod , ['checkbox ' , 'radio ' ])) {
74+ } elseif (\ in_array ($ formBuilderMethod , ['checkbox ' , 'radio ' ])) {
7475 $ result = static ::buildDefaultInput (
7576 $ formBuilderMethod ,
7677 $ formBuilderArgs [0 ],
@@ -79,7 +80,7 @@ public static function execute(array $files): int
7980 $ formBuilderArgs [3 ] ?? ''
8081 );
8182
82- } elseif (in_array ($ formBuilderMethod , ['file ' , 'password ' ])) {
83+ } elseif (\ in_array ($ formBuilderMethod , ['file ' , 'password ' ])) {
8384 $ result = static ::buildNoValueInput (
8485 $ formBuilderMethod ,
8586 $ formBuilderArgs [0 ],
@@ -107,7 +108,7 @@ public static function execute(array $files): int
107108 $ formBuilderArgs [3 ] ?? ''
108109 );
109110
110- } elseif (in_array ($ formBuilderMethod , ['button ' , 'submit ' ])) {
111+ } elseif (\ in_array ($ formBuilderMethod , ['button ' , 'submit ' ])) {
111112 $ result = static ::buildButton (
112113 $ formBuilderMethod ,
113114 $ formBuilderArgs [0 ],
@@ -147,7 +148,7 @@ protected static function buildFormOpen(string $options): string
147148 $ method = $ extractedOptions ['method ' ];
148149 }
149150
150- if (in_array ($ method , ['PUT ' , 'PATCH ' , 'DELETE ' ])) {
151+ if (\ in_array ($ method , ['PUT ' , 'PATCH ' , 'DELETE ' ])) {
151152 $ attributes ['method ' ] = 'POST ' ;
152153 } else {
153154 $ attributes ['method ' ] = $ method ;
@@ -164,10 +165,10 @@ protected static function buildFormOpen(string $options): string
164165
165166 $ attributes ['action ' ] = 'route( ' .$ route ;
166167
167- if (count ($ routeArgs ) === 1 ) {
168+ if (\ count ($ routeArgs ) === 1 ) {
168169 $ attributes ['action ' ] .= ', ' .$ routeArgs [0 ];
169170
170- } elseif (count ($ routeArgs ) > 1 ) {
171+ } elseif (\ count ($ routeArgs ) > 1 ) {
171172 $ attributes ['action ' ] .= ', [ ' .implode (', ' , $ routeArgs ).'] ' ;
172173 }
173174
@@ -177,7 +178,7 @@ protected static function buildFormOpen(string $options): string
177178 }
178179
179180 if (isset ($ extractedOptions ['files ' ])) {
180- if (in_array (strtolower ($ extractedOptions ['files ' ]), ['true ' , '1 ' ])) {
181+ if (\ in_array (strtolower ($ extractedOptions ['files ' ]), ['true ' , '1 ' ])) {
181182 $ attributes ['enctype ' ] = "'multipart/form-data' " ;
182183
183184 } elseif (! static ::isEmpty ($ extractedOptions ['files ' ])) {
@@ -191,7 +192,7 @@ protected static function buildFormOpen(string $options): string
191192
192193 $ input = static ::$ indent .'<form ' .static ::buildHtmlTagAttributes ($ attributes ).'> ' ;
193194
194- if (! in_array ($ method , ['GET ' , 'POST ' , 'PUT ' , 'PATCH ' , 'DELETE ' ])) {
195+ if (! \ in_array ($ method , ['GET ' , 'POST ' , 'PUT ' , 'PATCH ' , 'DELETE ' ])) {
195196 $ input .= "\n" .static ::$ indent .' @if (strtoupper( ' .$ method .') !== \'GET \') ' ;
196197 $ input .= "\n" .static ::$ indent .' @csrf ' ;
197198 $ input .= "\n" .static ::$ indent .' @if (strtoupper( ' .$ method .') !== \'POST \') ' ;
@@ -252,7 +253,7 @@ protected static function buildDefaultInput(string $type, string $name, string $
252253 if (! static ::isEmpty ($ name )) {
253254 $ attributes ['name ' ] = $ name ;
254255
255- if (in_array ($ type , ['checkbox ' , 'radio ' ])) {
256+ if (\ in_array ($ type , ['checkbox ' , 'radio ' ])) {
256257 if (! static ::useOldHelper ($ checked ) && ! static ::isEmpty ($ value )) {
257258 $ checked = (! static ::isEmpty ($ checked ) ? '! old() ? ' .$ checked .' : ' : '' )
258259 .'in_array( ' .$ value .', (array) ' .static ::withOldHelperIfNeeded ($ name ).') ' ;
@@ -385,32 +386,33 @@ protected static function buildHtmlTagAttributes(array $attributes): string
385386 $ stringBefore = '' ;
386387 $ stringAfter = '' ;
387388
388- if (count ($ attributes ) > 1 ) {
389+ if (\ count ($ attributes ) > 1 ) {
389390 $ stringBefore = ' ' ;
390391 $ stringAfter = "\n" .static ::$ indent ;
391392
392393 $ builtAttributes .= $ stringAfter ;
393394
394- } elseif (count ($ attributes ) === 1 ) {
395+ } elseif (\ count ($ attributes ) === 1 ) {
395396 $ builtAttributes .= ' ' ;
396397 }
397398
398399 foreach ($ attributes as $ attrName => $ attrValue ) {
399400 if ($ attrName === static ::CHECK_OPTIONS_TAG ) {
400401 $ builtAttributes .= $ stringBefore .'{{-- ' .$ attrName .': ' .$ attrValue .' --}} ' .$ stringAfter ;
402+
401403 continue ;
402404 }
403405
404406 if (static ::isEmpty ($ attrValue )) {
405407 $ attrValue = '' ;
406408 }
407409
408- if (in_array ($ attrName , ['disabled ' , 'readonly ' , 'required ' , 'checked ' , 'multiple ' ])) {
410+ if (\ in_array ($ attrName , ['disabled ' , 'readonly ' , 'required ' , 'checked ' , 'multiple ' ])) {
409411 if ($ attrValue === '' ) {
410412 continue ;
411413 }
412414
413- if (in_array (strtolower ($ attrValue ), ['true ' , '1 ' , $ attrName ])) {
415+ if (\ in_array (strtolower ($ attrValue ), ['true ' , '1 ' , $ attrName ])) {
414416 $ attr = $ attrName ;
415417 } elseif ($ attrName === 'multiple ' ) {
416418 $ attr = '@if ( ' .$ attrValue .') multiple @endif ' ;
@@ -421,7 +423,7 @@ protected static function buildHtmlTagAttributes(array $attributes): string
421423 } elseif ($ attrName === 'class ' && preg_match ('/^\s*(\[\s*.*\s*\])\s*$/Us ' , $ attrValue , $ matches )) {
422424 $ attr = $ attrName .'="{!! implode( \' \', ' .$ matches [1 ].') !!}" ' ;
423425
424- } elseif (is_string ($ attrName )) {
426+ } elseif (\ is_string ($ attrName )) {
425427 $ attr = $ attrName .'=" ' .static ::withEscapedEchoIfNeeded ($ attrValue ).'" ' ;
426428
427429 } else {
@@ -441,7 +443,7 @@ protected static function canUseNameAsId(string $name): bool
441443
442444 protected static function isEmpty (string $ value ): bool
443445 {
444- return empty ($ value ) || in_array (strtolower ($ value ), ["'' " , '"" ' , 'false ' , 'null ' ]);
446+ return empty ($ value ) || \ in_array (strtolower ($ value ), ["'' " , '"" ' , 'false ' , 'null ' ]);
445447 }
446448
447449 /**
@@ -594,7 +596,6 @@ protected static function extractArrayFromString(string $string): array
594596
595597 } elseif (strpos ($ segment , '=> ' ) !== false ) {
596598 throw new ConverterException ();
597-
598599 } else {
599600 $ array [] = $ segment ;
600601 }
0 commit comments