Re: Refactored magic methods
| From: | Nikita Popov | Date: | Thu, 29 Aug 2013 11:00:31 +0000 |
| Subject: | Re: Refactored magic methods | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-68677@lists.php.net to get a copy of this message | ||
On Fri, Aug 2, 2013 at 6:47 PM, Julien Pauli <jpauli@php.net> wrote:
> Hi internals.
>
> I started a work of refactoring magic methods from internals.
>
> The first goal was to never write ourselves things like "__get", but use
> macros for those names. (get, set, invoke, etc...).
>
> A second goal was to rewrite some parts of the compiler which looked like
> code duplication which could benefit from macro refactoring.
>
> I did that.
> All tests pass.
>
> It may look uglier for people who dont like having more macros, but anyway,
> we can cherry pick some commits, etc...
>
> If you have ideas or things to say, I'm listening.
> https://github.com/jpauli/php-src/compare/macroing
>
I'm not really a fan of heavy macro usage, so here an alternative
suggestion:
https://github.com/nikic/php-src/commit/375bd7911fd117696b8b5d63c104fd588d69c409
Basically, instead of going through all the magic methods manually we
define a structure holding information on magic methods and then loop
through it doing generic checks.
The above example only changes zend_check_magic_method_implementation, but
the idea can be generalized to the other occurances of magic method checks
(making the structure a global constant so they can all make use of the
information in there.)
Nikita