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 array_combine() to return empty array instead of FALSE when both
parameter arrays are empty. FR #34857. (joel.perras@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
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:
-
+=============================
+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
===================================
-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
- continue $var;
=============
-8. Extensions
+9. Extensions
=============
a. moved out to PECL and actively maintained there
-
==========================
-9. Changes in SAPI support
+10. Changes in SAPI support
==========================
- The REQUEST_TIME value inside server now returns a floating point number
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,
three times.
====================
-11. Syntax additions
+12. Syntax additions
====================
- Array dereferencing.
$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
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
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
--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
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"]=>
|| (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);
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) {
?>
--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
<?php
echo "=== 1st test ===\n";
-
+$Obj = new stdClass;
$Obj->value = 'value';
$RefObj = new ReflectionObject($Obj);
?>
--EXPECTF--
=== 1st test ===
-
-Strict Standards: Creating default object from empty value in %s on line %d
array(1) {
[0]=>
&object(ReflectionProperty)#%d (2) {
---( $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 )---