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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu May 02 16:01:29 2024 UTC