1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fix bug #81474: Make Reflection(Attribute|Enum|EnumBackedCase) non-final

BetterReflection would like to extend these classes to provide
adaptors. As our other Reflector classes are non-final, I think
it makes sense to make these non-final as well.

Closes GH-7520.
This commit is contained in:
Nikita Popov
2021-09-27 16:35:52 +02:00
parent f81f874408
commit f2ae8a3357
4 changed files with 6 additions and 17 deletions

1
NEWS
View File

@@ -9,6 +9,7 @@ PHP NEWS
- Reflection:
. Fixed bug #81457 (Enum: ReflectionMethod->getDeclaringClass() return a
ReflectionClass). (Nikita)
. Fixed bug #81474 (Make ReflectionEnum and related class non-final). (Nikita)
- XML:
. Fixed bug #70962 (XML_OPTION_SKIP_WHITE strips embedded whitespace).

View File

@@ -696,7 +696,7 @@ final class ReflectionReference
}
/** @not-serializable */
final class ReflectionAttribute implements Reflector
class ReflectionAttribute implements Reflector
{
public function getName(): string {}
public function getTarget(): int {}
@@ -711,7 +711,7 @@ final class ReflectionAttribute implements Reflector
private function __construct() {}
}
final class ReflectionEnum extends ReflectionClass
class ReflectionEnum extends ReflectionClass
{
public function __construct(object|string $objectOrClass) {}
@@ -739,7 +739,7 @@ class ReflectionEnumUnitCase extends ReflectionClassConstant
public function getValue(): UnitEnum {}
}
final class ReflectionEnumBackedCase extends ReflectionEnumUnitCase
class ReflectionEnumBackedCase extends ReflectionEnumUnitCase
{
public function __construct(object|string $class, string $constant) {}

View File

@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 2316b7245c77ca2a5dd8baef53002c890eab162e */
* Stub hash: 0b5887f75bd4ff4935aaa5bbdbe1c18f970525c2 */
ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_class_Reflection_getModifierNames, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, modifiers, IS_LONG, 0)
@@ -1452,7 +1452,7 @@ static zend_class_entry *register_class_ReflectionAttribute(zend_class_entry *cl
INIT_CLASS_ENTRY(ce, "ReflectionAttribute", class_ReflectionAttribute_methods);
class_entry = zend_register_internal_class_ex(&ce, NULL);
class_entry->ce_flags |= ZEND_ACC_FINAL|ZEND_ACC_NOT_SERIALIZABLE;
class_entry->ce_flags |= ZEND_ACC_NOT_SERIALIZABLE;
zend_class_implements(class_entry, 1, class_entry_Reflector);
return class_entry;
@@ -1464,7 +1464,6 @@ static zend_class_entry *register_class_ReflectionEnum(zend_class_entry *class_e
INIT_CLASS_ENTRY(ce, "ReflectionEnum", class_ReflectionEnum_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_ReflectionClass);
class_entry->ce_flags |= ZEND_ACC_FINAL;
return class_entry;
}
@@ -1485,7 +1484,6 @@ static zend_class_entry *register_class_ReflectionEnumBackedCase(zend_class_entr
INIT_CLASS_ENTRY(ce, "ReflectionEnumBackedCase", class_ReflectionEnumBackedCase_methods);
class_entry = zend_register_internal_class_ex(&ce, class_entry_ReflectionEnumUnitCase);
class_entry->ce_flags |= ZEND_ACC_FINAL;
return class_entry;
}

View File

@@ -1,10 +0,0 @@
--TEST--
Check that ReflectionAttribute is final
--FILE--
<?php
class T extends ReflectionAttribute {}
?>
--EXPECTF--
Fatal error: Class T cannot extend final class ReflectionAttribute in %s on line %d