Bug #69092 [Com]: Declare Encoding Compile Check Wrong
Edit report at https://bugs.php.net/bug.php?id=69092&edit=1
ID: 69092
Comment by: ircmaxell@php.net
Reported by: ircmaxell@php.net
Summary: Declare Encoding Compile Check Wrong
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: All
PHP Version: master-Git-2015-02-20 (Git)
Block user comment: N
Private report: N
New Comment:
Patched implementation for 7:
https://github.com/php/php-src/pull/1107
Previous Comments:
------------------------------------------------------------------------
[2015-02-20 15:34:29] ircmaxell@php.net
Description:
------------
The current compile-time error check for declare(encoding="...") is incorrect.
Declare is a parse-time only directive, which does not respect scope. The current compile-time
checks for the declare(encoding) directive only check to see if it's the first opcode in the
active oparray.
This is fine if the active oparray is a file, however if it is a function odd behavior will be
allowed. In the provided test script, "Bye" would be interpreted using the UTF-8 encoding
pragma, where "Hi" would use the default.
Test script:
---------------
<?php
echo "Hi";
function foo() {
declare(encoding="UTF-8");
}
echo "Bye";
Expected result:
----------------
Fatal error: Encoding declaration pragma must be the very first statement in the script
Actual result:
--------------
HiBye
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69092&edit=1
Thread (3 messages)