From 5bdd3f8ee5a2cc7bd3e8f4236b06811600238141 Mon Sep 17 00:00:00 2001
From: Nikita Popov
Date: Mon, 27 Sep 2021 16:35:52 +0200
Subject: [PATCH] Make Reflection(Attribute|Enum|EnumBackedCase) non-final
As requested in https://bugs.php.net/bug.php?id=81474:
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.
---
ext/reflection/php_reflection.stub.php | 6 +++---
ext/reflection/php_reflection_arginfo.h | 6 ++----
ext/reflection/tests/ReflectionAttribute_final.phpt | 10 ----------
3 files changed, 5 insertions(+), 17 deletions(-)
delete mode 100644 ext/reflection/tests/ReflectionAttribute_final.phpt
diff --git a/ext/reflection/php_reflection.stub.php b/ext/reflection/php_reflection.stub.php
index 6d6c105d9d2cc..07c3452721e3d 100644
--- a/ext/reflection/php_reflection.stub.php
+++ b/ext/reflection/php_reflection.stub.php
@@ -696,7 +696,7 @@ private function __construct() {}
}
/** @not-serializable */
-final class ReflectionAttribute implements Reflector
+class ReflectionAttribute implements Reflector
{
public function getName(): string {}
public function getTarget(): int {}
@@ -711,7 +711,7 @@ private function __clone(): void {}
private function __construct() {}
}
-final class ReflectionEnum extends ReflectionClass
+class ReflectionEnum extends ReflectionClass
{
public function __construct(object|string $objectOrClass) {}
@@ -739,7 +739,7 @@ public function getEnum(): ReflectionEnum {}
public function getValue(): UnitEnum {}
}
-final class ReflectionEnumBackedCase extends ReflectionEnumUnitCase
+class ReflectionEnumBackedCase extends ReflectionEnumUnitCase
{
public function __construct(object|string $class, string $constant) {}
diff --git a/ext/reflection/php_reflection_arginfo.h b/ext/reflection/php_reflection_arginfo.h
index 43172abe38af1..fd209dbd25158 100644
--- a/ext/reflection/php_reflection_arginfo.h
+++ b/ext/reflection/php_reflection_arginfo.h
@@ -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;
}
diff --git a/ext/reflection/tests/ReflectionAttribute_final.phpt b/ext/reflection/tests/ReflectionAttribute_final.phpt
deleted file mode 100644
index c0363a3130670..0000000000000
--- a/ext/reflection/tests/ReflectionAttribute_final.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Check that ReflectionAttribute is final
---FILE--
-
---EXPECTF--
-Fatal error: Class T cannot extend final class ReflectionAttribute in %s on line %d