Skip to content

[PHP7] Removed ZEND_ACC_FINAL_CLASS which is unnecessary. #911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ PHP NEWS
classes (https://wiki.php.net/rfc/secure_unserialize). (Stas)
. Fixed bug #68185 ("Inconsistent insteadof definition."- incorrectly triggered). (Julien)
. Fixed bug #65419 (Inside trait, self::class != __CLASS__). (Julien)
. Removed ZEND_ACC_FINAL_CLASS, promoting ZEND_ACC_FINAL as final class
modifier. (Guilherme Blanco)

- DBA:
. Fixed bug #62490 (dba_delete returns true on missing item (inifile)). (Mike)
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ PHP 7.0 INTERNALS UPGRADE NOTES
l. get_class_name object handler info
m. Other portable macros info
n. ZEND_ENGINE_2 removal
o. Updated final class modifier

2. Build system changes
a. Unix build system changes
Expand Down Expand Up @@ -123,6 +124,9 @@ PHP 7.0 INTERNALS UPGRADE NOTES
ZEND_NORETURN is defined as __declspec(noreturn) on VS

n. The ZEND_ENGINE_2 macro has been removed. A ZEND_ENGINE_3 macro has been added.

o. Removed ZEND_ACC_FINAL_CLASS in favour of ZEND_ACC_FINAL, turning final class
modifier now a different class entry flag. Update your extensions.

========================
2. Build system changes
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void zend_register_closure_ce(TSRMLS_D) /* {{{ */

INIT_CLASS_ENTRY(ce, "Closure", closure_functions);
zend_ce_closure = zend_register_internal_class(&ce TSRMLS_CC);
zend_ce_closure->ce_flags |= ZEND_ACC_FINAL_CLASS;
zend_ce_closure->ce_flags |= ZEND_ACC_FINAL;
zend_ce_closure->create_object = zend_closure_new;
zend_ce_closure->serialize = zend_class_serialize_deny;
zend_ce_closure->unserialize = zend_class_unserialize_deny;
Expand Down
1 change: 0 additions & 1 deletion Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ typedef struct _zend_try_catch_element {
/* ZEND_ACC_EXPLICIT_ABSTRACT_CLASS denotes that a class was explicitly defined as abstract by using the keyword. */
#define ZEND_ACC_IMPLICIT_ABSTRACT_CLASS 0x10
#define ZEND_ACC_EXPLICIT_ABSTRACT_CLASS 0x20
#define ZEND_ACC_FINAL_CLASS 0x40
#define ZEND_ACC_INTERFACE 0x80
#define ZEND_ACC_TRAIT 0x120

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_generators.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ void zend_register_generator_ce(TSRMLS_D) /* {{{ */

INIT_CLASS_ENTRY(ce, "Generator", generator_functions);
zend_ce_generator = zend_register_internal_class(&ce TSRMLS_CC);
zend_ce_generator->ce_flags |= ZEND_ACC_FINAL_CLASS;
zend_ce_generator->ce_flags |= ZEND_ACC_FINAL;
zend_ce_generator->create_object = zend_generator_create;
zend_ce_generator->serialize = zend_class_serialize_deny;
zend_ce_generator->unserialize = zend_class_unserialize_deny;
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_inheritance.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ ZEND_API void zend_do_inheritance(zend_class_entry *ce, zend_class_entry *parent
&& !(parent_ce->ce_flags & ZEND_ACC_INTERFACE)) {
zend_error_noreturn(E_COMPILE_ERROR, "Interface %s may not inherit from class (%s)", ce->name->val, parent_ce->name->val);
}
if (parent_ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
if (parent_ce->ce_flags & ZEND_ACC_FINAL) {
zend_error_noreturn(E_COMPILE_ERROR, "Class %s may not inherit from final class (%s)", ce->name->val, parent_ce->name->val);
}

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_language_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class_declaration_statement:
class_type:
T_CLASS { $$ = 0; }
| T_ABSTRACT T_CLASS { $$ = ZEND_ACC_EXPLICIT_ABSTRACT_CLASS; }
| T_FINAL T_CLASS { $$ = ZEND_ACC_FINAL_CLASS; }
| T_FINAL T_CLASS { $$ = ZEND_ACC_FINAL; }
| T_TRAIT { $$ = ZEND_ACC_TRAIT; }
;

Expand Down
4 changes: 2 additions & 2 deletions ext/mysqli/mysqli.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ PHP_MINIT_FUNCTION(mysqli)
zend_declare_property_null(ce, "embedded", sizeof("embedded") - 1, ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(ce, "reconnect", sizeof("reconnect") - 1, ZEND_ACC_PUBLIC TSRMLS_CC);
zend_declare_property_null(ce, "report_mode", sizeof("report_mode") - 1, ZEND_ACC_PUBLIC TSRMLS_CC);
ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
ce->ce_flags |= ZEND_ACC_FINAL;
zend_hash_add_ptr(&classes, ce->name, &mysqli_driver_properties);

REGISTER_MYSQLI_CLASS_ENTRY("mysqli", mysqli_link_class_entry, mysqli_link_methods);
Expand Down Expand Up @@ -655,7 +655,7 @@ PHP_MINIT_FUNCTION(mysqli)

REGISTER_MYSQLI_CLASS_ENTRY("mysqli_warning", mysqli_warning_class_entry, mysqli_warning_methods);
ce = mysqli_warning_class_entry;
ce->ce_flags |= ZEND_ACC_FINAL_CLASS | ZEND_ACC_PROTECTED;
ce->ce_flags |= ZEND_ACC_FINAL;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This configuration was somehow broken... we do not support protected classes (yet).

zend_hash_init(&mysqli_warning_properties, 0, NULL, free_prop_handler, 1);
MYSQLI_ADD_PROPERTIES(&mysqli_warning_properties, mysqli_warning_property_entries);
zend_declare_property_null(ce, "message", sizeof("message") - 1, ZEND_ACC_PUBLIC TSRMLS_CC);
Expand Down
2 changes: 1 addition & 1 deletion ext/pdo/pdo_stmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ void pdo_stmt_init(TSRMLS_D)

INIT_CLASS_ENTRY(ce, "PDORow", pdo_row_functions);
pdo_row_ce = zend_register_internal_class(&ce TSRMLS_CC);
pdo_row_ce->ce_flags |= ZEND_ACC_FINAL_CLASS; /* when removing this a lot of handlers need to be redone */
pdo_row_ce->ce_flags |= ZEND_ACC_FINAL; /* when removing this a lot of handlers need to be redone */
pdo_row_ce->create_object = pdo_row_new;
pdo_row_ce->serialize = pdo_row_serialize;
}
Expand Down
4 changes: 2 additions & 2 deletions ext/phar/phar_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -5308,11 +5308,11 @@ void phar_object_init(TSRMLS_D) /* {{{ */
#else
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
phar_ce_archive = zend_register_internal_class(&ce TSRMLS_CC);
phar_ce_archive->ce_flags |= ZEND_ACC_FINAL_CLASS;
phar_ce_archive->ce_flags |= ZEND_ACC_FINAL;

INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
phar_ce_data = zend_register_internal_class(&ce TSRMLS_CC);
phar_ce_data->ce_flags |= ZEND_ACC_FINAL_CLASS;
phar_ce_data->ce_flags |= ZEND_ACC_FINAL;
#endif

REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2)
Expand Down
10 changes: 5 additions & 5 deletions ext/reflection/php_reflection.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static void _class_string(string *str, zend_class_entry *ce, zval *obj, char *in
if (ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
string_printf(str, "abstract ");
}
if (ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
if (ce->ce_flags & ZEND_ACC_FINAL) {
string_printf(str, "final ");
}
string_printf(str, "class ");
Expand Down Expand Up @@ -1557,7 +1557,7 @@ ZEND_METHOD(reflection, getModifierNames)
if (modifiers & (ZEND_ACC_ABSTRACT | ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) {
add_next_index_stringl(return_value, "abstract", sizeof("abstract")-1);
}
if (modifiers & (ZEND_ACC_FINAL | ZEND_ACC_FINAL_CLASS)) {
if (modifiers & ZEND_ACC_FINAL) {
add_next_index_stringl(return_value, "final", sizeof("final")-1);
}
if (modifiers & ZEND_ACC_IMPLICIT_PUBLIC) {
Expand Down Expand Up @@ -4162,7 +4162,7 @@ ZEND_METHOD(reflection_class, isTrait)
Returns whether this class is final */
ZEND_METHOD(reflection_class, isFinal)
{
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_FINAL_CLASS);
_class_check_flag(INTERNAL_FUNCTION_PARAM_PASSTHRU, ZEND_ACC_FINAL);
}
/* }}} */

Expand Down Expand Up @@ -4290,7 +4290,7 @@ ZEND_METHOD(reflection_class, newInstanceWithoutConstructor)
METHOD_NOTSTATIC(reflection_class_ptr);
GET_REFLECTION_OBJECT_PTR(ce);

if (ce->create_object != NULL && ce->ce_flags & ZEND_ACC_FINAL_CLASS) {
if (ce->create_object != NULL && ce->ce_flags & ZEND_ACC_FINAL) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC, "Class %s is an internal class marked as final that cannot be instantiated without invoking its constructor", ce->name->val);
}

Expand Down Expand Up @@ -6187,7 +6187,7 @@ PHP_MINIT_FUNCTION(reflection) /* {{{ */

REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_IMPLICIT_ABSTRACT", ZEND_ACC_IMPLICIT_ABSTRACT_CLASS);
REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_EXPLICIT_ABSTRACT", ZEND_ACC_EXPLICIT_ABSTRACT_CLASS);
REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_FINAL", ZEND_ACC_FINAL_CLASS);
REGISTER_REFLECTION_CLASS_CONST_LONG(class, "IS_FINAL", ZEND_ACC_FINAL);

INIT_CLASS_ENTRY(_reflection_entry, "ReflectionObject", reflection_object_functions);
_reflection_entry.create_object = reflection_objects_new;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dump_modifiers('g');
--EXPECT--
int(0)
int(32)
int(64)
int(4)
int(128)
int(524288)
int(524416)
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/tests/ReflectionClass_modifiers_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int(0)
bool(true)
bool(false)
bool(false)
int(64)
int(4)
bool(false)
bool(true)
bool(false)
Expand Down
2 changes: 1 addition & 1 deletion ext/reflection/tests/ReflectionClass_toString_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector ] {
- Constants [3] {
Constant [ integer IS_IMPLICIT_ABSTRACT ] { 16 }
Constant [ integer IS_EXPLICIT_ABSTRACT ] { 32 }
Constant [ integer IS_FINAL ] { 64 }
Constant [ integer IS_FINAL ] { 4 }
}

- Static properties [0] {
Expand Down
2 changes: 1 addition & 1 deletion ext/tidy/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ static PHP_MINIT_FUNCTION(tidy)

REGISTER_INI_ENTRIES();
REGISTER_TIDY_CLASS(tidy, doc, NULL, 0);
REGISTER_TIDY_CLASS(tidyNode, node, NULL, ZEND_ACC_FINAL_CLASS);
REGISTER_TIDY_CLASS(tidyNode, node, NULL, ZEND_ACC_FINAL);

tidy_object_handlers_doc.cast_object = tidy_doc_cast_handler;
tidy_object_handlers_node.cast_object = tidy_node_cast_handler;
Expand Down