|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #52517 E_COMPILE_WARNING is not
Submitted: 2010-08-02 18:51 UTC Modified: 2010-08-17 21:55 UTC
From: david at grudl dot com Assigned: kalle (profile)
Status: Closed Package: Compile Warning
PHP Version: 5.3.3 OS:
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.
Block user comment
Status: Assign to:
Bug Type:
From: david at grudl dot com
New email:
PHP Version: OS:

Further comment on this bug is unnecessary.


 [2010-08-02 18:51 UTC] david at grudl dot com
E_COMPILE_WARNING is the only run-time error not catchable by user-defined error handler function (via set_error_handler). I suggest change this behavior. 

Test script:

declare(foo='bar'); // throws E_COMPILE_WARNING


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-08-02 18:54 UTC] david at grudl dot com
"run-time error" -> "runtime warning"
 [2010-08-16 21:42 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-08-16 21:42 UTC]
The declare struct have meaning for the script at compile time, not execution time hence its an E_COMPILE_WARNING.
 [2010-08-17 18:43 UTC] david at grudl dot com
It is not about declare struct, it is about handing warnings & notices by user-handler (and logging them e.g.). I am unable to catch and log this warning. Please re-open this issue.
 [2010-08-17 20:20 UTC]
Yes it is, as declare is evaluated at compile time, not execution time hence its not possible to catch the warning anyway as its thrown before the executor is hit.
 [2010-08-17 21:47 UTC] david at grudl dot com
There is not difference between compile time or execution time. Compilation is invoked by "include" or "require" or "eval" in run time. So statements "require" throw E_COMPILE_WARNING and you cannot handle them using user-defined error handler.
 [2010-08-17 21:55 UTC]
-Block user comment: N +Block user comment: Y
 [2010-08-17 21:55 UTC]
There is alot of difference between them. Using your example code the declare statement is hit at compile time, so before the the executor is triggered that hooks into the error handler the warning is already thrown. Same things goes for includes, although they are as you rightly put it, executed at runtime. This is  how the Zend Engine is designed and not going to change.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 14 11:01:28 2024 UTC