php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #18530 Request for Delphi style "inherited" call
Submitted: 2002-07-24 04:11 UTC Modified: 2002-07-24 04:35 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: woprog at hotmail dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.1.2 OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: woprog at hotmail dot com
New email:
PHP Version: OS:

 

 [2002-07-24 04:11 UTC] woprog at hotmail dot com
This is a feature request, not a bug.
=====================================


Check the following code:

class A {
  function foo() { echo "A bar"; }
}

class B extends A {
  function foo() { echo "B bar"; }
}

When I want to call the parent version of the function foo() in B, I have to enter:

A::foo();

thus including the actual classname of its parent... for me this is really annoying (I work a lot with classes in PHP)... could it be possible that the Delphi style of calling some classes parent version of some function is included in PHP? In Delphi this would look like this:

type
  A = class
    function foo();
  end;

  B = class(A)
    function foo();
  end;

function A.foo()
begin
  // do something
end;

function B.foo()
  inherited; // would call A.foo
  // do something else
end;


As you can see in the Delphi code, there's no need to include the actual class name in the call. This is possible since Delphi doesn't support multiple inheritance. And as far as I know, PHP doesn't as well, so it should be possible, right?

Would be really great to get feedback on this...

Marc

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-24 04:22 UTC] alan_k@php.net
you can already do

parent::foo();

the inherited; is really against the grain of the language as it is a little too obfusicated.
 [2002-07-24 04:27 UTC] woprog at hotmail dot com
Hmm is that anywhere in the documentation? That also means that classes with the name "parent" are not possible right?

Thanks a lot!!
 [2002-07-24 04:35 UTC] derick@php.net
You can have a class named parent, but you can not access it as a static class:

Derick
 [2002-07-24 04:37 UTC] alan at akbkhome dot com
http://www.php.net/manual/en/keyword.parent.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 10:01:28 2024 UTC