ID:               31669
 User updated by:  jason at amp-design dot net
 Reported By:      jason at amp-design dot net
 Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: *
 PHP Version:      5.*
 New Comment:

Well despite the fact that is so happens to be something that is
supposed to happen "by design", it would be good if this could be
reflected in the documentation if it is not seen as a bug (which I was
expecting somewhat). The main reason I found this worthy of a bug
report is the fact that this behaviour is different from that of C++.
Something like 

class A {
};

class B : A {
public:
        B(void) {
                A::A();
        }
};

int main(int argc, char **args)
{
        B b = *new B();
        return 0;
}

Will compile fine, and not have any issues during run time. I
personally can't see how it can be such as issue for PHP to follow C++
and remain consistent.


Previous Comments:
------------------------------------------------------------------------

[2005-01-23 20:32:11] [EMAIL PROTECTED]

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

It is 'a language level issue' by design.

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

[2005-01-23 16:06:38] jason at amp-design dot net

Description:
------------
If you extend from a base class with no explict constructor defined,
and the derived class has a call to parent::__construct(), an error is
raised.

However it is perfectly legit to call new Dummy(), despite the fact
Dummy has no explict constructor. Surely, if no constructor is defined
in a base class, it should provide a default null/empty constructor to
prevent errors. Without this, programmers have to provide a empty
__construct method, which seems be silly as it serves no purpose other
than to act as 'scaffolding code'.

I have checked in the PHP Manual under the OO bit for PHP4 and PHP5 to
make sure this is not the intended behaviour for PHP. If this is not a
bug and you have to provide dummy constructors, this should be made
clear in the documentation.

If needed I can test this at home under Windows as well using a CVS
snapshot if I get time. I'm sure it will produce the same result as it
appears to be a language level issue.

Reproduce code:
---------------
<?php

class Dummy {
        // uncomment here to make me work :-)
        // function __construct() {}
}

class BillGates extends Dummy {
        function __construct() {
                parent::__construct();
        }
}

$new_idiot_to_dominate_world = new BillGates();

?>

Expected result:
----------------
Nothing should be output. $new_idiot_to_dominate_world should have an
instance of BillGates.

Actual result:
--------------
Fatal error: Can not call constructor in BillGatesIsAScumBag.php on
line 10


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


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

Reply via email to