/var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Console
Edit: /var/www/vhosts/ihelp.ro/_OLD/vendor/cakephp/cakephp/src/Console/ConsoleInput.php (2875B)
_canReadline = (extension_loaded('readline') && $handle === 'php://stdin');
$this->_input = fopen($handle, 'rb');
}
/**
* Read a value from the stream
*
* @return string|null The value of the stream. Null on EOF.
*/
public function read(): ?string
{
if ($this->_canReadline) {
/** @var string|false $line */
$line = readline('');
if ($line !== false && strlen($line) > 0) {
readline_add_history($line);
}
} else {
$line = fgets($this->_input);
}
if ($line === false) {
return null;
}
return $line;
}
/**
* Check if data is available on stdin
*
* @param int $timeout An optional time to wait for data
* @return bool True for data available, false otherwise
*/
public function dataAvailable(int $timeout = 0): bool
{
$readFds = [$this->_input];
$writeFds = null;
$errorFds = null;
/** @var string|null $error */
$error = null;
set_error_handler(function (int $code, string $message) use (&$error) {
$error = "stream_select failed with code={$code} message={$message}.";
});
$readyFds = stream_select($readFds, $writeFds, $errorFds, $timeout);
restore_error_handler();
if ($error !== null) {
throw new ConsoleException($error);
}
return $readyFds > 0;
}
}