Merge 1.x into master #2

Merged
sikofitt merged 18 commits from 1.x into master 2022-05-17 11:15:18 -07:00
2 changed files with 553 additions and 401 deletions
Showing only changes of commit 6405f1c7b9 - Show all commits

947
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -72,13 +72,13 @@ final class Getch
if (null === self::$ffi) { if (null === self::$ffi) {
$osFamily = PHP_OS_FAMILY; $osFamily = PHP_OS_FAMILY;
if ('Windows' === $osFamily) { if ('Windows' === $osFamily) {
$declarations = self::DECLARATIONS . ' int _kbhit();'; $declarations = self::DECLARATIONS.' int _kbhit();';
self::$ffi = FFI::cdef($declarations, self::WINDOWS_LIBRARY); self::$ffi = FFI::cdef($declarations, self::WINDOWS_LIBRARY);
} elseif ('Linux' === $osFamily) { } elseif ('Linux' === $osFamily) {
if (!file_exists($linuxLibrary)) { if (!file_exists($linuxLibrary)) {
throw new RuntimeException(sprintf('Could not find library file %s.', $linuxLibrary)); throw new RuntimeException(sprintf('Could not find library file %s.', $linuxLibrary));
} }
$declarations = self::DECLARATIONS . ' int cinPeek();'; $declarations = self::DECLARATIONS.' int cinPeek();';
self::$ffi = FFI::cdef($declarations, $linuxLibrary); self::$ffi = FFI::cdef($declarations, $linuxLibrary);
} else { } else {
throw new RuntimeException(sprintf('Sorry, %s is not supported yet.', $osFamily)); throw new RuntimeException(sprintf('Sorry, %s is not supported yet.', $osFamily));
@ -92,10 +92,13 @@ final class Getch
if ($ffi->_kbhit()) { if ($ffi->_kbhit()) {
$result = $ffi->_getch(); $result = $ffi->_getch();
$ffi->_ungetch($result); $ffi->_ungetch($result);
return $result; return $result;
} }
return -1; return -1;
} }
return $ffi->cinPeek(); return $ffi->cinPeek();
} }