mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Add support for autoloading Enums
PHP 8.1 supports Enums, and [Enums follow class-semantics](https://php.watch/versions/8.1/enums#class-semantics-autoload). Composer's class-map generator currently looks for `class`, `interface`, and `trait` keywords. If Composer is run in PHP 8.1 or later, Composer now additionally looks for `enum` keyword as well. This is similar to how Hack's `enum` support is added. This PR also adds tests for basic enums, backed enums, namespaced enums, and an enum that implements an interface and extends a class.
This commit is contained in:
parent
03dcb6df3d
commit
228428747a
6 changed files with 41 additions and 1 deletions
|
@ -96,6 +96,16 @@ class ClassMapGeneratorTest extends TestCase
|
|||
'Dummy\Test\AnonClassHolder' => __DIR__ . '/Fixtures/php7.0/anonclass.php',
|
||||
));
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID >= 80100) {
|
||||
$data[] = array(__DIR__ . '/Fixtures/php8.1', array(
|
||||
'RolesBasicEnum' => __DIR__ . '/Fixtures/php8.1/enum_basic.php',
|
||||
'RolesBackedEnum' => __DIR__ . '/Fixtures/php8.1/enum_backed.php',
|
||||
'RolesClassLikeEnum' => __DIR__ . '/Fixtures/php8.1/enum_class_semantics.php',
|
||||
'Foo\Bar\RolesClassLikeNamespacedEnum' => __DIR__ . '/Fixtures/php8.1/enum_namespaced.php',
|
||||
));
|
||||
}
|
||||
|
||||
if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
|
||||
$data[] = array(__DIR__ . '/Fixtures/hhvm3.3', array(
|
||||
'FooEnum' => __DIR__ . '/Fixtures/hhvm3.3/HackEnum.php',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue