|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43786 declare() should complain with invalid directive
Submitted: 2008-01-08 12:36 UTC Modified: 2008-01-09 08:39 UTC
From: zabmilenko at charter dot net Assigned:
Status: Wont fix Package: Unknown/Other Function
PHP Version: 5.2.5 OS: Any
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: zabmilenko at charter dot net
New email:
PHP Version: OS:


 [2008-01-08 12:36 UTC] zabmilenko at charter dot net
If you use a misspelled or unknown directive in a declare() statement, no error or warning is produced.  To help in debugging, at least a warning should be raised if a directive is used that is not known to the php engine.

Reproduce code:
    echo 'Hello, world';

Expected result:
Perhaps an error or warning stating that the declare directive is unknown or invalid.

Actual result:
Blocked up code executes like expected but nothing occurs with the declare() statement.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-08 13:25 UTC] zabmilenko at charter dot net
I solved this by adding the following just before line 4705 of ZendEngine2/zend_compile.c (rev 1.796):

// Raise a warning
zend_error(E_COMPILE_WARNING, "Illegal directive [%s]", Z_STRVAL(var->u.constant));

It appears to work on my Debian Etch box, but I don't know if Z_STRVAL is 100% appropriate.  Thanks and have a nice day.
 [2008-01-08 17:53 UTC]
I think it's intentional. It at lest helps with PHP 6 compatibility :-)


and such work in PHP 5 and PHP 6 - meaning that PHP 5 ignores it and PHP 6 uses that encoding while parsing the file.
 [2008-01-09 08:31 UTC] zabmilenko at charter dot net
That makes sense.  Would E_STRICT be appropriate in place of E_COMPILE_WARNING then?
 [2008-01-09 08:39 UTC]
No... not at all. It is meant not to show anything because of forwards compatibility between PHP 5.3 and PHP 6.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 09:01:32 2024 UTC