Skip to content

Conversation

@khaledalam
Copy link

Description

Extensions can register internal classes, but currently there is no supported ZendAPI to apply Traits to those classes.

This PR introduces zend_class_use_traits() to allow internal classes to use Traits.

Fix #20974

@matyhtf
Copy link
Contributor

matyhtf commented Jan 19, 2026

@khaledalam This is fantastic, thank you for your work. Your efficiency is truly remarkable—new code commits in just a few hours. The support for trait features will help us utilize more advanced design patterns in extensions and break free from the limitations of single inheritance.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

While testing I noticed various things missing, and pushed the missing pieces. The test passes now.

Just out of interested, did you make the changes by hand or via AI?

@khaledalam
Copy link
Author

While testing I noticed various things missing, and pushed the missing pieces. The test passes now.

Just out of interested, did you make the changes by hand or via AI?

Thanks for the fixes. I did the changes myself by hand, with some occasional AI help.

@khaledalam
Copy link
Author

@khaledalam This is fantastic, thank you for your work. Your efficiency is truly remarkable—new code commits in just a few hours. The support for trait features will help us utilize more advanced design patterns in extensions and break free from the limitations of single inheritance.

Thanks, @matyhtf I appreciate it. And thank you for the thoughtful suggestion as well.

@iluuu1994
Copy link
Member

Ah, the test immediately crashed in CI and on my machine, so I was wondering how most of your code works if you couldn't test it, but I realize now it didn't crash for you because you didn't use address sanitizer. Nice work!

You can use sanitizer with ./configure --enable-address-sanitizer and then run-tests.php --asan, it will make your life much easier.

@khaledalam khaledalam changed the title Zend: Add zend_class_use_traits() for internal classes Zend: Add zend_class_use_internal_traits() for internal classes Jan 20, 2026
@khaledalam khaledalam marked this pull request as draft January 20, 2026 13:16
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.

Request to add support for Trait in the extension layer

3 participants