File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -614,7 +614,7 @@ Returns current timestamp in UTC timezone in ISO8601 format.
614614## quote()
615615
616616``` php
617- quote(string $arg): string
617+ quote(string|int $arg): string
618618```
619619
620620Quotes a string for safe use as a shell argument using ANSI-C $'...' syntax.
Original file line number Diff line number Diff line change @@ -992,8 +992,9 @@ function timestamp(): string
992992 * run('echo ' . quote("it's a test")); // echo $'it\'s a test'
993993 * ```
994994 */
995- function quote (string $ arg ): string
995+ function quote (string | int $ arg ): string
996996{
997+ $ arg = (string ) $ arg ;
997998 if ($ arg === '' ) {
998999 return "\$'' " ;
9991000 }
Original file line number Diff line number Diff line change @@ -127,4 +127,24 @@ public function testShellInjectionAttempts()
127127 self ::assertEquals ("\$'`rm -rf /`' " , quote ('`rm -rf /` ' ));
128128 self ::assertEquals ("\$' \$(cat /etc/passwd)' " , quote ('$(cat /etc/passwd) ' ));
129129 }
130+
131+ public function testIntPositive ()
132+ {
133+ self ::assertEquals ('42 ' , quote (42 ));
134+ }
135+
136+ public function testIntZero ()
137+ {
138+ self ::assertEquals ('0 ' , quote (0 ));
139+ }
140+
141+ public function testIntNegative ()
142+ {
143+ self ::assertEquals ('-7 ' , quote (-7 ));
144+ }
145+
146+ public function testIntMax ()
147+ {
148+ self ::assertEquals ((string ) PHP_INT_MAX , quote (PHP_INT_MAX ));
149+ }
130150}
You can’t perform that action at this time.
0 commit comments