php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33486 "new self" should return the extended class
Submitted: 2005-06-27 08:49 UTC Modified: 2005-06-27 09:33 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: apann at personal dot ro Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5CVS-2005-06-27 OS: *
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: apann at personal dot ro
New email:
PHP Version: OS:

 

 [2005-06-27 08:49 UTC] apann at personal dot ro
Description:
------------
See "reproduce code" section.
The same thing happens with php version 5.0.3, 5.0.4 and 5.1.0-from_cvs.
Os: Mandriva Linux/Ubuntu/Win XP/Win 2000.

Reproduce code:
---------------
<?php
class Base {
    public function __construct() {
        echo __METHOD__ . "\n";
    }
    public static function run() {
        return new self;
    }
}

class Ext_One extends Base {
    public function __construct() {
        parent::__construct();
        echo __METHOD__ . "\n";
    }
}

class Ext_Two extends Base {
    public function __construct() {
        parent::__construct();
        echo __METHOD__ . "\n";
    }
}

$o1 = Ext_One::run();
$o2 = Ext_Two::run();

Expected result:
----------------
Ext_One::__construct
Base::__construct
Ext_Two::__construct
Base::__construct

Actual result:
--------------
Base::__construct
Base::__construct

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-27 08:52 UTC] apann at personal dot ro
The expected result should be:

Base::__construct
Ext_One::__construct
Base::__construct
Ext_Two::__construct
 [2005-06-27 09:33 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 03:01:32 2024 UTC