In the following link you will find final, public, protected and private (f
+ 3p) for ZE2:
http://marcus-boerger.de/php/ext/ze2/
What it does:
- introduced final, public, protected, private member functions (methods)
-> Since we have aggregation already (and a patch from me some days
before shows that it can
work even with ZE2) and 3p member variables i thought why not having
3p member functions.
-> This does not make "PHP a strictly typed language". But it makes PHP
more OO powerfull
and allows real "Class-Design".
- i also introduced a forth visibility "private+hidden". That means when
you inherit a private method
it is always marked as hidden. This way you cannot overload a private
method in a second derived
class. You could check without inheriting the private method as hidden
but that would take longer.
- and i added a fifth visibility "". This is currently mapped to puiblic
but the informaion is kept.
I could have forced this to public but found it better to keep the
visibility "" to make it possible
to display the correct decorated method string.
- since abstract made it already into ZE2 i wanted to have final
(overloading not allowed) what could
be thought of as the opposite of abstract (must be overloaded).
- Every method now knows its scope. This allows better error messages since
we can allways
show class and method name. Without this part of the patch we cannot
allways do this.
- When at compile time a class inherits methods from another class there
are several checks
to veify that you do not change the visibility, do not mix static and
non static and do not overload
private methods.
- for the 'speed guys': during runtime (zend_execute.c) public static
methods only have one
additional check. public methods have one additional call and one
additional check. protected
and private checks take longer since they often require rekursive scope
lookups.
- 'speed guys' continued: during compile time (zend_compile.c)
- before this patch we had the structure member is_static in
zend_op_array/zend_function. Now
we have fn_flags which stores information about
abstract/final/static/public/protected/private. On
modern CPUs it makes no speed difference if we have a packed bitset or
single boolean values
but we require less memory.
- i store abstract in fn_flags to disallow overloading a method with an
abstract method. There is no
further change in abstract.
- last but not least i made 27 tests for everything i had in mind during
patching the ZendEngine.
What's left:
- create a global scope with a name that can be referred by the error
message. Not doing this will
either result in errors when working with "dynaming function call by
name" (i guess so) or we have
to check or skip class/namespace names in error messages.
- i haven't experimented with aggregation yet since it does not work
without my patch mentioned
already.
- the other OO features "interfaces and such": but i remember all those
were disagreed on this list.
- more tests
- more than i know yet - i guess :-)
regards
marcus
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php
- Re: [PHP-DEV] ZE2 + F3P Marcus Börger
- Re: [PHP-DEV] ZE2 + F3P Marcus Börger