php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40948 missing parameters for constructor produces E_WARNING - should be E_FATAL
Submitted: 2007-03-29 10:38 UTC Modified: 2007-03-29 10:47 UTC
From: jestar342 at hotmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.1 OS: All
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jestar342 at hotmail dot com
New email:
PHP Version: OS:

 

 [2007-03-29 10:38 UTC] jestar342 at hotmail dot com
Description:
------------
Instantiating an object from a class with *required* parameters does not cease instantiation. In my humble opinion, as we have the ability to use optional parameters, missing required parameters should generate E_FATAL error.

Reproduce code:
---------------
class Foo
{
    public function __construct ($bar)
    {}
    public function doSomething()
    {}
}

$foo = new Foo(); // E_WARNING
$foo->doSomething(); // this will still execute.

Expected result:
----------------
class Foo
{
    public function __construct ($bar)
    {}
    public function doSomething()
    {}
}

$foo = new Foo(); // E_FATAL
$foo->doSomething(); // this will not execute.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-29 10:47 UTC] tony2001@php.net
This behaviour is consistent for all functions including constructors and we don't have any plans to change it.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Mon Feb 16 16:00:01 2026 UTC