php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #827 request on object constructors
Submitted: 1998-10-06 17:27 UTC Modified: 1998-10-07 15:46 UTC
From: be at SHonline dot DE Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 3.0.5 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: be at SHonline dot DE
New email:
PHP Version: OS:

 

 [1998-10-06 17:27 UTC] be at SHonline dot DE
The constructor method of a class should be changed from
the classes name to "init" or whatever static name - or additional
support for this should be given for backward compatibility.

W H Y ? ?

The current solution makes it impossible to inherit from a class
with constructor method without rewriting the constructor method.

Example:

class origin {
  function origin() {
     # i will initiate all the neccessary things
    ;
  }

class inherit extends origin {
  ;
}

$q = new inherit;

Now nothing is done because inheritance loses the destructor.

In case of a library which lays in the background this is a bad thing.

Documentaion provides some slots of a class to be an api to the user
of that library class. Inheritance is the method of choice to
configure such a class.

Its a bad idea(tm) to force the user of a library to rewrite or wrap the 
internals of that library. That makes the idea of a library obsolete.

Boris

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-10-07 15:46 UTC] zeev
Will not happen.
Instead, PHP 3.0.6 classes will inherit their parent's
constructor.  E.g., for class foo, that has a ctor function
foo(), class bar that extends from it would have, by default
function bar() which behaves just like foo::foo(), unless
overriden by a new implementation of bar::bar().
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 04:01:29 2024 UTC