rector/rules/DowngradePhp72/snippet/isatty_closure.php.inc
Tomas Votruba ecb71886c6 Updated Rector to commit 478f5c87c75b5fd23276c5a542c4bc1f104c870b
478f5c87c7 Improve DowngradeStreamIsattyRector when stream_isatty is available (#61)
2021-05-18 22:27:49 +00:00

22 lines
577 B
PHP

<?php
function ($stream) {
if (\function_exists('stream_isatty')) {
return stream_isatty($stream);
}
if (!\is_resource($stream)) {
trigger_error('stream_isatty() expects parameter 1 to be resource, '.\gettype($stream).' given', \E_USER_WARNING);
return false;
}
if ('\\' === \DIRECTORY_SEPARATOR) {
$stat = @fstat($stream);
// Check if formatted mode is S_IFCHR
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
}
return \function_exists('posix_isatty') && @posix_isatty($stream);
};