ID: 48215
Updated by: [email protected]
Reported By: mark at everytruckjob dot com
-Status: Open
+Status: Verified
Bug Type: Class/Object related
-Operating System: CentOs 5.3
+Operating System: *
-PHP Version: 5.3.0RC2
+PHP Version: 5.3, 6CVS (2009-05-09)
New Comment:
Not sure if this is actually intentional change in PHP_5.3 (and HEAD)
but this is different from PHP_5_2:
[j...@linux5 ~]$ /usr/src/build/php_5_2CVS_FCGI/sapi/cli/php -n -d
error_reporting="E_ALL | E_STRICT" t.php
Strict Standards: Redefining already defined constructor for class
search in /home/jani/t.php on line 9
search2::__construct()
search::__construct()
search2::search()
search::search()
[j...@linux5 ~]$ /usr/src/build/php_5_3CVS_FCGI/sapi/cli/php -n -d
error_reporting="E_ALL | E_STRICT" t.php
Strict Standards: Redefining already defined constructor for class
search in /home/jani/t.php on line 9
search2::__construct()
search::__construct()
search2::search()
search::__construct()
Previous Comments:
------------------------------------------------------------------------
[2009-05-09 21:59:42] mark at everytruckjob dot com
Description:
------------
Child class calling parent::function calls parent's php4 style
constructor of same name instead of parent's public method named the
same as the class.
Reproduce code:
---------------
<?php
class search
{
public function __construct()
{
echo "<br>".__METHOD__;
}
protected function search()
{
echo "<br>".__METHOD__;
}
}
class search2 extends search
{
public function __construct()
{
echo "<br>".__METHOD__;
parent::__construct();
}
public function search()
{
echo "<br>".__METHOD__;
parent::search();
}
}
$search2 = new search2();
$search2->search();
?>
Expected result:
----------------
search2::__construct
search::__construct
search2::search
search::__search
Actual result:
--------------
search2::__construct
search::__construct
search2::search
search::__construct
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48215&edit=1