php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30184 run-tests error_reporting / ~E_STRICT ignored in phpt files
Submitted: 2004-09-21 19:39 UTC Modified: 2004-09-23 00:10 UTC
From: danielc at analysisandsolutions dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5CVS-2004-09-21 (dev) OS: Win 2000
Private report: No CVE-ID: None
 [2004-09-21 19:39 UTC] danielc at analysisandsolutions dot com
Description:
------------
Using:
    * PHP 5.0.2RC1 (cli) (built: Sep 21 2004 10:29:26)
    * run-tests.php version 1.195.2.1 or HEAD

When error_reporting is set to E_ALL in a .phpt file, E_STRICT warnings still come up for code in the .phpt file.  The notice isn't generated for code in included files.

Reproduce code:
---------------
NOTE: two files...

=============== s.phpt =================
--TEST--
error_reporting ignored for code in phpt
--SKIPIF--
--FILE--
<?php

/*
 * error_reporting(E_ALL) is ignored for the code
 * in this file but not the included file.
 */
error_reporting(E_ALL);

include './s.inc';

class phpt {
    var $phpt_var;
}

?>
--EXPECT--


=============== s.inc =================
<?php

class inc {
    var $inc_var;
}


Expected result:
----------------
Test to pass.

Actual result:
--------------
If error_reporting(E_ALL)
-------------------------
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in s.php on line 12


If error_reporting(E_ALL) commented out
---------------------------------------
Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in s.php on line 12

Strict Standards: var: Deprecated. Please use the public/private/protected modifiers in s.inc on line 4


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-09-21 23:34 UTC] danielc at analysisandsolutions dot com
Something else to take into consideration is run-tests.php is overriding the error_reporting settings from php.ini.  This is causing tests to fail even though the same tests worked fine under development versions of PHP 5.

Here's a new set of test scripts...

=========== s.phpt ================
--TEST--
error_reporting ignored for code in phpt
--SKIPIF--
--FILE--
<?php

echo 'Default error_reporting in s.phpt: ' . error_reporting() . "\n";

/*
 * RESULT:
 *   Strict Standards: var: Deprecated. Please use the
 *       public/private/protected modifiers in s.php on line 28
 *   Default error_reporting in s.phpt: 4095
 *   The error_reporting in s.inc: 2047
 *   Subsequent error_reporting in s.phpt: 2047
 *
 * RESULT if error_reporting(E_ALL) is commented out:
 *   Strict Standards: var: Deprecated. Please use the
 *       public/private/protected modifiers in s.php on line 28
 *   Default error_reporting in s.phpt: 4095
 *   Strict Standards: var: Deprecated. Please use the
 *       public/private/protected modifiers in s.inc on line 6
 *   The error_reporting in s.inc: 4095
 *   Subsequent error_reporting in s.phpt: 4095
 */
error_reporting(E_ALL);

include './s.inc';

class phpt {
    var $phpt_var;
}

echo 'Subsequent error_reporting in s.phpt: ' . error_reporting() . "\n";

?>
--EXPECT--
Default error_reporting in s.phpt: 2047
The error_reporting in s.inc: 2047
Subsequent error_reporting in s.phpt: 2047



=========== s.inc ================
<?php

echo 'The error_reporting in s.inc: ' . error_reporting() . "\n";

class inc {
    var $inc_var;
}
 [2004-09-22 23:04 UTC] andi@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

Certain E_STRICT notices (such as var being deprecated) are emited at compile-time therefore changing the error_reporting (which only happens at run-time) will not affect it. You will need to make sure that E_STRICT is turned off in the INI. One work around for the tests might be to put the source in an include file and change error_reporting before we include it. This issue was discussed on internals@ a few months back and this behavior was agreed on because some of these E_STRICT issues have to be detected at compile-time.
 [2004-09-22 23:43 UTC] derick@php.net
And you should use an --INI-- section in your test file for this anyway.
 [2004-09-23 00:10 UTC] danielc at analysisandsolutions dot com
Andi:

Thanks for the --INI-- tip.

Regarding your first email which said "make sure that E_STRICT is turned off in the INI," php.ini already had reporting set to E_ALL but it's being ignored.

The reason I posted it as a bug was this issue seems to have only arose in the recent past.  This issue hadn't come up while I was developing DB and HTML_Form even though I've been running snapshots of PHP 5 for a long while.

Thanks again.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 19:01:28 2024 UTC