Skip to content
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

Rfc: inner classes #18069

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open

Conversation

withinboredom
Copy link
Contributor

This is the implementation for inner classes as defined in https://wiki.php.net/rfc/short-and-inner-classes

There is quite a lot going on here, so here's an overview of the changes (thanks AI):

Changes

File(s) Change Summary
Zend/{zend.h, zend_ast.h, zend_compile.c, zend_compile.h, zend_execute.c, zend_language_parser.y, zend_language_scanner.l, zend_object_handlers.c, zend_opcode.c, zend_vm_def.h, zend_vm_execute.h, zend_vm_handlers.h, zend_vm_opcodes.c, zend_vm_opcodes.h} Added support for inner (nested) classes including a new AST node (ZEND_AST_INNER_CLASS), additional structure members (required_scope, lexical_scope, required_scope_absolute), updated compile functions (zend_compile_inner_class_ref, zend_resolve_nested_class_name), new token (T_INNER_REF) handling, opcode definitions, and enhanced visibility checks.
ext/reflection/{php_reflection.c, php_reflection.stub.php, php_reflection_arginfo.h} Extended the ReflectionClass API with new methods: isInnerClass, isPrivate, isProtected, and isPublic to determine inner class status and visibility.
ext/opcache/zend_persist.c Introduced zend_update_required_scope to update the required_scope and lexical_scope properties during class table persistence, ensuring proper reference management.
ext/tokenizer/{tokenizer_data.c, tokenizer_data.stub.php, tokenizer_data_arginfo.h} Added support for a new token (T_INNER_REF) for inner class references by updating token recognition rules and constant definitions.
Zend/tests/errmsg/errmsg_027.phpt, ext/reflection/tests/bug74454.phpt Updated expected error messages to clarify the syntax and parsing errors related to nested class declarations.
tests/classes/inner_classes/*.phpt Added numerous test cases covering inner class declarations, access modifiers (including public, private, protected, and specialized modifiers), autoloading, inheritance, readonly properties, return types, static variables, and visibility rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant