Skip to content

Commit

Permalink
misc: drop support for PHP 8.0
Browse files Browse the repository at this point in the history
PHP 8.0 security support has ended on the 26th of November 2023.

See: https://www.php.net/supported-versions.php
  • Loading branch information
romm committed Feb 8, 2024
1 parent 3afd7fa commit dafcc80
Show file tree
Hide file tree
Showing 114 changed files with 532 additions and 1,028 deletions.
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Expand Up @@ -12,7 +12,6 @@ jobs:
- "highest"
- "locked"
php-version:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
Expand Down
8 changes: 2 additions & 6 deletions .php-cs-fixer.dist.php
Expand Up @@ -9,12 +9,8 @@
->notPath('Fixtures/FunctionWithSeveralImportStatementsInSameUseStatement.php')
->notPath('Fixtures/TwoClassesInDifferentNamespaces.php');

if (PHP_VERSION_ID < 8_01_00) {
$finder = $finder->notPath('Fixture/Enum/PureEnum.php');
$finder = $finder->notPath('Fixture/Enum/BackedStringEnum.php');
$finder = $finder->notPath('Fixture/Enum/BackedIntegerEnum.php');
$finder = $finder->notPath('Fixture/Object/ObjectWithPropertyWithNativeIntersectionType.php');
$finder = $finder->notPath('Integration/Mapping/Fixture/ReadonlyValues.php');
if (PHP_VERSION_ID < 8_02_00) {
$finder = $finder->notPath('Fixture/Object/ObjectWithPropertyWithNativeDisjunctiveNormalFormType.php');
}

return (new PhpCsFixer\Config())
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"composer-runtime-api": "^2.0",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0"
},
Expand Down
6 changes: 3 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions rector.php
Expand Up @@ -4,11 +4,12 @@

use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\Config\RectorConfig;
use Rector\Core\Configuration\Option;
use Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector;
use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\FunctionLike\MixedTypeRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\Set\ValueObject\LevelSetList;

return static function (RectorConfig $config): void {
Expand All @@ -18,22 +19,26 @@
__DIR__ . '/tests',
]);

$config->parameters()->set(Option::CACHE_DIR, './var/cache/rector');
$config->cacheDirectory(__DIR__ . '/var/cache/rector');

// @see https://github.com/rectorphp/rector/issues/7341
$config->parameters()->set(Option::CACHE_CLASS, FileCacheStorage::class);
$config->cacheClass(FileCacheStorage::class);

$config->sets([
LevelSetList::UP_TO_PHP_80,
LevelSetList::UP_TO_PHP_81,
]);

