implement the solution for isset/string offsets, fix bug #60362

This commit is contained in:
Stanislav Malyshev 2011-12-19 02:05:03 +00:00
parent beda5efd41
commit 622412d8e6
18 changed files with 731 additions and 319 deletions

336
NEWS

File diff suppressed because it is too large Load Diff

112
UPGRADING
View File

@ -30,7 +30,7 @@ UPGRADE NOTES - PHP 5.4
========================================
- The default_charset setting now defaults to UTF-8.
It was ISO-88590-1 before, so if you were relying
It was ISO-88590-1 before, so if you were relying
on the default, you will need to add:
default_charset = iso-8859-1
@ -49,7 +49,7 @@ UPGRADE NOTES - PHP 5.4
to your php.ini to preserve pre-PHP5.4 behavior.
- Deprecated ini directives will now throw an E_CORE_WARNING's
- Deprecated ini directives will now throw an E_CORE_WARNING's
instead of the previous E_WARNING's.
The following directives are marked as deprecated:
@ -57,8 +57,8 @@ UPGRADE NOTES - PHP 5.4
- magic_quotes_runtime
- magic_quotes_sybase
- The following directives, which indicates a removed feature
in PHP will now throw an E_CORE_ERROR upon startup like the
- The following directives, which indicates a removed feature
in PHP will now throw an E_CORE_ERROR upon startup like the
deprecation warnings.
The following directives are no longer available:
@ -78,7 +78,7 @@ UPGRADE NOTES - PHP 5.4
- the following new directives were added
- max_input_vars - specifies how many GET/POST/COOKIE input variables may be
accepted. default value 1000.
accepted. default value 1000.
=============================
2. Reserved words and classes
@ -101,7 +101,7 @@ UPGRADE NOTES - PHP 5.4
{
public function __construct($bar) {}
}
Now emits a Fatal error due the incompatible declaration.
- In previous versions, names of superglobals could be used for parameter
@ -118,12 +118,18 @@ UPGRADE NOTES - PHP 5.4
$test = new StdClass;
$test->baz = 1;
- Converting array to string now will cause E_NOTICE warning.
- Converting array to string now will cause E_NOTICE warning.
- Chained string offsets - e.g. $a[0][0] where $a is a string - now work, which
means isset($a['foo']['bar']) now will return true due to automatic type conversion.
- Chained string offsets - e.g. $a[0][0] where $a is a string - now work.
- Changed E_ALL to include E_STRICT.
- Non-numeric string offsets - e.g. $a['foo'] where $a is a string - now return
false on isset() and true on empty(), and produce warning if trying to use them.
Offsets of types double, bool and null produce notice. Numeric strings ($a['2'])
still work as before.
Note that offsets like '12.3' and '5 and a half' are considered non-numeric
and produce warning, but are converted to 12 and 5 respectively for BC reasons.
- Changed E_ALL to include E_STRICT.
- Closures now support scopes and $this and can be rebound to
objects using Closure::bind() and Closure::bindTo().
@ -133,7 +139,7 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- <?= is now always available regardless of the short_open_tag setting.
- Parse error messages are changed to contain more information about the error.
- Parse error messages are changed to contain more information about the error.
=====================================
4. Changes made to existing functions
@ -212,22 +218,22 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- Added AES support to OpenSSL.
- openssl_csr_new() expects the textual data to be in UTF-8.
- Added no padding option to openssl_encrypt()/openssl_decrypt().
- Added a "no_ticket" SSL context option to disable the SessionTicket TLS
- Added a "no_ticket" SSL context option to disable the SessionTicket TLS
extension.
- Added new json_encode() options: JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES,
- Added new json_encode() options: JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES,
JSON_NUMERIC_CHECK, JSON_BIGINT_AS_STRING, JSON_UNESCAPED_UNICODE.
- Added Tokyo Cabinet and Berkley DB 5 support to DBA extension.
- Added support for CURLOPT_MAX_SEND_SPEED_LARGE and CURLOPT_MAX_RECV_SPEED_LARGE
to cURL.
- Added optional argument to debug_backtrace() and debug_print_backtrace()
- Added optional argument to debug_backtrace() and debug_print_backtrace()
to limit the amount of stack frames returned.
- Fixed crypt_blowfish handling of 8-bit characters. crypt() in Blowfish mode
now supports hashes marked $2a$, $2x$, $2y$ and $2z$.
- mbstring now supports following encodings: Shift_JIS/UTF-8 Emoji,
JIS X0213:2004 (Shift_JIS-2004, EUC-JP-2004, ISO-2022-JP-2004),
now supports hashes marked $2a$, $2x$, $2y$ and $2z$.
- mbstring now supports following encodings: Shift_JIS/UTF-8 Emoji,
JIS X0213:2004 (Shift_JIS-2004, EUC-JP-2004, ISO-2022-JP-2004),
MacJapanese (Shift_JIS), gb18030.
- Added encode/decode in hex format to mb_[en|de]code_numericentity().
- Added support for SORT_NATURAL and SORT_FLAG_CASE in array sort functions
- Added support for SORT_NATURAL and SORT_FLAG_CASE in array sort functions
(sort, rsort, ksort, krsort, asort, arsort and array_multisort).
- is_a() and is_subclass_of() now have third boolean parameter, which specifies
if the first argument can be a string class name. Default if false for is_a
@ -243,7 +249,7 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
5. Changes made to existing methods
===================================
- DateTime::parseFromFormat() now has + modifier to allow trailing text in
- DateTime::parseFromFormat() now has + modifier to allow trailing text in
the string to parse without throwing an error.
- Added the ability to pass options to DOMDocument::loadHTML().
- FilesystemIterator, GlobIterator and (Recursive)DirectoryIterator now use
@ -281,8 +287,8 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
a. removed features
- magic quotes
. remove magic_quotes_gpc, magic_quotes_runtime,
magic_quotes_sybase (calling ini_set('magic_....')
. remove magic_quotes_gpc, magic_quotes_runtime,
magic_quotes_sybase (calling ini_set('magic_....')
returns 0|false
. get_magic_quotes_gpc, get_magic_quotes_runtime are kept but
always return false
@ -347,10 +353,10 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- PDO_mysql: Support for linking with MySQL client libraries older
than 4.1 is removed.
- The session extension now can hook into the file upload feature
in order to provide upload progress information through session
in order to provide upload progress information through session
variables.
- SNMP extension
- Functions in SNMP extension now returns FALSE on every error
- Functions in SNMP extension now returns FALSE on every error
condition including SNMP-related (no such instance, end of MIB,
etc). Thus, in patricular, breaks previous behaviour of get/walk
functions returning an empty string on SNMP-related errors.
@ -358,7 +364,7 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- New constants added for use in snmp_set_oid_output_format()
function.
- Function snmp_set_valueretrieval() changed it's behaviour:
SNMP_VALUE_OBJECT can be combined with one of
SNMP_VALUE_OBJECT can be combined with one of
SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY resulting OID value
changes. When no SNMP_VALUE_PLAIN or SNMP_VALUE_LIBRARY
is supplied with SNMP_VALUE_OBJECT, SNMP_VALUE_LIBRARY is used.
@ -370,7 +376,7 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- In sake of adding support for IPv6 DNS name resolution of
remote SNMP agent (peer) is done by extension now, not by Net-SNMP
library anymore.
- Date extension
- Setting the timezone with the TZ environment variable is no longer
supported, instead date.timezone and/or date_default_timezone_set()
@ -387,12 +393,12 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- The REQUEST_TIME value inside server now returns a floating point number
indicating the time with microsecond precision. All SAPIs providing this
value should be returning float and not time_t.
- apache_child_terminate(), getallheaders(), apache_request_headers()
- apache_child_terminate(), getallheaders(), apache_request_headers()
and apache_response_headers() now supported on FastCGI.
- Added shortcut #inisetting=value to change ini settings at run-time.
- Changed shell not to terminate on fatal errors.
- Interactive shell works with shared readline extension.
- Added command line option --rz <name> which shows information of the
- Added command line option --rz <name> which shows information of the
named Zend extension.
- PHP-FPM now supports syslog value for error_log.
@ -400,10 +406,10 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
11. Changes in INI directives
=============================
- Recommended production value for error_reporting changed to
- Recommended production value for error_reporting changed to
E_ALL & ~E_DEPRECATED & ~E_STRICT.
- Added session.upload_progress.enabled, session.upload_progress.cleanup,
session.upload_progress.prefix, session.upload_progress.name,
- Added session.upload_progress.enabled, session.upload_progress.cleanup,
session.upload_progress.prefix, session.upload_progress.name,
session.upload_progress.freq, session.upload_progress.min_freq.
- Added zend.multibyte directive as a replacement of PHP compile time
configuration option --enable-zend-multibyte. Now ZE always contains code for
@ -418,7 +424,7 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
three times.
- A new directive, called windows_show_crt_warning, has been introduced.
This directive shows the CRT warnings when enabled. These warnings were
displayed by default until now. It is disabled by default.
displayed by default until now. It is disabled by default.
- Added cli.pager php.ini setting to set a pager for CLI output.
- Added cli.prompt php.ini setting to configure the CLI shell prompt.
- Added process.max to control the number of process FPM can fork.
@ -434,12 +440,12 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
}
class CanIGetHello {
use HelloWorld;
use HelloWorld;
}
$hello = new CanIGetHello();
$hello->sayHello();
- Function call result array access:
e.g.
foo()[0]
@ -464,17 +470,17 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- $str[1][0] where $str is a string is now a legal construct.
- Anonymous functions now support using $this and class scope.
- Anonymous functions now support using $this and class scope.
Anonymous function can be declared as "static" to ignore the scope.
- Class::{expr}() syntax is now supported:
class A {
static function foo() {
class A {
static function foo() {
echo "Hello world!\n";
}
}
$x = "f";
$y = "o";
}
$x = "f";
$y = "o";
A::{$x.$y.$y}();
- Class member access on instantiation:
@ -486,7 +492,7 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
13. Windows support
===================
- is_link now works properly for symbolic links on Windows Vista
- is_link now works properly for symbolic links on Windows Vista
or later. Earlier systems do not support symbolic links.
===================
@ -513,22 +519,22 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- transliterator_get_error_message()
- transliterator_list_ids()
- transliterator_transliterate()
- LDAP:
- ldap_control_paged_results()
- ldap_control_paged_results_response()
- libxml:
- libxml_set_external_entity_loader()
- mysqli:
- mysqli_error_list()
- mysqli_stmt_error_list()
- Session:
- session_register_shutdown()
- session_status()
- SPL
- class_uses()
@ -627,17 +633,17 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- Reflection:
- ReflectionZendExtension
- Intl:
- Transliterator
- Spoofchecker
- JSON:
- JsonSerializable
- Session:
- Session:
- SessionHandler
- SNMP:
- SNMP
@ -647,9 +653,9 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
d. New methods
- Closure:
- Closure:
- Closure::bind()
- Closure::bindTo()
- Closure::bindTo()
- Reflection:
- ReflectionClass::getTraitAliases()
@ -714,5 +720,5 @@ means isset($a['foo']['bar']) now will return true due to automatic type convers
- joaat

View File

@ -17,7 +17,7 @@ var_dump(isset($a['b']));
$simpleString = "Bogus String Text";
echo isset($simpleString->wrong)?"bug\n":"ok\n";
echo isset($simpleString["wrong"])?"ok\n":"bug\n";
echo isset($simpleString["wrong"])?"bug\n":"ok\n";
echo isset($simpleString[-1])?"bug\n":"ok\n";
echo isset($simpleString[0])?"ok\n":"bug\n";
echo isset($simpleString["0"])?"ok\n":"bug\n";
@ -34,8 +34,8 @@ bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
bool(false)
bool(false)
ok
ok
ok
@ -44,8 +44,12 @@ ok
ok
ok
Notice: Trying to get property of non-object in %sbug31098.php on line %d
ok
ok
Notice: Trying to get property of non-object in %s on line %d
ok
Warning: Illegal string offset 'wrong' in %s on line %d
ok
ok
Warning: Illegal string offset 'wrong' in %s on line %d
ok

View File

@ -6,7 +6,7 @@ Bug #39018 (Error control operator '@' fails to suppress "Uninitialized string o
error_reporting(E_ALL);
$a = 'foo';
$a[11111111111];
$a[111111111111111111111];
$a = '';
@ -62,31 +62,42 @@ print "\nDone\n";
?>
--EXPECTF--
Notice: String offset cast occured in %s on line %d
Notice: Uninitialized string offset: %i in %s on line 6
Notice: Uninitialized string offset: 0 in %s on line %d
Notice: Uninitialized string offset: 0 in %s on line 10
Notice: Uninitialized string offset: 0 in %s on line %d
Notice: Uninitialized string offset: 0 in %s on line 12
Notice: String offset cast occured in %s on line %d
Notice: Uninitialized string offset: %i in %s on line 14
Notice: Uninitialized string offset: %i in %s on line %d
Notice: Uninitialized string offset: %i in %s on line 16
Notice: String offset cast occured in %s on line %d
Notice: Uninitialized string offset: 0 in %s on line 18
Notice: Uninitialized string offset: %i in %s on line %d
Notice: Uninitialized string offset: 4 in %s on line 28
Notice: Uninitialized string offset: 0 in %s on line %d
Notice: Uninitialized string offset: 4 in %s on line 34
Notice: Uninitialized string offset: 4 in %s on line %d
Notice: Uninitialized string offset: 4 in %s on line 38
Notice: Uninitialized string offset: 4 in %s on line %d
Notice: Uninitialized string offset: 4 in %s on line 42
Notice: Uninitialized string offset: 4 in %s on line %d
Notice: Uninitialized string offset: 4 in %s on line 46
Notice: Uninitialized string offset: 4 in %s on line %d
Notice: Uninitialized string offset: 12 in %s on line 50
Notice: Uninitialized string offset: 4 in %s on line %d
Notice: Uninitialized string offset: 12 in %s on line 52
Notice: String offset cast occured in %s on line %d
Notice: Uninitialized string offset: 12 in %s on line %d
Notice: String offset cast occured in %s on line %d
Notice: Uninitialized string offset: 12 in %s on line %d
Notice: String offset cast occured in %s on line %d
Notice: String offset cast occured in %s on line %d
b
Done

View File

@ -7,10 +7,10 @@ Bug #39304 (Segmentation fault with list unpacking of string offset)
echo "I am alive";
?>
--EXPECTF--
Notice: Uninitialized string offset: 0 in %sbug39304.php on line 3
Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d
Notice: Uninitialized string offset: 1 in %sbug39304.php on line 3
Notice: Uninitialized string offset: 1 in %sbug39304.php on line %d
Notice: Uninitialized string offset: 0 in %sbug39304.php on line 3
Notice: Uninitialized string offset: 0 in %sbug39304.php on line %d
I am alive

View File

@ -9,10 +9,10 @@ Bug #39304 (Segmentation fault with list unpacking of string offset)
var_dump($a,$b);
?>
--EXPECTF--
Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line 3
Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d
Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line 3
Notice: Uninitialized string offset: 1 in %sbug39304_2_4.php on line %d
Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line 3
Notice: Uninitialized string offset: 0 in %sbug39304_2_4.php on line %d
string(0) ""
string(0) ""

View File

@ -9,7 +9,7 @@ $simpleString["wrong"] = "f";
echo "ok\n";
?>
--EXPECTF--
bool(true)
bool(false)
Warning: Attempt to modify property of non-object in %sbug54262.php on line 4

74
Zend/tests/bug60362.phpt Normal file
View File

@ -0,0 +1,74 @@
--TEST--
Bug #60362: non-existent sub-sub keys should not have values
--FILE--
<?php
$arr = array('exists' => 'foz');
if (isset($arr['exists']['non_existent'])) {
echo "sub-key 'non_existent' is set: ";
var_dump($arr['exists']['non_existent']);
} else {
echo "sub-key 'non_existent' is not set.\n";
}
if (isset($arr['exists'][1])) {
echo "sub-key 1 is set: ";
var_dump($arr['exists'][1]);
} else {
echo "sub-key 1 is not set.\n";
}
echo "-------------------\n";
if (isset($arr['exists']['non_existent']['sub_sub'])) {
echo "sub-key 'sub_sub' is set: ";
var_dump($arr['exists']['non_existent']['sub_sub']);
} else {
echo "sub-sub-key 'sub_sub' is not set.\n";
}
if (isset($arr['exists'][1][0])) {
echo "sub-sub-key 0 is set: ";
var_dump($arr['exists'][1][0]);
} else {
echo "sub-sub-key 0 is not set.\n";
}
echo "-------------------\n";
if (empty($arr['exists']['non_existent'])) {
echo "sub-key 'non_existent' is empty.\n";
} else {
echo "sub-key 'non_existent' is not empty: ";
var_dump($arr['exists']['non_existent']);
}
if (empty($arr['exists'][1])) {
echo "sub-key 1 is empty.\n";
} else {
echo "sub-key 1 is not empty: ";
var_dump($arr['exists'][1]);
}
echo "-------------------\n";
if (empty($arr['exists']['non_existent']['sub_sub'])) {
echo "sub-sub-key 'sub_sub' is empty.\n";
} else {
echo "sub-sub-key 'sub_sub' is not empty: ";
var_dump($arr['exists']['non_existent']['sub_sub']);
}
if (empty($arr['exists'][1][0])) {
echo "sub-sub-key 0 is empty.\n";
} else {
echo "sub-sub-key 0 is not empty: ";
var_dump($arr['exists'][1][0]);
}
echo "DONE";
--EXPECT--
sub-key 'non_existent' is not set.
sub-key 1 is set: string(1) "o"
-------------------
sub-sub-key 'sub_sub' is not set.
sub-sub-key 0 is set: string(1) "o"
-------------------
sub-key 'non_existent' is empty.
sub-key 1 is not empty: string(1) "o"
-------------------
sub-sub-key 'sub_sub' is empty.
sub-sub-key 0 is not empty: string(1) "o"
DONE

View File

@ -0,0 +1,91 @@
--TEST--
Testing empty() with string offsets
--FILE--
<?php
print "- empty ---\n";
$str = "test0123";
var_dump(empty($str[-1]));
var_dump(empty($str[0]));
var_dump(empty($str[1]));
var_dump(empty($str[4])); // 0
var_dump(empty($str[5])); // 1
var_dump(empty($str[8]));
var_dump(empty($str[10000]));
// non-numeric offsets
print "- string ---\n";
var_dump(empty($str['-1']));
var_dump(empty($str['0']));
var_dump(empty($str['1']));
var_dump(empty($str['4'])); // 0
var_dump(empty($str['1.5']));
var_dump(empty($str['good']));
var_dump(empty($str['3 and a half']));
print "- bool ---\n";
var_dump(empty($str[true]));
var_dump(empty($str[false]));
var_dump(empty($str[false][true]));
print "- null ---\n";
var_dump(empty($str[null]));
print "- double ---\n";
var_dump(empty($str[-1.1]));
var_dump(empty($str[-0.8]));
var_dump(empty($str[-0.1]));
var_dump(empty($str[0.2]));
var_dump(empty($str[0.9]));
var_dump(empty($str[M_PI]));
var_dump(empty($str[100.5001]));
print "- array ---\n";
var_dump(empty($str[array()]));
var_dump(empty($str[array(1,2,3)]));
print "- object ---\n";
var_dump(empty($str[new stdClass()]));
print "- resource ---\n";
$f = fopen(__FILE__, 'r');
var_dump(empty($str[$f]));
print "done\n";
?>
--EXPECTF--
- empty ---
bool(true)
bool(false)
bool(false)
bool(true)
bool(false)
bool(true)
bool(true)
- string ---
bool(true)
bool(false)
bool(false)
bool(true)
bool(true)
bool(true)
Notice: A non well formed numeric value encountered in %s line %d
bool(false)
- bool ---
bool(false)
bool(false)
bool(true)
- null ---
bool(false)
- double ---
bool(true)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
- array ---
bool(true)
bool(true)
- object ---
bool(true)
- resource ---
bool(true)
done

View File

@ -71,6 +71,8 @@ array(1) {
}
}
Warning: Illegal string offset 'foo' in %s on line %d
Notice: Array to string conversion in %s on line %d
string(1) "A"

View File

@ -0,0 +1,91 @@
--TEST--
Testing isset with string offsets
--FILE--
<?php
print "- isset ---\n";
$str = "test0123";
var_dump(isset($str[-1]));
var_dump(isset($str[0]));
var_dump(isset($str[1]));
var_dump(isset($str[4])); // 0
var_dump(isset($str[5])); // 1
var_dump(isset($str[8]));
var_dump(isset($str[10000]));
// non-numeric offsets
print "- string ---\n";
var_dump(isset($str['-1']));
var_dump(isset($str['0']));
var_dump(isset($str['1']));
var_dump(isset($str['4'])); // 0
var_dump(isset($str['1.5']));
var_dump(isset($str['good']));
var_dump(isset($str['3 and a half']));
print "- bool ---\n";
var_dump(isset($str[true]));
var_dump(isset($str[false]));
var_dump(isset($str[false][true]));
print "- null ---\n";
var_dump(isset($str[null]));
print "- double ---\n";
var_dump(isset($str[-1.1]));
var_dump(isset($str[-0.8]));
var_dump(isset($str[-0.1]));
var_dump(isset($str[0.2]));
var_dump(isset($str[0.9]));
var_dump(isset($str[M_PI]));
var_dump(isset($str[100.5001]));
print "- array ---\n";
var_dump(isset($str[array()]));
var_dump(isset($str[array(1,2,3)]));
print "- object ---\n";
var_dump(isset($str[new stdClass()]));
print "- resource ---\n";
$f = fopen(__FILE__, 'r');
var_dump(isset($str[$f]));
print "done\n";
?>
--EXPECTF--
- isset ---
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
- string ---
bool(false)
bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
Notice: A non well formed numeric value encountered in %s line %d
bool(true)
- bool ---
bool(true)
bool(true)
bool(false)
- null ---
bool(true)
- double ---
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
bool(false)
- array ---
bool(false)
bool(false)
- object ---
bool(false)
- resource ---
bool(false)
done

View File

@ -3,9 +3,11 @@ Crash on $x['x']['y'] += 1 when $x is string
--FILE--
<?php
$x = "a";
$x['x']['y'] += 1;
$x['x']['y'] += 1;
echo "Done\n";
?>
--EXPECTF--
Fatal error: Cannot use string offset as an array in %s on line %d
--EXPECTF--
Warning: Illegal string offset 'x' in %soffset_assign.php on line %d
Fatal error: Cannot use string offset as an array in %soffset_assign.php on line %d

View File

@ -9,6 +9,9 @@ var_dump($str[1]);
var_dump($str[0.0836]);
var_dump($str[NULL]);
var_dump($str["run away"]);
var_dump($str["13"]);
var_dump($str["14.5"]);
var_dump($str["15 and then some"]);
var_dump($str[TRUE]);
var_dump($str[FALSE]);
@ -24,12 +27,29 @@ var_dump($str[$arr]);
echo "Done\n";
?>
--EXPECTF--
--EXPECTF--
string(1) "i"
Notice: String offset cast occured in %s on line %d
string(1) "S"
Notice: String offset cast occured in %s on line %d
string(1) "S"
Warning: Illegal string offset 'run away' in %s on line %d
string(1) "S"
string(1) "c"
Warning: Illegal string offset '14.5' in %s on line %d
string(1) "o"
Notice: A non well formed numeric value encountered in %s on line %d
string(1) "r"
Notice: String offset cast occured in %s on line %d
string(1) "i"
Notice: String offset cast occured in %s on line %d
string(1) "S"
Warning: Illegal offset type in %s on line %d
@ -42,4 +62,4 @@ string(1) "%s"
Warning: Illegal offset type in %s on line %d
string(1) "i"
Done
Done

View File

@ -24,6 +24,6 @@ $x->prop;
$x->y;
echo "ok\n";
--EXPECTF--
Notice: Uninitialized string offset: 3 in %sresult_unused.php on line 11
Notice: Uninitialized string offset: 3 in %sresult_unused.php on line %d
ok

View File

@ -24,28 +24,28 @@ foo($str[1][0]);
foo($str[2][1]);
?>
--EXPECTF--
Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line 7
Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
string(0) ""
string(1) "a"
string(1) "b"
string(1) "c"
Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line 11
Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
string(0) ""
string(1) "b"
Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line 13
Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
string(0) ""
Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line 15
Notice: Uninitialized string offset: -1 in %sstr_offset_001.php on line %d
string(0) ""
string(1) "a"
string(1) "b"
string(1) "c"
Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line 19
Notice: Uninitialized string offset: 3 in %sstr_offset_001.php on line %d
string(0) ""
string(1) "b"
Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line 21
Notice: Uninitialized string offset: 1 in %sstr_offset_001.php on line %d
string(0) ""

View File

@ -1147,13 +1147,22 @@ convert_to_array:
}
if (Z_TYPE_P(dim) != IS_LONG) {
switch(Z_TYPE_P(dim)) {
/* case IS_LONG: */
case IS_STRING:
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
break;
}
if (type != BP_VAR_UNSET) {
zend_error(E_WARNING, "Illegal string offset '%s'", dim->value.str.val);
}
break;
case IS_DOUBLE:
case IS_NULL:
case IS_BOOL:
/* do nothing */
zend_error(E_NOTICE, "String offset cast occured");
break;
default:
zend_error(E_WARNING, "Illegal offset type");
@ -1265,10 +1274,19 @@ static void zend_fetch_dimension_address_read(temp_variable *result, zval **cont
switch(Z_TYPE_P(dim)) {
/* case IS_LONG: */
case IS_STRING:
if (IS_LONG == is_numeric_string(Z_STRVAL_P(dim), Z_STRLEN_P(dim), NULL, NULL, -1)) {
break;
}
if (type != BP_VAR_IS) {
zend_error(E_WARNING, "Illegal string offset '%s'", dim->value.str.val);
}
break;
case IS_DOUBLE:
case IS_NULL:
case IS_BOOL:
/* do nothing */
if (type != BP_VAR_IS) {
zend_error(E_NOTICE, "String offset cast occured");
}
break;
default:
zend_error(E_WARNING, "Illegal offset type");

View File

@ -2391,7 +2391,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
CHECK_EXCEPTION();
ZEND_VM_NEXT_OPCODE();
} else if (OP2_TYPE != IS_CONST &&
EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) &&
zend_hash_num_elements(Z_ARRVAL_P(function_name)) == 2) {
zend_class_entry *ce;
zval **method = NULL;
@ -2399,15 +2399,15 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
zend_hash_index_find(Z_ARRVAL_P(function_name), 0, (void **) &obj);
zend_hash_index_find(Z_ARRVAL_P(function_name), 1, (void **) &method);
if (Z_TYPE_PP(obj) != IS_STRING && Z_TYPE_PP(obj) != IS_OBJECT) {
zend_error_noreturn(E_ERROR, "First array member is not a valid class name or object");
}
if (Z_TYPE_PP(method) != IS_STRING) {
zend_error_noreturn(E_ERROR, "Second array member is not a valid method");
}
if (Z_TYPE_PP(obj) == IS_STRING) {
ce = zend_fetch_class_by_name(Z_STRVAL_PP(obj), Z_STRLEN_PP(obj), NULL, 0 TSRMLS_CC);
if (UNEXPECTED(ce == NULL)) {
@ -2415,7 +2415,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
}
EX(called_scope) = ce;
EX(object) = NULL;
if (ce->get_static_method) {
EX(fbc) = ce->get_static_method(ce, Z_STRVAL_PP(method), Z_STRLEN_PP(method) TSRMLS_CC);
} else {
@ -2429,7 +2429,7 @@ ZEND_VM_HANDLER(59, ZEND_INIT_FCALL_BY_NAME, ANY, CONST|TMP|VAR|CV)
if (UNEXPECTED(EX(fbc) == NULL)) {
zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), Z_STRVAL_PP(method));
}
if ((EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) != 0) {
EX(object) = NULL;
} else {
@ -4507,10 +4507,17 @@ ZEND_VM_C_LABEL(num_index_prop):
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {

View File

@ -14035,10 +14035,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -15941,10 +15948,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -18205,10 +18219,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -21119,10 +21140,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -22446,10 +22474,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -23596,10 +23631,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -24746,10 +24788,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -26162,10 +26211,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -29470,10 +29526,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -31250,10 +31313,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -33387,10 +33457,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {
@ -36038,10 +36115,17 @@ num_index_prop:
zval tmp;
if (Z_TYPE_P(offset) != IS_LONG) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
if (Z_TYPE_P(offset) <= IS_BOOL /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, -1))) {
ZVAL_COPY_VALUE(&tmp, offset);
zval_copy_ctor(&tmp);
convert_to_long(&tmp);
offset = &tmp;
} else {
/* can not be converted to proper offset, return "not set" */
result = 0;
}
}
if (Z_TYPE_P(offset) == IS_LONG) {
if (opline->extended_value & ZEND_ISSET) {