Skip to content

Remove auto-vivification for objects #3865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/tests/026.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ print "ok\n";
Notice: Trying to get property 'a' of non-object in %s on line %d
ok

Warning: Creating default object from empty value in %s on line %d
Warning: Attempt to assign property 'a' of non-object in %s on line %d
ok
14 changes: 0 additions & 14 deletions Zend/tests/033.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,10 @@ $arr[1][2][3][4][5];

echo $arr[1][2][3][4][5];

$arr[1][2][3][4][5]->foo;

$arr[1][2][3][4][5]->foo = 1;

$arr[][] = 2;

$arr[][]->bar = 2;

?>
--EXPECTF--
Notice: Undefined variable: arr in %s on line %d

Notice: Undefined variable: arr in %s on line %d

Notice: Undefined variable: arr in %s on line %d

Notice: Trying to get property 'foo' of non-object in %s on line %d

Warning: Creating default object from empty value in %s on line %d

Warning: Creating default object from empty value in %s on line %d
6 changes: 4 additions & 2 deletions Zend/tests/bug36303.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ foreach($x->a->b as &$v) {
echo "ok\n";
?>
--EXPECTF--
Warning: Attempt to modify property 'a' of non-object in %sbug36303.php on line 3
Notice: Trying to get property 'a' of non-object in %s on line %d

Warning: Invalid argument supplied for foreach() in %sbug36303.php on line 3
Warning: Attempt to modify property 'b' of non-object in %s on line %d

Warning: Invalid argument supplied for foreach() in %s on line %d
ok
2 changes: 1 addition & 1 deletion Zend/tests/bug41075.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ try {
echo "Done\n";
?>
--EXPECT--
string(40) "Creating default object from empty value"
string(31) "Undefined property: test::$blah"
Done
6 changes: 2 additions & 4 deletions Zend/tests/bug41813.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@ $foo[0]->bar = "xyz";
echo "Done\n";
?>
--EXPECTF--
Fatal error: Uncaught Error: Cannot use string offset as an object in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
Warning: Attempt to assign property 'bar' of non-object in %s on line %d
Done
8 changes: 4 additions & 4 deletions Zend/tests/bug41919.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $foo[3]->bar[1] = "bang";
echo "ok\n";
?>
--EXPECTF--
Fatal error: Uncaught Error: Cannot use string offset as an object in %sbug41919.php:%d
Stack trace:
#0 {main}
thrown in %sbug41919.php on line %d
Notice: Uninitialized string offset: 3 in %s on line %d

Warning: Attempt to modify property 'bar' of non-object in %s on line %d
ok
5 changes: 1 addition & 4 deletions Zend/tests/bug47704.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ $s = "abd";
$s[0]->a += 1;
?>
--EXPECTF--
Fatal error: Uncaught Error: Cannot use string offset as an object in %sbug47704.php:%d
Stack trace:
#0 {main}
thrown in %sbug47704.php on line %d
Warning: Attempt to assign property 'a' of non-object in %s on line %d
21 changes: 0 additions & 21 deletions Zend/tests/bug48004.phpt

This file was deleted.

30 changes: 9 additions & 21 deletions Zend/tests/bug52041.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,33 @@ var_dump(foo());
--EXPECTF--
Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 6
Warning: Attempt to assign property 'a' of non-object in %sbug52041.php on line 6

Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 7
Notice: Trying to get property 'a' of non-object in %sbug52041.php on line 7

Warning: Creating default object from empty value in %sbug52041.php on line 7
Warning: Attempt to assign property 'b' of non-object in %sbug52041.php on line 7

Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 8

Notice: Undefined property: stdClass::$a in %sbug52041.php on line 8
Warning: Attempt to increment/decrement property 'a' of non-object in %sbug52041.php on line 8

Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 9

Notice: Undefined property: stdClass::$a in %sbug52041.php on line 9

Warning: Creating default object from empty value in %sbug52041.php on line 9
Notice: Trying to get property 'a' of non-object in %sbug52041.php on line 9

Notice: Undefined property: stdClass::$b in %sbug52041.php on line 9
Warning: Attempt to increment/decrement property 'b' of non-object in %sbug52041.php on line 9

Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 10

Notice: Undefined property: stdClass::$a in %sbug52041.php on line 10
Warning: Attempt to assign property 'a' of non-object in %sbug52041.php on line 10

Notice: Undefined variable: x in %sbug52041.php on line 3

Warning: Creating default object from empty value in %sbug52041.php on line 11

Notice: Undefined property: stdClass::$a in %sbug52041.php on line 11

Warning: Creating default object from empty value in %sbug52041.php on line 11
Notice: Trying to get property 'a' of non-object in %sbug52041.php on line 11

Notice: Undefined property: stdClass::$b in %sbug52041.php on line 11
Warning: Attempt to assign property 'b' of non-object in %sbug52041.php on line 11

Notice: Undefined variable: x in %sbug52041.php on line 3

Expand Down
2 changes: 1 addition & 1 deletion Zend/tests/bug52614.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ array(0) {
array(0) {
}

Warning: Creating default object from empty value in %sbug52614.php on line 52
Warning: Attempt to assign property 'a' of non-object in %s on line %d
NULL
object(stdClass)#%d (1) {
["a"]=>
Expand Down
3 changes: 2 additions & 1 deletion Zend/tests/bug54265.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ $my_var = str_repeat("A",$my_var[0]->errormsg = "xyz");
echo "ok\n";
?>
--EXPECT--
EROOR: Creating default object from empty value
EROOR: Undefined variable: my_var
EROOR: Attempt to assign property 'errormsg' of non-object
ok
8 changes: 1 addition & 7 deletions Zend/tests/bug62005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,4 @@ function add_points($player, $points) {
}
add_points(NULL, 2);
--EXPECTF--
Warning: Creating default object from empty value in %sbug62005.php on line %d

Notice: Undefined property: stdClass::$energy in %sbug62005.php on line 3
stdClass Object
(
[energy] => 2
)
Warning: Attempt to assign property 'energy' of non-object in %s on line %d
13 changes: 5 additions & 8 deletions Zend/tests/bug71539_5.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ $array[0] = 42;
var_dump($array);
?>
--EXPECTF--
Warning: Creating default object from empty value in %sbug71539_5.php on line 3
array(2) {
Notice: Undefined index: in %s on line %d

Warning: Attempt to modify property 'prop' of non-object in %s on line %d
array(1) {
[0]=>
&int(42)
[""]=>
object(stdClass)#1 (1) {
["prop"]=>
&int(42)
}
int(42)
}
4 changes: 3 additions & 1 deletion Zend/tests/bug72911.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ var_dump($b);

?>
--EXPECTF--
Warning: Attempt to modify property 'b' of non-object in %sbug72911.php on line %d
Notice: Trying to get property 'b' of non-object in %s on line %d

Warning: Attempt to assign property 'i' of non-object in %s on line %d
NULL
1 change: 1 addition & 0 deletions Zend/tests/bug75241.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function eh(){}

set_error_handler('eh');

$d = new stdClass;
$d->d = &$d + $d->d/=0;
var_dump($d);
?>
Expand Down
8 changes: 5 additions & 3 deletions Zend/tests/bug75573.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26)
class A
{
var $_stdObject;
function __construct()
{
$this->_stdObject = new stdClass;
}
function &__get($property)
{
if (isset($this->_stdObject->{$property})) {
Expand Down Expand Up @@ -44,9 +48,7 @@ var_dump($b->name);
var_dump($b->settings);
?>
--EXPECTF--
Warning: Creating default object from empty value in %sbug75573.php on line %d

Notice: Only variable references should be returned by reference in %sbug75573.php on line %d
Notice: Only variable references should be returned by reference in %s on line %d
string(3) "abc"
array(2) {
["foo"]=>
Expand Down
89 changes: 36 additions & 53 deletions Zend/tests/bug75921.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,39 @@ unset($null);

?>
--EXPECTF--
Warning: Creating default object from empty value in %sbug75921.php on line 3
object(stdClass)#1 (1) {
["a"]=>
int(42)
}

Warning: Creating default object from empty value in %sbug75921.php on line 7
object(stdClass)#1 (1) {
["a"]=>
array(1) {
["hello"]=>
int(42)
}
}

Warning: Creating default object from empty value in %sbug75921.php on line 11

Warning: Creating default object from empty value in %sbug75921.php on line 11
object(stdClass)#1 (1) {
["a"]=>
object(stdClass)#2 (1) {
["b"]=>
int(42)
}
}

Warning: Creating default object from empty value in %sbug75921.php on line 15

Warning: Creating default object from empty value in %sbug75921.php on line 15
object(stdClass)#1 (1) {
["a"]=>
array(1) {
["hello"]=>
object(stdClass)#2 (1) {
["b"]=>
int(42)
}
}
}

