Skip to content

Commit

Permalink
Fix bug #81474: Make Reflection(Attribute|Enum|EnumBackedCase) non-final
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Sep 28, 2021
1 parent f81f874 commit f2ae8a3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
6 changes: 3 additions & 3 deletions ext/reflection/php_reflection.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand All @@ -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) {}

Expand Down Expand Up @@ -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) {}

Expand Down
6 changes: 2 additions & 4 deletions ext/reflection/php_reflection_arginfo.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
10 changes: 0 additions & 10 deletions ext/reflection/tests/ReflectionAttribute_final.phpt

This file was deleted.

0 comments on commit f2ae8a3

Please sign in to comment.