Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da99563

Browse files
Merge branch '5.4' into 6.2
* 5.4: [Translation] Fix handling of null messages in `ArrayLoader` [Console] Remove exec and replace it by shell_exec
2 parents 55aa350 + a349882 commit da99563

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

Helper/QuestionHelper.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -496,13 +496,11 @@ private function isInteractiveInput($inputStream): bool
496496
return self::$stdinIsInteractive = @posix_isatty(fopen('php://stdin', 'r'));
497497
}
498498

499-
if (!\function_exists('exec')) {
499+
if (!\function_exists('shell_exec')) {
500500
return self::$stdinIsInteractive = true;
501501
}
502502

503-
exec('stty 2> /dev/null', $output, $status);
504-
505-
return self::$stdinIsInteractive = 1 !== $status;
503+
return self::$stdinIsInteractive = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
506504
}
507505

508506
/**

Terminal.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,12 @@ public static function hasSttyAvailable(): bool
123123
return self::$stty;
124124
}
125125

126-
// skip check if exec function is disabled
127-
if (!\function_exists('exec')) {
126+
// skip check if shell_exec function is disabled
127+
if (!\function_exists('shell_exec')) {
128128
return false;
129129
}
130130

131-
exec('stty 2>&1', $output, $exitcode);
132-
133-
return self::$stty = 0 === $exitcode;
131+
return self::$stty = (bool) shell_exec('stty 2> '.('\\' === \DIRECTORY_SEPARATOR ? 'NUL' : '/dev/null'));
134132
}
135133

136134
private static function initDimensions()

Tests/Helper/QuestionHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ public function testAskHiddenResponse()
430430
$this->assertEquals('8AM', $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream("8AM\n")), $this->createOutputInterface(), $question));
431431
}
432432

433-
public function testAskHiddenResponseTrimmed()
433+
public function testAskHiddenResponseNotTrimmed()
434434
{
435435
if ('\\' === \DIRECTORY_SEPARATOR) {
436436
$this->markTestSkipped('This test is not supported on Windows');
@@ -442,7 +442,7 @@ public function testAskHiddenResponseTrimmed()
442442
$question->setHidden(true);
443443
$question->setTrimmable(false);
444444

445-
$this->assertEquals(' 8AM', $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream(' 8AM')), $this->createOutputInterface(), $question));
445+
$this->assertEquals(' 8AM'.\PHP_EOL, $dialog->ask($this->createStreamableInputInterfaceMock($this->getInputStream(' 8AM'.\PHP_EOL)), $this->createOutputInterface(), $question));
446446
}
447447

448448
public function testAskMultilineResponseWithEOF()

Tests/TerminalTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public function testSttyOnWindows()
7777
$this->markTestSkipped('Must be on windows');
7878
}
7979

80-
$sttyString = exec('(stty -a | grep columns) 2>&1', $output, $exitcode);
81-
if (0 !== $exitcode) {
80+
$sttyString = shell_exec('(stty -a | grep columns) 2> NUL');
81+
if (!$sttyString) {
8282
$this->markTestSkipped('Must have stty support');
8383
}
8484

0 commit comments

Comments
 (0)