scottmac Fri, 31 Dec 2010 16:57:45 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=306931
Log: Silently casting an empty string, null or false into an object by adding a property is pretty non-intuitive. If the same value was 1 or true you get a warning and it halts. Since we can't break BC completely (yet) lets bump this from E_STRICT. Also added a new section to UPGRADING for engine changes. <?php $x = ''; // $x = null; // $x = false; $x->baz = 1; var_dump($x); $y = 1; $y->baz = 1; var_dump($y); Changed paths: U php/php-src/trunk/NEWS U php/php-src/trunk/UPGRADING U php/php-src/trunk/Zend/tests/026.phpt U php/php-src/trunk/Zend/tests/033.phpt U php/php-src/trunk/Zend/tests/bug52041.phpt U php/php-src/trunk/Zend/tests/bug52614.phpt U php/php-src/trunk/Zend/zend_execute.c U php/php-src/trunk/ext/dom/tests/bug47430.phpt U php/php-src/trunk/ext/reflection/tests/bug40431.phpt U php/php-src/trunk/tests/classes/implicit_instantiation_001.phpt
Modified: php/php-src/trunk/NEWS =================================================================== --- php/php-src/trunk/NEWS 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/NEWS 2010-12-31 16:57:45 UTC (rev 306931) @@ -27,6 +27,8 @@ - Changed array_combine() to return empty array instead of FALSE when both parameter arrays are empty. FR #34857. (joel.per...@gmail.com) - Changed third parameter of preg_match_all() to optional. FR #53238. (Adam) +- Changed silent casting of null/''/false into an Object when adding + a property into a warning. (Scott) - General improvements: . Added multibyte suppport by default. Previosly php had to be compiled Modified: php/php-src/trunk/UPGRADING =================================================================== --- php/php-src/trunk/UPGRADING 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/UPGRADING 2010-12-31 16:57:45 UTC (rev 306931) @@ -4,19 +4,19 @@ 1. Changes made to default configuration 2. Reserved words and classes -3. Changes made to existing functions -4. Changes made to existing methods -5. Changes made to existing classes -6. Deprecated -7. Removed -8. Extensions: +3. Changes made to engine behaviour +4. Changes made to existing functions +5. Changes made to existing methods +6. Changes made to existing classes +7. Deprecated +8. Removed +9. Extensions: a. moved out to PECL and actively maintained there b. no longer maintained c. with changed behaviour d. no longer possible to disable -9. Changes in SAPI support -10. Changes in INI directives -11. Syntax additions +10. Changes in SAPI support +11. Changes in INI directives 12. Syntax additions 13. Windows support 14. New in PHP X.Y: @@ -87,8 +87,22 @@ - +============================= +3. Changes made to engine behaviour +============================= + +- Turning null, false or empty string into an object by adding a property + will now emit a warning instead of an E_STRICT error. + + $test = null; + $test->baz = 1; + + To create a generic object you can use StdClass: + $test = new StdClass; + $text->baz = 1; + ===================================== -3. Changes made to existing functions +4. Changes made to existing functions ===================================== - array_combine now returns array() instead of FALSE when two empty arrays are @@ -150,23 +164,23 @@ =================================== -4. Changes made to existing methods +5. Changes made to existing methods =================================== - =================================== -5. Changes made to existing classes +6. Changes made to existing classes =================================== - ============= -6. Deprecated +7. Deprecated ============= ========== -7. Removed +8. Removed ========== a. removed features @@ -215,7 +229,7 @@ - continue $var; ============= -8. Extensions +9. Extensions ============= a. moved out to PECL and actively maintained there @@ -237,7 +251,7 @@ - ========================== -9. Changes in SAPI support +10. Changes in SAPI support ========================== - The REQUEST_TIME value inside server now returns a floating point number @@ -245,7 +259,7 @@ value should be returning float and not time_t. ============================= -10. Changes in INI directives +11. Changes in INI directives ============================= - Added session.upload_progress.enabled, session.upload_progress.cleanup, @@ -264,7 +278,7 @@ three times. ==================== -11. Syntax additions +12. Syntax additions ==================== - Array dereferencing. @@ -273,14 +287,14 @@ $foo->bar()[0] =================== -12. Windows support +13. Windows support =================== - is_link now works properly for symbolic links on Windows Vista or later. Earlier systems do not support symbolic links. =================== -13. New in PHP X.Y: +14. New in PHP X.Y: =================== a. New libraries Modified: php/php-src/trunk/Zend/tests/026.phpt =================================================================== --- php/php-src/trunk/Zend/tests/026.phpt 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/Zend/tests/026.phpt 2010-12-31 16:57:45 UTC (rev 306931) @@ -21,5 +21,5 @@ Notice: Trying to get property of non-object in %s on line %d ok -Strict Standards: Creating default object from empty value in %s on line %d +Warning: Creating default object from empty value in %s on line %d ok Modified: php/php-src/trunk/Zend/tests/033.phpt =================================================================== --- php/php-src/trunk/Zend/tests/033.phpt 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/Zend/tests/033.phpt 2010-12-31 16:57:45 UTC (rev 306931) @@ -26,6 +26,6 @@ Notice: Trying to get property of non-object in %s on line %d -Strict Standards: Creating default object from empty value in %s on line %d +Warning: Creating default object from empty value in %s on line %d -Strict Standards: Creating default object from empty value in %s on line %d +Warning: Creating default object from empty value in %s on line %d Modified: php/php-src/trunk/Zend/tests/bug52041.phpt =================================================================== --- php/php-src/trunk/Zend/tests/bug52041.phpt 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/Zend/tests/bug52041.phpt 2010-12-31 16:57:45 UTC (rev 306931) @@ -25,27 +25,27 @@ --EXPECTF-- Notice: Undefined variable: x in %sbug52041.php on line 3 -Strict Standards: Creating default object from empty value in %sbug52041.php on line 6 +Warning: Creating default object from empty value in %sbug52041.php on line 6 Notice: Undefined variable: x in %sbug52041.php on line 3 -Strict Standards: Creating default object from empty value in %sbug52041.php on line 7 +Warning: Creating default object from empty value in %sbug52041.php on line 7 Notice: Undefined variable: x in %sbug52041.php on line 3 -Strict Standards: Creating default object from empty value in %sbug52041.php on line 8 +Warning: Creating default object from empty value in %sbug52041.php on line 8 Notice: Undefined variable: x in %sbug52041.php on line 3 -Strict Standards: Creating default object from empty value in %sbug52041.php on line 9 +Warning: Creating default object from empty value in %sbug52041.php on line 9 Notice: Undefined variable: x in %sbug52041.php on line 3 -Strict Standards: Creating default object from empty value in %sbug52041.php on line 10 +Warning: Creating default object from empty value in %sbug52041.php on line 10 Notice: Undefined variable: x in %sbug52041.php on line 3 -Strict Standards: Creating default object from empty value in %sbug52041.php on line 11 +Warning: Creating default object from empty value in %sbug52041.php on line 11 Notice: Undefined variable: x in %sbug52041.php on line 3 Modified: php/php-src/trunk/Zend/tests/bug52614.phpt =================================================================== --- php/php-src/trunk/Zend/tests/bug52614.phpt 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/Zend/tests/bug52614.phpt 2010-12-31 16:57:45 UTC (rev 306931) @@ -72,7 +72,7 @@ array(0) { } -Strict Standards: Creating default object from empty value in %sbug52614.php on line 52 +Warning: Creating default object from empty value in %sbug52614.php on line 52 NULL object(stdClass)#%d (1) { ["a"]=> Modified: php/php-src/trunk/Zend/zend_execute.c =================================================================== --- php/php-src/trunk/Zend/zend_execute.c 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/Zend/zend_execute.c 2010-12-31 16:57:45 UTC (rev 306931) @@ -554,7 +554,7 @@ || (Z_TYPE_PP(object_ptr) == IS_BOOL && Z_LVAL_PP(object_ptr) == 0) || (Z_TYPE_PP(object_ptr) == IS_STRING && Z_STRLEN_PP(object_ptr) == 0) ) { - zend_error(E_STRICT, "Creating default object from empty value"); + zend_error(E_WARNING, "Creating default object from empty value"); SEPARATE_ZVAL_IF_NOT_REF(object_ptr); zval_dtor(*object_ptr); @@ -660,7 +660,7 @@ zval_dtor(*object_ptr); object_init(*object_ptr); object = *object_ptr; - zend_error(E_STRICT, "Creating default object from empty value"); + zend_error(E_WARNING, "Creating default object from empty value"); } else { zend_error(E_WARNING, "Attempt to assign property of non-object"); if (retval) { Modified: php/php-src/trunk/ext/dom/tests/bug47430.phpt =================================================================== --- php/php-src/trunk/ext/dom/tests/bug47430.phpt 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/ext/dom/tests/bug47430.phpt 2010-12-31 16:57:45 UTC (rev 306931) @@ -21,9 +21,9 @@ ?> --EXPECTF-- -Strict Standards: Creating default object from empty value in %s on line %d +Warning: Creating default object from empty value in %s on line %d -Strict Standards: Creating default object from empty value in %s on line %d +Warning: Creating default object from empty value in %s on line %d Array ( [0] => Value Modified: php/php-src/trunk/ext/reflection/tests/bug40431.phpt =================================================================== --- php/php-src/trunk/ext/reflection/tests/bug40431.phpt 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/ext/reflection/tests/bug40431.phpt 2010-12-31 16:57:45 UTC (rev 306931) @@ -4,7 +4,7 @@ <?php echo "=== 1st test ===\n"; - +$Obj = new stdClass; $Obj->value = 'value'; $RefObj = new ReflectionObject($Obj); @@ -78,8 +78,6 @@ ?> --EXPECTF-- === 1st test === - -Strict Standards: Creating default object from empty value in %s on line %d array(1) { [0]=> &object(ReflectionProperty)#%d (2) { Modified: php/php-src/trunk/tests/classes/implicit_instantiation_001.phpt =================================================================== --- php/php-src/trunk/tests/classes/implicit_instantiation_001.phpt 2010-12-31 16:37:12 UTC (rev 306930) +++ php/php-src/trunk/tests/classes/implicit_instantiation_001.phpt 2010-12-31 16:57:45 UTC (rev 306931) @@ -39,43 +39,43 @@ ---( $c->boolFalse )--- --> Attempting implicit conversion to object using increment... -Strict Standards: Creating default object from empty value in %s on line 18 +Warning: Creating default object from empty value in %s on line 18 --> Attempting implicit conversion to object using assignment... -Strict Standards: Creating default object from empty value in %s on line 22 +Warning: Creating default object from empty value in %s on line 22 --> Attempting implicit conversion to object using combined assignment... -Strict Standards: Creating default object from empty value in %s on line 26 +Warning: Creating default object from empty value in %s on line 26 ---( $c->emptyString )--- --> Attempting implicit conversion to object using increment... -Strict Standards: Creating default object from empty value in %s on line 18 +Warning: Creating default object from empty value in %s on line 18 --> Attempting implicit conversion to object using assignment... -Strict Standards: Creating default object from empty value in %s on line 22 +Warning: Creating default object from empty value in %s on line 22 --> Attempting implicit conversion to object using combined assignment... -Strict Standards: Creating default object from empty value in %s on line 26 +Warning: Creating default object from empty value in %s on line 26 ---( $c->null )--- --> Attempting implicit conversion to object using increment... -Strict Standards: Creating default object from empty value in %s on line 18 +Warning: Creating default object from empty value in %s on line 18 --> Attempting implicit conversion to object using assignment... -Strict Standards: Creating default object from empty value in %s on line 22 +Warning: Creating default object from empty value in %s on line 22 --> Attempting implicit conversion to object using combined assignment... -Strict Standards: Creating default object from empty value in %s on line 26 +Warning: Creating default object from empty value in %s on line 26 ---( $c->boolTrue )---
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php