@@ -87,7 +87,7 @@ public function askConfirmation(OutputInterface $output, $question, $default = t
87
87
public function askHiddenResponse (OutputInterface $ output , $ question , $ fallback = true )
88
88
{
89
89
if (defined ('PHP_WINDOWS_VERSION_BUILD ' )) {
90
- $ exe = __DIR__ . '\\ hiddeninput.exe ' ;
90
+ $ exe = __DIR__ . '/ hiddeninput.exe ' ;
91
91
92
92
// handle code running from a phar
93
93
if ('phar: ' === substr (__FILE__ , 0 , 5 )) {
@@ -105,15 +105,17 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
105
105
}
106
106
107
107
return $ value ;
108
- } elseif ($ this ->hasSttyAvailable ()) {
108
+ }
109
+
110
+ if ($ this ->hasSttyAvailable ()) {
109
111
110
112
$ output ->write ($ question );
111
113
112
114
$ sttyMode = shell_exec ('/usr/bin/env stty -g ' );
113
115
114
116
shell_exec ('/usr/bin/env stty -echo ' );
115
117
$ value = fgets ($ this ->inputStream ?: STDIN , 4096 );
116
- shell_exec (sprintf ('/usr/bin/env stty %s ' , escapeshellarg ( $ sttyMode) ));
118
+ shell_exec (sprintf ('/usr/bin/env stty %s ' , $ sttyMode ));
117
119
118
120
if (false === $ value ) {
119
121
throw new \RuntimeException ('Aborted ' );
@@ -123,7 +125,9 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
123
125
$ output ->writeln ('' );
124
126
125
127
return $ value ;
126
- } elseif (false !== $ shell = $ this ->getShell ()) {
128
+ }
129
+
130
+ if (false !== $ shell = $ this ->getShell ()) {
127
131
128
132
$ output ->write ($ question );
129
133
$ readCmd = $ shell === 'csh ' ? 'set mypassword = $< ' : 'read mypassword ' ;
@@ -132,7 +136,9 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
132
136
$ output ->writeln ('' );
133
137
134
138
return $ value ;
135
- } elseif ($ fallback ) {
139
+ }
140
+
141
+ if ($ fallback ) {
136
142
return $ this ->ask ($ output , $ question );
137
143
}
138
144
@@ -158,8 +164,10 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
158
164
*/
159
165
public function askAndValidate (OutputInterface $ output , $ question , $ validator , $ attempts = false , $ default = null )
160
166
{
161
- $ interviewer = function () use ($ output , $ question , $ default ) {
162
- return $ this ->ask ($ output , $ question , $ default );
167
+ $ that = $ this ;
168
+
169
+ $ interviewer = function () use ($ output , $ question , $ default , $ that ) {
170
+ return $ that ->ask ($ output , $ question , $ default );
163
171
};
164
172
165
173
return $ this ->validateAttempts ($ interviewer , $ output , $ validator , $ attempts );
@@ -186,8 +194,10 @@ public function askAndValidate(OutputInterface $output, $question, $validator, $
186
194
*/
187
195
public function askHiddenResponseAndValidate (OutputInterface $ output , $ question , $ validator , $ attempts = false , $ fallback = true )
188
196
{
189
- $ interviewer = function () use ($ output , $ question , $ fallback ) {
190
- return $ this ->askHiddenResponse ($ output , $ question , $ fallback );
197
+ $ that = $ this ;
198
+
199
+ $ interviewer = function () use ($ output , $ question , $ fallback , $ that ) {
200
+ return $ that ->askHiddenResponse ($ output , $ question , $ fallback );
191
201
};
192
202
3FCB
193
203
return $ this ->validateAttempts ($ interviewer , $ output , $ validator , $ attempts );
0 commit comments