php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63336 invalid E_NOTICE error occur
Submitted: 2012-10-23 02:29 UTC Modified: 2015-04-14 14:12 UTC
Votes:3
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: tomoya-yokota at cybozu dot co dot jp Assigned: laruence (profile)
Status: Not a bug Package: Compile Warning
PHP Version: 5.4.8 OS: ubuntu12.04
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: tomoya-yokota at cybozu dot co dot jp
New email:
PHP Version: OS:

 

 [2012-10-23 02:29 UTC] tomoya-yokota at cybozu dot co dot jp
Description:
------------
1. set error_reporting with error_report( E_STRICT & ~ E_STRICT ).
2. call set_error_handler( callable $error_handler, E_STRICT & ~ E_STRICT ).
3. execute Bellow script(test.php)
4. E_NOTICE Error occur 
( Error Message is Use of undefined constant XXX - assumed 'XXX' )

# when the script of PHP is splitted by Class, This issue does not occur.


Test script:
---------------
------
test.php
------
<?php
error_reporting( E_ALL & ~ E_STRICT );
function myErrorHandler($errno, $errstr, $errfile, $errline) {
    if( $errno === E_NOTICE ) { echo "{$errstr}\n"; }
    if( $errno === E_STRICT ) { echo "{$errstr}\n"; } 
}
set_error_handler('myErrorHandler', E_ALL & ~ E_STRICT );
require_once("sample.php");

------
sample.php
------
<?php
define("TEST", "123");
class Hoge2 {
  public function moge($var=TEST, $moge=null) { return true; }
}

class HogeChild extends Hoge2 {
  public function moge($var=TEST) { return true; }
}


Expected result:
----------------
1. E_NOTICE would not be reported
2. E_STRICT wouble be reported.

Actual result:
--------------
1. E_NOTICE was reported.

----
error message
----
Use of undefined constant TEST - assumed 'TEST'

Patches

diff_of_zend_compile.c (last revision 2012-10-23 02:30 UTC by tomoya-yokota at cybozu dot co dot jp)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-10-23 03:39 UTC] laruence@php.net
you said "set error_reporting with error_report( E_STRICT & ~ E_STRICT )."

but your test script sasy: "error_reporting( E_ALL & ~ E_STRICT );" ?
 [2012-10-23 04:27 UTC] tomoya-yokota at cybozu dot co dot jp
> you said "set error_reporting with error_report( E_STRICT & ~ E_STRICT )."
Sorry. It is wrong. Test script is correct
 [2012-10-23 06:00 UTC] laruence@php.net
I am not sure, E_ALL & ~ E_STRICT == E_ALL without E_STRICT..
maybe you mistake your except result?
 [2012-10-23 06:09 UTC] tomoya-yokota at cybozu dot co dot jp
in PHP5.3, E_NOTICE error did not occur.
But in PHP5.4, E_NOTICE error would occur.
Is it error reporting specification?
 [2012-10-23 07:18 UTC] laruence@php.net
-Assigned To: +Assigned To: laruence
 [2012-10-23 07:18 UTC] laruence@php.net
Oh, I see your point.
 [2012-10-23 08:25 UTC] laruence@php.net
an solution is stop resolve constant value while in E_STRICT warning showing up. 
but that will introduce a little bc break.
 [2015-04-14 14:12 UTC] dmitry@php.net
-Status: Assigned +Status: Not a bug
 [2015-04-14 14:12 UTC] dmitry@php.net
This is not a bug.

You see compile-time warning messages, that are emitted before error_reporting() function is executed. If you call error_reporting() before including this file the messages are hidden.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC