php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47439 Strict errors don't always appear in CLI
Submitted: 2009-02-18 16:34 UTC Modified: 2009-02-18 18:22 UTC
From: tomek at realtsp dot com Assigned:
Status: Not a bug Package: Compile Warning
PHP Version: 5.2.9RC2 OS: FreeBSD 7.0, Ubuntu
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: tomek at realtsp dot com
New email:
PHP Version: OS:

 

 [2009-02-18 16:34 UTC] tomek at realtsp dot com
Description:
------------
When running in CLI with strict errors enabled & display_errors turned on, PHP does not produce all strict warnings reliably.

Some, like:

"Strict Standards: Non-static method b::init() should not be called statically in /usr/home/tomek/test.php on line 25"

is 100% reproducible.

Others, like:

"Strict Standards: Declaration of b::init() should be compatible with that of a::init() in /usr/home/tomek/test.php on line 8"

are not reproducible using the code attached. Swapping the class declarations, however, makes the warning appear (ie. "class b extends a" goes first, and only then define "class a").

Please note that this is the *only* change required for it to appear. 

This is very similar to bug #46851.

Reproduce code:
---------------
<?php

error_reporting(E_ALL | E_STRICT);

ini_set('display_errors', 'On');
ini_set('log_errors', 'Off');

class a
{
  public function init($v) {}
}

class b extends a
{
  public function init() {}
}

b::init();

Expected result:
----------------
Strict Standards: Declaration of b::init() should be compatible with that of a::init() in /usr/home/tomek/test.php on line 8

Strict Standards: Non-static method b::init() should not be called statically in /usr/home/tomek/test.php on line 19


Actual result:
--------------
Strict Standards: Non-static method b::init() should not be called statically in /usr/home/tomek/test.php on line 19

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-18 17:08 UTC] johannes@php.net
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

The \"missing\" messages are created at compile time, but you\'Re setting your error_reporting level at run-time. Please set error reporting in php.ini to get all compile time messages
 [2009-02-18 17:16 UTC] tomek at realtsp dot com
Fair enough, changing that setting does show them in both cases.

However, what's still not clear is why is it inconsistent depending on the order of the class declarations? Surely it should just not appear at all unless the php.ini settings are changed?
 [2009-02-18 18:22 UTC] johannes@php.net
Sometimes we don'T have all information while compiling and do late binding at runtime, sometimes we have all information we need an can do early binding at compile time.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 08:01:23 2020 UTC