$config->parallel();
$config->skip([
AddLiteralSeparatorToNumberRector::class,
ClassPropertyAssignToConstructorPromotionRector::class,
ReadOnlyPropertyRector::class,
MixedTypeRector::class => [
__DIR__ . '/tests/Unit/Definition/Repository/Reflection/ReflectionClassDefinitionRepositoryTest',
],
NullToStrictStringFuncCallArgRector::class => [
__DIR__ . '/tests/Traits/TestIsSingleton.php',
],
RestoreDefaultNullToNullableTypePropertyRector::class => [
__DIR__ . '/tests/Integration/Mapping/Other/FlexibleCastingMappingTest.php',
__DIR__ . '/tests/Integration/Mapping/SingleNodeMappingTest',
Expand Down
4 changes: 2 additions & 2 deletions src/Cache/FileWatchingCache.php
Expand Up @@ -125,15 +125,15 @@ private function saveTimestamps(string $key, mixed $value): void
$fileNames = [];

if ($value instanceof ClassDefinition) {
$reflection = Reflection::class($value->name());
$reflection = Reflection::class($value->name);

do {
$fileNames[] = $reflection->getFileName();
} while ($reflection = $reflection->getParentClass());
}

if ($value instanceof FunctionDefinition) {
$fileNames[] = $value->fileName();
$fileNames[] = $value->fileName;
}

foreach ($fileNames as $fileName) {
Expand Down
6 changes: 3 additions & 3 deletions src/Cache/Warmup/RecursiveCacheWarmupService.php
Expand Up @@ -82,10 +82,10 @@ private function warmupInterfaceType(InterfaceType $type): void

$function = $this->implementations->function($interfaceName);

$this->warmupType($function->returnType());
$this->warmupType($function->returnType);

foreach ($function->parameters() as $parameter) {
$this->warmupType($parameter->type());
foreach ($function->parameters as $parameter) {
$this->warmupType($parameter->type);
}
}

Expand Down
19 changes: 3 additions & 16 deletions src/Definition/AttributeDefinition.php
Expand Up @@ -8,26 +8,13 @@
final class AttributeDefinition
{
public function __construct(
private ClassDefinition $class,
public readonly ClassDefinition $class,
/** @var list<mixed> */
private array $arguments,
public readonly array $arguments,
) {}

public function class(): ClassDefinition
{
return $this->class;
}

/**
* @return list<mixed>
*/
public function arguments(): array
{
return $this->arguments;
}

public function instantiate(): object
{
return new ($this->class->type()->className())(...$this->arguments);
return new ($this->class->type->className())(...$this->arguments);
}
}
2 changes: 1 addition & 1 deletion src/Definition/Attributes.php
Expand Up @@ -40,7 +40,7 @@ public static function empty(): self
public function has(string $className): bool
{
foreach ($this->attributes as $attribute) {
if (is_a($attribute->class()->type()->className(), $className, true)) {
if (is_a($attribute->class->type->className(), $className, true)) {
return true;
}
}
Expand Down
52 changes: 8 additions & 44 deletions src/Definition/ClassDefinition.php
Expand Up @@ -10,49 +10,13 @@
final class ClassDefinition
{
public function __construct(
private ClassType $type,
private Attributes $attributes,
private Properties $properties,
private Methods $methods,
private bool $isFinal,
private bool $isAbstract,
/** @var class-string */
public readonly string $name,
public readonly ClassType $type,
public readonly Attributes $attributes,
public readonly Properties $properties,
public readonly Methods $methods,
public readonly bool $isFinal,
public readonly bool $isAbstract,
) {}

/**
* @return class-string
*/
public function name(): string
{
return $this->type->className();
}

public function type(): ClassType
{
return $this->type;
}

public function attributes(): Attributes
{
return $this->attributes;
}

public function properties(): Properties
{
return $this->properties;
}

public function methods(): Methods
{
return $this->methods;
}

public function isFinal(): bool
{
return $this->isFinal;
}

public function isAbstract(): bool
{
return $this->isAbstract;
}
}
66 changes: 9 additions & 57 deletions src/Definition/FunctionDefinition.php
Expand Up @@ -10,63 +10,15 @@
final class FunctionDefinition
{
public function __construct(
private string $name,
private string $signature,
private Attributes $attributes,
private ?string $fileName,
public readonly string $name,
public readonly string $signature,
public readonly Attributes $attributes,
public readonly ?string $fileName,
/** @var class-string|null */
private ?string $class,
private bool $isStatic,
private bool $isClosure,
private Parameters $parameters,
private Type $returnType
public readonly ?string $class,
public readonly bool $isStatic,
public readonly bool $isClosure,
public readonly Parameters $parameters,
public readonly Type $returnType
) {}

public function name(): string
{
return $this->name;
}

public function signature(): string
{
return $this->signature;
}

public function attributes(): Attributes
{
return $this->attributes;
}

public function fileName(): ?string
{
return $this->fileName;
}

/**
* @return class-string|null
*/
public function class(): ?string
{
return $this->class;
}

public function isStatic(): bool
{
return $this->isStatic;
}

public function isClosure(): bool
{
return $this->isClosure;
}

public function parameters(): Parameters
{
return $this->parameters;
}

public function returnType(): Type
{
return $this->returnType;
}
}
14 changes: 2 additions & 12 deletions src/Definition/FunctionObject.php
Expand Up @@ -7,24 +7,14 @@
/** @internal */
final class FunctionObject
{
private FunctionDefinition $definition;
public readonly FunctionDefinition $definition;

/** @var callable */
private $callback;
public readonly mixed $callback;

public function __construct(FunctionDefinition $definition, callable $callback)
{
$this->definition = $definition;
$this->callback = $callback;
}

public function definition(): FunctionDefinition
{
return $this->definition;
}

public function callback(): callable
{
return $this->callback;
}
}
42 changes: 6 additions & 36 deletions src/Definition/MethodDefinition.php
Expand Up @@ -10,41 +10,11 @@
final class MethodDefinition
{
public function __construct(
private string $name,
private string $signature,
private Parameters $parameters,
private bool $isStatic,
private bool $isPublic,
private Type $returnType
public readonly string $name,
public readonly string $signature,
public readonly Parameters $parameters,
public readonly bool $isStatic,
public readonly bool $isPublic,
public readonly Type $returnType
) {}

public function name(): string
{
return $this->name;
}

public function signature(): string
{
return $this->signature;
}

public function parameters(): Parameters
{
return $this->parameters;
}

public function isStatic(): bool
{
return $this->isStatic;
}

public function isPublic(): bool
{
return $this->isPublic;
}

public function returnType(): Type
{
return $this->returnType;
}
}
2 changes: 1 addition & 1 deletion src/Definition/Methods.php
Expand Up @@ -21,7 +21,7 @@ final class Methods implements IteratorAggregate, Countable
public function __construct(MethodDefinition ...$methods)
{
foreach ($methods as $method) {
$this->methods[$method->name()] = $method;
$this->methods[$method->name] = $method;
}
}

Expand Down

0 comments on commit dafcc80

Please sign in to comment.