#43786 [Opn->WFx]: declare() should complain with invalid directive

From: Date: Wed, 09 Jan 2008 08:39:43 +0000
Subject: #43786 [Opn->WFx]: declare() should complain with invalid directive
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121154@lists.php.net to get a copy of this message
ID: 43786 Updated by: derick@php.net Reported By: zabmilenko at charter dot net -Status: Open +Status: Wont fix Bug Type: Unknown/Other Function Operating System: Any PHP Version: 5.2.5 New Comment: No... not at all. It is meant not to show anything because of forwards compatibility between PHP 5.3 and PHP 6. Previous Comments: ------------------------------------------------------------------------ [2008-01-09 08:31:56] zabmilenko at charter dot net That makes sense. Would E_STRICT be appropriate in place of E_COMPILE_WARNING then? ------------------------------------------------------------------------ [2008-01-08 17:53:33] johannes@php.net I think it's intentional. It at lest helps with PHP 6 compatibility :-) declare(encoding="iso-8859-1"); 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-08 13:25:01] 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 12:36:29] zabmilenko at charter dot net Description: ------------ 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: --------------- <?php declare(foobar="baz") { 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43786&edit=1

« previous php.bugs (#121154) next »