Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Timothy Warren | 8bcc4c6807 | |
Timothy Warren | a5223adfa5 |
|
@ -17,6 +17,7 @@
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"phpunit/phpunit": "^9.5.0",
|
"phpunit/phpunit": "^9.5.0",
|
||||||
"phpstan/phpstan": "^0.12.19",
|
"phpstan/phpstan": "^0.12.19",
|
||||||
|
"rector/rector": "^0.10.9",
|
||||||
"spatie/phpunit-snapshot-assertions": "^4.2.0"
|
"spatie/phpunit-snapshot-assertions": "^4.2.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -27,6 +28,6 @@
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-ffi": "*",
|
"ext-ffi": "*",
|
||||||
"php": ">= 8.0.0"
|
"php": ">= 7.4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
public static function fromPHPToken(int $token): int
|
||||||
{
|
{
|
||||||
return match($token) {
|
$token = match($token) {
|
||||||
// Delimiters
|
// Delimiters
|
||||||
T_ARRAY,
|
T_ARRAY,
|
||||||
T_CURLY_OPEN,
|
T_CURLY_OPEN,
|
||||||
|
@ -186,6 +186,8 @@ class Highlight {
|
||||||
|
|
||||||
default => Highlight::NORMAL,
|
default => Highlight::NORMAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return $token;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,7 +199,7 @@ class Highlight {
|
||||||
*/
|
*/
|
||||||
public static function fromPHPChar(string $char): int
|
public static function fromPHPChar(string $char): int
|
||||||
{
|
{
|
||||||
return match ($char) {
|
$hl = match ($char) {
|
||||||
// Delimiter characters
|
// Delimiter characters
|
||||||
'[', ']', '{', '}', '(', ')', '"', "'" => Highlight::DELIMITER,
|
'[', ']', '{', '}', '(', ')', '"', "'" => Highlight::DELIMITER,
|
||||||
|
|
||||||
|
@ -207,5 +209,7 @@ class Highlight {
|
||||||
|
|
||||||
default => Highlight::NORMAL,
|
default => Highlight::NORMAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return $hl;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,7 +26,7 @@ class FileType {
|
||||||
{
|
{
|
||||||
$ext = strstr(basename($filename), '.');
|
$ext = strstr(basename($filename), '.');
|
||||||
$ext = ($ext !== FALSE) ? $ext : '';
|
$ext = ($ext !== FALSE) ? $ext : '';
|
||||||
return match ($ext) {
|
$syntax = match ($ext) {
|
||||||
'.sh', '.bash' => Syntax::new(
|
'.sh', '.bash' => Syntax::new(
|
||||||
'Shell',
|
'Shell',
|
||||||
[
|
[
|
||||||
|
@ -127,6 +127,8 @@ class FileType {
|
||||||
),
|
),
|
||||||
default => Syntax::default(),
|
default => Syntax::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return $syntax;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function __construct(public string $name, public Syntax $syntax) {}
|
private function __construct(public string $name, public Syntax $syntax) {}
|
||||||
|
|
|
@ -76,13 +76,15 @@ class Row {
|
||||||
|
|
||||||
public function __get(string $name): mixed
|
public function __get(string $name): mixed
|
||||||
{
|
{
|
||||||
return match ($name)
|
$prop = match ($name)
|
||||||
{
|
{
|
||||||
'size' => strlen($this->chars),
|
'size' => strlen($this->chars),
|
||||||
'rsize' => strlen($this->render),
|
'rsize' => strlen($this->render),
|
||||||
'chars' => $this->chars,
|
'chars' => $this->chars,
|
||||||
default => NULL,
|
default => NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return $prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Terminal {
|
||||||
{
|
{
|
||||||
$c = Terminal::read();
|
$c = Terminal::read();
|
||||||
|
|
||||||
return match($c)
|
$key = match($c)
|
||||||
{
|
{
|
||||||
// Unambiguous mappings
|
// Unambiguous mappings
|
||||||
RawKeyCode::ARROW_DOWN => KeyType::ARROW_DOWN,
|
RawKeyCode::ARROW_DOWN => KeyType::ARROW_DOWN,
|
||||||
|
@ -113,6 +113,8 @@ class Terminal {
|
||||||
|
|
||||||
default => $c,
|
default => $c,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,7 +76,7 @@ function is_digit(string $char): bool
|
||||||
*/
|
*/
|
||||||
function is_space(string $char): bool
|
function is_space(string $char): bool
|
||||||
{
|
{
|
||||||
return match($char) {
|
$isSpace = match($char) {
|
||||||
RawKeyCode::CARRIAGE_RETURN,
|
RawKeyCode::CARRIAGE_RETURN,
|
||||||
RawKeyCode::FORM_FEED,
|
RawKeyCode::FORM_FEED,
|
||||||
RawKeyCode::NEWLINE,
|
RawKeyCode::NEWLINE,
|
||||||
|
@ -86,6 +86,8 @@ function is_space(string $char): bool
|
||||||
|
|
||||||
default => false,
|
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
|
function syntax_to_color(int $hl): int
|
||||||
{
|
{
|
||||||
return match ($hl)
|
$color = match ($hl)
|
||||||
{
|
{
|
||||||
Highlight::COMMENT => Color::FG_CYAN,
|
Highlight::COMMENT => Color::FG_CYAN,
|
||||||
Highlight::ML_COMMENT => Color::FG_BRIGHT_BLACK,
|
Highlight::ML_COMMENT => Color::FG_BRIGHT_BLACK,
|
||||||
|
@ -175,6 +177,8 @@ function syntax_to_color(int $hl): int
|
||||||
Highlight::IDENTIFIER => Color::FG_BRIGHT_WHITE,
|
Highlight::IDENTIFIER => Color::FG_BRIGHT_WHITE,
|
||||||
default => Color::FG_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
|
function error_code_name(int $code): string
|
||||||
{
|
{
|
||||||
return match ($code) {
|
$errorName = match ($code) {
|
||||||
E_ERROR => 'Error',
|
E_ERROR => 'Error',
|
||||||
E_WARNING => 'Warning',
|
E_WARNING => 'Warning',
|
||||||
E_PARSE => 'Parse Error',
|
E_PARSE => 'Parse Error',
|
||||||
|
@ -208,6 +212,8 @@ function error_code_name(int $code): string
|
||||||
E_USER_DEPRECATED => 'User Deprecated',
|
E_USER_DEPRECATED => 'User Deprecated',
|
||||||
default => 'Unknown',
|
default => 'Unknown',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return $errorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function saturating_add(int $a, int $b, int $max): int
|
function saturating_add(int $a, int $b, int $max): int
|
||||||
|
|
Loading…
Reference in New Issue