Req #55864 [Opn->Sus]: Explicit call to default constructor

From: Date: Fri, 18 Dec 2020 13:36:28 +0000
Subject: Req #55864 [Opn->Sus]: Explicit call to default constructor
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-231153@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55864&edit=1

 ID:                 55864
 Updated by:         cmb@php.net
 Reported by:        dagguh at gmail dot com
 Summary:            Explicit call to default constructor
-Status:             Open
+Status:             Suspended
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   Ubuntu 10.04.3 LTS
 PHP Version:        5.3.5
 Block user comment: N
 Private report:     N

 New Comment:

> So, I stand by my request :)

Apparently, nobody else does.  So if you're still interested in
this, please forward the request to the internals mailing list.
For the time being, I'm suspending this ticket.


Previous Comments:
------------------------------------------------------------------------
[2011-10-07 10:23:31] dagguh at gmail dot com

I stand by my request because of cohesion.
I often see useless code in derived classes, e.g.:

function __construct($name) {
    parent::__construct($name);
}

which does absolutely nothing and I delete this code, because php will do it 
automatically.
For the same reason I'd like to remove

function __construct() {
    ;
}

which also does absolutely nothing and php will do the same automatically EXCEPT 
in the case I described.

So, I stand by my request :)

------------------------------------------------------------------------
[2011-10-07 10:03:48] laruence@php.net

yes, you can instantiate a calss without a constructor be declared, but that doesn't mean there
is default empty constructor. 

in PHP, constructor most like a magic method which will be called after a object instantiated
immediatlely. 
 
so if there is no constructor for a class, the new operator still can instantiate a class. but you
can't call a no-exists constructor directly :)

------------------------------------------------------------------------
[2011-10-07 09:55:01] dagguh at gmail dot com

Well you can call:

$base = new Base();

which works, because php uses default, empty constructor.
If new operator can call it, why derived classes can't?

------------------------------------------------------------------------
[2011-10-07 09:41:18] laruence@php.net

Actually, there is no default constructor in PHP, you should decalare one be 
fore you call to it. 
I think this should be mark as a feature request.

------------------------------------------------------------------------
[2011-10-07 09:25:40] dagguh at gmail dot com

Fixed version and OS

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=55864


--
Edit this bug report at https://bugs.php.net/bug.php?id=55864&edit=1


Thread (8 messages)

« previous php.bugs (#231153) next »