8000 Fix tests and CS · symfony/symfony@ac01d5d · GitHub
[go: up one dir, main page]

Skip to content

Commit ac01d5d

Browse files
committed
Fix tests and CS
1 parent e396edb commit ac01d5d

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/Symfony/Component/Console/Helper/DialogHelper.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function askConfirmation(OutputInterface $output, $question, $default = t
8787
public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
8888
{
8989
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
90-
$exe = __DIR__ . '\\hiddeninput.exe';
90+
$exe = __DIR__ . '/hiddeninput.exe';
9191

9292
// handle code running from a phar
9393
if ('phar:' === substr(__FILE__, 0, 5)) {
@@ -105,15 +105,17 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
105105
}
106106

107107
return $value;
108-
} elseif ($this->hasSttyAvailable()) {
108+
}
109+
110+
if ($this->hasSttyAvailable()) {
109111

110112
$output->write($question);
111113

112114
$sttyMode = shell_exec('/usr/bin/env stty -g');
113115

114116
shell_exec('/usr/bin/env stty -echo');
115117
$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));
117119

118120
if (false === $value) {
119121
throw new \RuntimeException('Aborted');
@@ -123,7 +125,9 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
123125
$output->writeln('');
124126

125127
return $value;
126-
} elseif (false !== $shell = $this->getShell()) {
128+
}
129+
130+
if (false !== $shell = $this->getShell()) {
127131

128132
$output->write($question);
129133
$readCmd = $shell === 'csh' ? 'set mypassword = $<' : 'read mypassword';
@@ -132,7 +136,9 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
132136
$output->writeln('');
133137

134138
return $value;
135-
} elseif ($fallback) {
139+
}
140+
141+
if ($fallback) {
136142
return $this->ask($output, $question);
137143
}
138144

@@ -158,8 +164,10 @@ public function askHiddenResponse(OutputInterface $output, $question, $fallback
158164
*/
159165
public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null)
160166
{
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);
163171
};
164172

165173
return $this->validateAttempts($interviewer, $output, $validator, $attempts);
@@ -186,8 +194,10 @@ public function askAndValidate(OutputInterface $output, $question, $validator, $
186194
*/
187195
public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
188196
{
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);
191201
};
192202 3FCB

193203
return $this->validateAttempts($interviewer, $output, $validator, $attempts);

0 commit comments

Comments
 (0)
0