mirror of
https://github.com/danog/Valinor.git
synced 2024-11-26 20:24:40 +01:00
feat: add support for PHP 8.2
This commit is contained in:
parent
bd5123390f
commit
47ad4a1416
3
.github/workflows/quality-assurance.yml
vendored
3
.github/workflows/quality-assurance.yml
vendored
@ -5,8 +5,9 @@ jobs:
|
||||
name: Quality Assurance
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
php-version: '8.1'
|
||||
php-version: '8.2'
|
||||
php-extensions: yaml
|
||||
PHP_CS_FIXER_IGNORE_ENV: 1 # @PHP 8.2 remove when PHP-CS-Fixer fully supports PHP 8.2
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
1
.github/workflows/tests.yml
vendored
1
.github/workflows/tests.yml
vendored
@ -15,6 +15,7 @@ jobs:
|
||||
- "7.4"
|
||||
- "8.0"
|
||||
- "8.1"
|
||||
- "8.2"
|
||||
|
||||
env:
|
||||
php-extensions: yaml
|
||||
|
@ -7,7 +7,10 @@ $finder = PhpCsFixer\Finder::create()->in([
|
||||
])
|
||||
->notPath('Fixtures/FunctionWithGroupedImportStatements.php')
|
||||
->notPath('Fixtures/FunctionWithSeveralImportStatementsInSameUseStatement.php')
|
||||
->notPath('Fixtures/TwoClassesInDifferentNamespaces.php');
|
||||
->notPath('Fixtures/TwoClassesInDifferentNamespaces.php')
|
||||
// @PHP 8.2 remove when PHP-CS-Fixer fully supports PHP 8.2; also remove
|
||||
// `@putenv PHP_CS_FIXER_IGNORE_ENV=1` inside `composer.json`
|
||||
->notPath('Fixture/Object/ObjectWithPropertyWithNativeDisjunctiveNormalFormType.php');
|
||||
|
||||
if (PHP_VERSION_ID < 8_00_00) {
|
||||
$finder = $finder
|
||||
|
@ -15,7 +15,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
|
||||
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
|
||||
"composer-runtime-api": "^2.0",
|
||||
"psr/simple-cache": "^1.0 || ^2.0",
|
||||
"doctrine/annotations": "^1.11"
|
||||
@ -46,6 +46,7 @@
|
||||
"scripts": {
|
||||
"check": [
|
||||
"@putenv XDEBUG_MODE=off",
|
||||
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",
|
||||
"phpunit",
|
||||
"phpstan",
|
||||
"psalm",
|
||||
@ -54,6 +55,7 @@
|
||||
],
|
||||
"fix": [
|
||||
"@putenv XDEBUG_MODE=off",
|
||||
"@putenv PHP_CS_FIXER_IGNORE_ENV=1",
|
||||
"php-cs-fixer fix",
|
||||
"rector"
|
||||
],
|
||||
|
4
composer.lock
generated
4
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "d9ebcc2e5638317c0dbe69803a3d1522",
|
||||
"content-hash": "5a1c2928cb71d9aca6ace45d1cea6012",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
@ -5823,7 +5823,7 @@
|
||||
"prefer-stable": false,
|
||||
"prefer-lowest": false,
|
||||
"platform": {
|
||||
"php": "~7.4.0 || ~8.0.0 || ~8.1.0",
|
||||
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0",
|
||||
"composer-runtime-api": "^2.0"
|
||||
},
|
||||
"platform-dev": [],
|
||||
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CuyZ\Valinor\Tests\Fixture\Object;
|
||||
|
||||
use Countable;
|
||||
use DateTime;
|
||||
use Iterator;
|
||||
|
||||
// @PHP8.2 move to anonymous class
|
||||
final class ObjectWithPropertyWithNativeDisjunctiveNormalFormType
|
||||
{
|
||||
public (Countable&Iterator)|(Countable&DateTime) $someProperty;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace CuyZ\Valinor\Tests\Fixture\Object;
|
||||
|
||||
// @PHP8.2 move to anonymous class
|
||||
final class ObjectWithPropertyWithNativePhp82StandaloneTypes
|
||||
{
|
||||
public null $nativeNull = null;
|
||||
|
||||
public true $nativeTrue;
|
||||
|
||||
public false $nativeFalse;
|
||||
}
|
@ -66,7 +66,7 @@ final class AttributesCompilerTest extends TestCase
|
||||
*/
|
||||
public function test_compiles_native_php_attributes_for_class_without_attributes(): void
|
||||
{
|
||||
$reflection = new ReflectionClass(stdClass::class);
|
||||
$reflection = new ReflectionClass(new class () { });
|
||||
$attributes = $this->compile(new NativeAttributes($reflection));
|
||||
|
||||
self::assertInstanceOf(EmptyAttributes::class, $attributes);
|
||||
@ -181,7 +181,7 @@ final class AttributesCompilerTest extends TestCase
|
||||
*/
|
||||
public function test_compiles_combined_attributes_for_class_without_annotation(): void
|
||||
{
|
||||
$reflection = new ReflectionClass(stdClass::class);
|
||||
$reflection = new ReflectionClass(new class () { });
|
||||
$attributes = $this->compile(
|
||||
new CombinedAttributes(
|
||||
new DoctrineAnnotations($reflection),
|
||||
|
@ -9,7 +9,9 @@ use CuyZ\Valinor\Tests\Fake\FakeReflector;
|
||||
use CuyZ\Valinor\Tests\Fixture\Enum\BackedStringEnum;
|
||||
use CuyZ\Valinor\Tests\Fixture\Object\ObjectWithConstants;
|
||||
use CuyZ\Valinor\Tests\Fixture\Object\ObjectWithPropertyPromotion;
|
||||
use CuyZ\Valinor\Tests\Fixture\Object\ObjectWithPropertyWithNativeDisjunctiveNormalFormType;
|
||||
use CuyZ\Valinor\Tests\Fixture\Object\ObjectWithPropertyWithNativeIntersectionType;
|
||||
use CuyZ\Valinor\Tests\Fixture\Object\ObjectWithPropertyWithNativePhp82StandaloneTypes;
|
||||
use CuyZ\Valinor\Tests\Fixture\Object\ObjectWithPropertyWithNativeUnionType;
|
||||
use CuyZ\Valinor\Utility\Reflection\Reflection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@ -159,6 +161,58 @@ final class ReflectionTest extends TestCase
|
||||
self::assertSame('Countable&Iterator', Reflection::flattenType($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8.2
|
||||
*/
|
||||
public function test_disjunctive_normal_form_type_is_handled(): void
|
||||
{
|
||||
$class = ObjectWithPropertyWithNativeDisjunctiveNormalFormType::class;
|
||||
|
||||
/** @var ReflectionType $type */
|
||||
$type = (new ReflectionProperty($class, 'someProperty'))->getType();
|
||||
|
||||
self::assertSame('Countable&Iterator|Countable&DateTime', Reflection::flattenType($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8.2
|
||||
*/
|
||||
public function test_native_null_type_is_handled(): void
|
||||
{
|
||||
$class = ObjectWithPropertyWithNativePhp82StandaloneTypes::class;
|
||||
|
||||
/** @var ReflectionType $type */
|
||||
$type = (new ReflectionProperty($class, 'nativeNull'))->getType();
|
||||
|
||||
self::assertSame('null', Reflection::flattenType($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8.2
|
||||
*/
|
||||
public function test_native_true_type_is_handled(): void
|
||||
{
|
||||
$class = ObjectWithPropertyWithNativePhp82StandaloneTypes::class;
|
||||
|
||||
/** @var ReflectionType $type */
|
||||
$type = (new ReflectionProperty($class, 'nativeTrue'))->getType();
|
||||
|
||||
self::assertSame('true', Reflection::flattenType($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP >= 8.2
|
||||
*/
|
||||
public function test_native_false_type_is_handled(): void
|
||||
{
|
||||
$class = ObjectWithPropertyWithNativePhp82StandaloneTypes::class;
|
||||
|
||||
/** @var ReflectionType $type */
|
||||
$type = (new ReflectionProperty($class, 'nativeFalse'))->getType();
|
||||
|
||||
self::assertSame('false', Reflection::flattenType($type));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param non-empty-string $expectedType
|
||||
* @dataProvider callables_with_docblock_typed_return_type
|
||||
|
Loading…
Reference in New Issue
Block a user