@@ -43,30 +43,32 @@ public static function spinner(): void
4343
4444 /**
4545 * Uses `stty` to hide input/output completely.
46+ *
4647 * @param boolean $hidden Will hide/show the next data. Defaults to true.
4748 */
48- public static function hide ($ hidden = true ): void
49+ public static function hide (bool $ hidden = true ): void
4950 {
5051 system ('stty ' . ($ hidden ? '-echo ' : 'echo ' ));
5152 }
5253
5354 /**
5455 * Prompts the user for input. Optionally masking it.
5556 *
56- * @param string $prompt The prompt to show the user
57- * @param bool $masked If true, the users input will not be shown. e.g. password input
58- * @param int $limit The maximum amount of input to accept
57+ * @param string $prompt The prompt to show the user
58+ * @param bool $masked If true, the users input will not be shown. e.g. password input
59+ * @param int $limit The maximum amount of input to accept
60+ *
5961 * @return string
6062 */
61- public static function prompt ($ prompt , $ masked= false , $ limit =100 )
63+ public static function prompt (string $ prompt , bool $ masked, int $ limit =100 ): string
6264 {
6365 echo "$ prompt: " ;
6466 if ($ masked ) {
6567 `stty -echo `; // disable shell echo
6668 }
6769 $ buffer = '' ;
6870 $ char = '' ;
69- $ f = fopen ('php://stdin ' , 'r ' );
71+ $ f = fopen ('php://stdin ' , 'rb ' );
7072 while (strlen ($ buffer ) < $ limit ) {
7173 $ char = fread ($ f , 1 );
7274 if ($ char === "\n" || $ char === "\r" ) {
@@ -89,6 +91,7 @@ public static function prompt($prompt, $masked=false, $limit=100)
8991echo $ input ;
9092die;
9193
94+ /** @noinspection PhpUnreachableStatementInspection */
9295$ total = random_int (5000 , 10000 );
9396for ($ x =1 ; $ x <=$ total ; $ x ++) {
9497 Status::spinner ();
0 commit comments