An update. When I hardcode the parent class name (example below) then it
works. But if I decide to change the
class inheritance hierarchy I need to manually revise all my existing
classes. So where is the flexibility?
Furthermore .. I found a note in php manual stating that in php405
get_parent_class also accepts class name string as it's
only parameter.
So when corectly passing parent class names to each make I'll be able to do
something like that:
function make($this_name) {
$parent = get_parent_class($this_name);
eval("$parent::make('$parent')");
}
Unfortunately, the only thing I get form get_parent_class when calling it
with string parameter is quite empty string (and I have 4.0.5).
More. I think it would be wise to implement an "class name" like parent, for
example 'inherited' which calls always the "real" parent class
(that is the parent class of the class where such keyword is used not the
parent class of current object instance) method (or the method of
parent's parent if the method is not overriden in parent etc, generating an
error if the method is not found in entire class inheritance hierarchy)..
I hope you understood, since enhlish is not my primary language.
If you need me to elaborate a bit then ask.
Lenar
""Lenar Lõhmus"" <[EMAIL PROTECTED]> wrote in message
9gpn2a$oc6$[EMAIL PROTECTED]">news:9gpn2a$oc6$[EMAIL PROTECTED]...
> Hello,
>
> Sorry to write in dev, but i consider this a weakness of php. Something
> needs to be changed.
> Ok, maybe thereis a solution right now existing in PHP, but i'm unaware of
> it.
> Skip to the problem....
> I have three classes:
>
> class a {
> function make() {
> // some code
> }
> }
>
> class b extends a {
> function make() {
> // some code
> parent::make(); // instead write:
a::make(); // hardcoded
> }
> }
>
> class c extends b {
> function make() {
> // some code
> parent::make(); // instead write:
b::make(); //hardcoded
> }
> }
>
> now the class 'c' is instantiated and the member function 'make' is
called.
> All works up to the point where 'b'::make calls parent::make().
> It seems to call itself :(. I can understand this is logical behaviour
since
> it's still an instance of class c,
> so parent:: is still b::, but how should I call that grandparent's
make()???
> This doesn't seem like a good OOP.
> For example delphi's 'inherited' works relative to the class it's used in
> and it is way more useful than php's parent::.
>
> is there any elegant solution(s) to my problem?
>
> Lenar Lõhmus
>
>
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]