Edit report at https://bugs.php.net/bug.php?id=62769&edit=1
ID: 62769 Updated by: larue...@php.net Reported by: julien at palard dot fr Summary: Inconsistent notice reporting using [] Status: Open Type: Bug Package: Output Control PHP Version: 5.4.5 Block user comment: N Private report: N New Comment: const array dereference is only in trunk Previous Comments: ------------------------------------------------------------------------ [2012-08-07 14:42:36] julien at palard dot fr Description: ------------ Error reported for invalid [] access seems inconsistent : echo NULL["bar"] -> Parse error echo []["bar"] -> Parse error $foo = NULL; echo $foo["bar"] -> Fails silently $foo = []; echo $foo["bar"] -> Notice: Undefined index class Bar {} ; $foo = new Bar(); echo $foo["bar"]; -> PHP Fatal error I whish : []["bar"] to trigger Notice: Undefined index NULL["bar"] to trigger something catcheable with set_error_handler $foo = NULL; $foo["bar"] to trigger a catcheable Notice. Test script: --------------- /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); echo []["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); echo NULL["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); $foo = NULL; $foo["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); $foo = []; $foo["bar"];' /usr/local/php-5.4.5/bin/php -r 'error_reporting(-1); class Bar {} ; $foo = new Bar(); echo $foo["bar"];' Expected result: ---------------- At least get a Notice on : $foo = NULL; echo $foo["bar"]; Actual result: -------------- Fails silently. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62769&edit=1