ID:               27367
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Bogus
 Bug Type:         Zend Engine 2 problem
 Operating System: linux
 PHP Version:      5CVS-2004-02-23 (dev)
 New Comment:

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

protected or private constructors are callable from static members aka
factory pattern.


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

[2004-02-23 12:12:32] [EMAIL PROTECTED]

Description:
------------
By default if a constructor in a subclass is not defined the
constructor of the parent class is being called (see example 1).

However, if the parent constructor is declared "protected" and is
visible to the child, the engine refuses to execute the constructor
(Example 2 and result 2).

Example 3 shows that the parent constructor is visible in the child
when an explicit constructor is provided there.

Reproduce code:
---------------
Ex. 1:

php -r 'class a { function a() {echo "const of a\n";}} class b extends
a {} $a = new b();'



Ex. 2:

php -r 'class a { protected function a() {echo "const of a\n";}} class
b extends a {} $a = new b();'



Ex. 3:

php -r 'class a { protected function a() {echo "const of a\n";}} class
b extends a {public function b(){parent::a();}} $a = new b();'



Expected result:
----------------
const of a

const of a

const of a

Actual result:
--------------
Result 1 :

const of a



Result 2 :

PHP Fatal error:  Call to protected a::a() from context '' in Command
line code on line 1



Result 3 :

const of a


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


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

Reply via email to