php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54631 Cannot call constructor
Submitted: 2011-04-29 13:33 UTC Modified: 2011-06-04 15:26 UTC
From: toolong at mail dot ru Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.3.6 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: toolong at mail dot ru
New email:
PHP Version: OS:

 

 [2011-04-29 13:33 UTC] toolong at mail dot ru
Description:
------------
Trying to overload SplObjectStorage __construct(),
but got an fatal error: Cannot call constructor

Notice that in manual
http://php.net/manual/en/class.splobjectstorage.php
class SplObjectStorage does not contain constructor, at least public.



Test script:
---------------
Class Foo extends SplObjectStorage
{
	public function __construct()
	{
		parent::__construct();
	}
}

$foo = new Foo();

Expected result:
----------------
It should work

Actual result:
--------------
Fatal error: Cannot call constructor

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-05-16 18:29 UTC] acurioso@php.net
-Assigned To: +Assigned To: acurioso
 [2011-06-04 15:26 UTC] felipe@php.net
-Status: Assigned +Status: Bogus -Assigned To: acurioso +Assigned To:
 [2011-06-04 15:26 UTC] felipe@php.net
Simply do not call the parent constructor whereas SplObjectStorage doesn't have it. Declaring the constructor in the derived class is not the problem.

You can reproduce the same error inheriting from an user class without constructor, and trying to call it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 08:01:28 2024 UTC