Updated header comment
This commit is contained in:
parent
d9af97eab2
commit
48420375b4
|
@ -2,14 +2,17 @@
|
||||||
|
|
||||||
use PhpCsFixer\Config;
|
use PhpCsFixer\Config;
|
||||||
|
|
||||||
|
$header = file_exists(__DIR__.'/header.txt') ? file_get_contents(__DIR__.'/header.txt') : '';
|
||||||
$finder = PhpCsFixer\Finder::create()
|
$finder = PhpCsFixer\Finder::create()
|
||||||
->in(__DIR__ . '/src')
|
->in(__DIR__ . '/src')
|
||||||
->in(__DIR__ . '/tests')
|
->in(__DIR__ . '/tests')
|
||||||
;
|
;
|
||||||
return (new Config())
|
return (new Config())
|
||||||
|
|
||||||
->setRules([
|
->setRules([
|
||||||
'@Symfony' => true,
|
'@Symfony' => true,
|
||||||
'array_syntax' => ['syntax' => 'short'],
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
|
'header_comment' => ['header' => $header],
|
||||||
])
|
])
|
||||||
->setFinder($finder)
|
->setFinder($finder)
|
||||||
;
|
;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 https://rewiv.com sikofitt@gmail.com
|
* Copyright (c) 2020-2024 https://sikofitt.com sikofitt@gmail.com
|
||||||
*
|
*
|
||||||
* This Source Code Form is subject to the
|
* This Source Code Form is subject to the
|
||||||
* terms of the Mozilla Public License, v. 2.0.
|
* terms of the Mozilla Public License, v. 2.0.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2020 https://rewiv.com sikofitt@gmail.com
|
Copyright (c) 2020-2024 https://sikofitt.com sikofitt@gmail.com
|
||||||
|
|
||||||
This Source Code Form is subject to the
|
This Source Code Form is subject to the
|
||||||
terms of the Mozilla Public License, v. 2.0.
|
terms of the Mozilla Public License, v. 2.0.
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020 https://rewiv.com sikofitt@gmail.com
|
* Copyright (c) 2020-2024 https://sikofitt.com sikofitt@gmail.com
|
||||||
*
|
*
|
||||||
* This Source Code Form is subject to the
|
* This Source Code Form is subject to the
|
||||||
* terms of the Mozilla Public License, v. 2.0.
|
* terms of the Mozilla Public License, v. 2.0.
|
||||||
|
@ -14,8 +14,6 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Sikofitt\Console;
|
namespace Sikofitt\Console;
|
||||||
|
|
||||||
use FFI;
|
|
||||||
|
|
||||||
final class Getch
|
final class Getch
|
||||||
{
|
{
|
||||||
// Special key codes
|
// Special key codes
|
||||||
|
@ -24,7 +22,7 @@ final class Getch
|
||||||
public const KEY_E0 = 0;
|
public const KEY_E0 = 0;
|
||||||
public const KEY_E1 = 224;
|
public const KEY_E1 = 224;
|
||||||
|
|
||||||
// Supported scan scodes.
|
// Supported scan codes.
|
||||||
public const KEY_F1 = 59;
|
public const KEY_F1 = 59;
|
||||||
public const KEY_F2 = 60;
|
public const KEY_F2 = 60;
|
||||||
public const KEY_F3 = 61;
|
public const KEY_F3 = 61;
|
||||||
|
@ -55,7 +53,7 @@ final class Getch
|
||||||
int _ungetch(int c);
|
int _ungetch(int c);
|
||||||
DECLARATIONS;
|
DECLARATIONS;
|
||||||
|
|
||||||
private static ?FFI $ffi = null;
|
private static ?\FFI $ffi = null;
|
||||||
|
|
||||||
public static function resetFFI(): void
|
public static function resetFFI(): void
|
||||||
{
|
{
|
||||||
|
@ -72,13 +70,13 @@ final class Getch
|
||||||
$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));
|
||||||
}
|
}
|
||||||
|
@ -108,7 +106,6 @@ final class Getch
|
||||||
|
|
||||||
public function ungetch(string|int $char): int
|
public function ungetch(string|int $char): int
|
||||||
{
|
{
|
||||||
|
|
||||||
if (is_string($char)) {
|
if (is_string($char)) {
|
||||||
$char = ord($char[0]);
|
$char = ord($char[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020-2024 https://sikofitt.com sikofitt@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the
|
||||||
|
* terms of the Mozilla Public License, v. 2.0.
|
||||||
|
*
|
||||||
|
* If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Sikofitt\Tests\Console\Getch;
|
namespace Sikofitt\Tests\Console\Getch;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020-2024 https://sikofitt.com sikofitt@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the
|
||||||
|
* terms of the Mozilla Public License, v. 2.0.
|
||||||
|
*
|
||||||
|
* If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Sikofitt\Tests\Console\Ungetch;
|
namespace Sikofitt\Tests\Console\Ungetch;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
Loading…
Reference in New Issue