Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8bcc4c6807 | ||
|
a5223adfa5 |
@ -17,6 +17,7 @@
|
||||
"ext-json": "*",
|
||||
"phpunit/phpunit": "^9.5.0",
|
||||
"phpstan/phpstan": "^0.12.19",
|
||||
"rector/rector": "^0.10.9",
|
||||
"spatie/phpunit-snapshot-assertions": "^4.2.0"
|
||||
},
|
||||
"scripts": {
|
||||
@ -27,6 +28,6 @@
|
||||
},
|
||||
"require": {
|
||||
"ext-ffi": "*",
|
||||
"php": ">= 8.0.0"
|
||||
"php": ">= 7.4.0"
|
||||
}
|
||||
}
|
||||
|
3669
composer.lock
generated
3669
composer.lock
generated
File diff suppressed because it is too large
Load Diff
54
rector.php
Normal file
54
rector.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector;
|
||||
use Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector;
|
||||
use Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector;
|
||||
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector;
|
||||
use Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;
|
||||
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
|
||||
use Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector;
|
||||
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
|
||||
use Rector\Generics\Rector\Class_\GenericsPHPStormMethodAnnotationRector;
|
||||
use Rector\Set\ValueObject\SetList;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
// get parameters
|
||||
// $parameters = $containerConfigurator->parameters();
|
||||
//
|
||||
// // Define what rule sets will be applied
|
||||
// $parameters->set(Option::SETS, [
|
||||
// SetList::DEAD_CODE,
|
||||
// SetList::PHP_80,
|
||||
// ]);
|
||||
|
||||
// get services (needed for register a single rule)
|
||||
$services = $containerConfigurator->services();
|
||||
|
||||
|
||||
$rules = [
|
||||
// PHP8 downgrade
|
||||
DowngradeClassOnObjectToGetClassRector::class,
|
||||
DowngradeMatchToSwitchRector::class,
|
||||
DowngradeMixedTypeDeclarationRector::class,
|
||||
DowngradeNonCapturingCatchesRector::class,
|
||||
DowngradeNullsafeToTernaryOperatorRector::class,
|
||||
DowngradePropertyPromotionRector::class,
|
||||
DowngradeStaticTypeDeclarationRector::class,
|
||||
DowngradeTrailingCommasInParamUseRector::class,
|
||||
DowngradeUnionTypeDeclarationRector::class,
|
||||
DowngradeUnionTypeTypedPropertyRector::class,
|
||||
|
||||
GenericsPHPStormMethodAnnotationRector::class,
|
||||
];
|
||||
|
||||
foreach ($rules as $rule)
|
||||
{
|
||||
$services->set($rule);
|
||||
}
|
||||
};
|
@ -33,7 +33,7 @@ class Highlight {
|
||||
*/
|
||||
public static function fromPHPToken(int $token): int
|
||||
{
|
||||
return match($token) {
|
||||
$token = match($token) {
|
||||
// Delimiters
|
||||
T_ARRAY,
|
||||
T_CURLY_OPEN,
|
||||
@ -186,6 +186,8 @@ class Highlight {
|
||||
|
||||
default => Highlight::NORMAL,
|
||||
};
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -197,7 +199,7 @@ class Highlight {
|
||||
*/
|
||||
public static function fromPHPChar(string $char): int
|
||||
{
|
||||
return match ($char) {
|
||||
$hl = match ($char) {
|
||||
// Delimiter characters
|
||||
'[', ']', '{', '}', '(', ')', '"', "'" => Highlight::DELIMITER,
|
||||
|
||||
@ -207,5 +209,7 @@ class Highlight {
|
||||
|
||||
default => Highlight::NORMAL,
|
||||
};
|
||||
|
||||
return $hl;
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ class FileType {
|
||||
{
|
||||
$ext = strstr(basename($filename), '.');
|
||||
$ext = ($ext !== FALSE) ? $ext : '';
|
||||
return match ($ext) {
|
||||
$syntax = match ($ext) {
|
||||
'.sh', '.bash' => Syntax::new(
|
||||
'Shell',
|
||||
[
|
||||
@ -127,6 +127,8 @@ class FileType {
|
||||
),
|
||||
default => Syntax::default(),
|
||||
};
|
||||
|
||||
return $syntax;
|
||||
}
|
||||
|
||||
private function __construct(public string $name, public Syntax $syntax) {}
|
||||
|
@ -76,13 +76,15 @@ class Row {
|
||||
|
||||
public function __get(string $name): mixed
|
||||
{
|
||||
return match ($name)
|
||||
$prop = match ($name)
|
||||
{
|
||||
'size' => strlen($this->chars),
|
||||
'rsize' => strlen($this->render),
|
||||
'chars' => $this->chars,
|
||||
default => NULL,
|
||||
};
|
||||
|
||||
return $prop;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,7 +87,7 @@ class Terminal {
|
||||
{
|
||||
$c = Terminal::read();
|
||||
|
||||
return match($c)
|
||||
$key = match($c)
|
||||
{
|
||||
// Unambiguous mappings
|
||||
RawKeyCode::ARROW_DOWN => KeyType::ARROW_DOWN,
|
||||
@ -113,6 +113,8 @@ class Terminal {
|
||||
|
||||
default => $c,
|
||||
};
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ function is_digit(string $char): bool
|
||||
*/
|
||||
function is_space(string $char): bool
|
||||
{
|
||||
return match($char) {
|
||||
$isSpace = match($char) {
|
||||
RawKeyCode::CARRIAGE_RETURN,
|
||||
RawKeyCode::FORM_FEED,
|
||||
RawKeyCode::NEWLINE,
|
||||
@ -86,6 +86,8 @@ function is_space(string $char): bool
|
||||
|
||||
default => false,
|
||||
};
|
||||
|
||||
return $isSpace;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -158,7 +160,7 @@ function str_has(string $haystack, string $str, ?int $offset = NULL): bool
|
||||
*/
|
||||
function syntax_to_color(int $hl): int
|
||||
{
|
||||
return match ($hl)
|
||||
$color = match ($hl)
|
||||
{
|
||||
Highlight::COMMENT => Color::FG_CYAN,
|
||||
Highlight::ML_COMMENT => Color::FG_BRIGHT_BLACK,
|
||||
@ -175,6 +177,8 @@ function syntax_to_color(int $hl): int
|
||||
Highlight::IDENTIFIER => Color::FG_BRIGHT_WHITE,
|
||||
default => Color::FG_WHITE,
|
||||
};
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -191,7 +195,7 @@ function tabs_to_spaces(string $str, int $number = KILO_TAB_STOP): string
|
||||
|
||||
function error_code_name(int $code): string
|
||||
{
|
||||
return match ($code) {
|
||||
$errorName = match ($code) {
|
||||
E_ERROR => 'Error',
|
||||
E_WARNING => 'Warning',
|
||||
E_PARSE => 'Parse Error',
|
||||
@ -208,6 +212,8 @@ function error_code_name(int $code): string
|
||||
E_USER_DEPRECATED => 'User Deprecated',
|
||||
default => 'Unknown',
|
||||
};
|
||||
|
||||
return $errorName;
|
||||
}
|
||||
|
||||
function saturating_add(int $a, int $b, int $max): int
|
||||
|
Loading…
Reference in New Issue
Block a user