Warning: Creating default object from empty value in %sbug75921.php on line 19

Warning: Creating default object from empty value in %sbug75921.php on line 19
object(stdClass)#1 (1) {
["a"]=>
object(stdClass)#2 (1) {
["b"]=>
array(1) {
["hello"]=>
int(42)
}
}
}
Warning: Attempt to assign property 'a' of non-object in %s on line %d

Notice: Undefined variable: null in %s on line %d
NULL

Warning: Attempt to modify property 'a' of non-object in %s on line %d

Notice: Undefined variable: null in %s on line %d
NULL

Notice: Undefined variable: null in %s on line %d

Notice: Trying to get property 'a' of non-object in %s on line %d

Warning: Attempt to assign property 'b' of non-object in %s on line %d

Notice: Undefined variable: null in %s on line %d
NULL

Notice: Undefined variable: null in %s on line %d

Notice: Trying to get property 'a' of non-object in %s on line %d

Warning: Attempt to assign property 'b' of non-object in %s on line %d

Notice: Undefined variable: null in %s on line %d
NULL

Notice: Undefined variable: null in %s on line %d

Notice: Trying to get property 'a' of non-object in %s on line %d

Warning: Attempt to modify property 'b' of non-object in %s on line %d

Notice: Undefined variable: null in %s on line %d
NULL
4 changes: 2 additions & 2 deletions Zend/tests/objects_020.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Accessing members of standard object through of variable variable

error_reporting(E_ALL);

$stdclass = new stdClass;
$test = 'stdclass';

$$test->a =& $$test;
Expand All @@ -14,8 +15,7 @@ var_dump($$test);

?>
--EXPECTF--
Warning: Creating default object from empty value in %sobjects_020.php on line 7
object(stdClass)#%d (2) {
object(stdClass)#1 (2) {
["a"]=>
*RECURSION*
["b"]=>
Expand Down
Loading