Skip to content

Commit 3e86a32

Browse files
committed
Improve error message for invalid property read
1 parent 5f7040f commit 3e86a32

18 files changed

+39
-39
lines changed

Zend/tests/024.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ NULL
4141
Warning: Undefined variable $b in %s on line %d
4242
int(1)
4343

44-
Warning: Trying to get property '1' of non-object in %s on line %d
44+
Warning: Access to property '1' on int in %s on line %d
4545
NULL
4646

47-
Warning: Trying to get property '1' of non-object in %s on line %d
47+
Warning: Access to property '1' on int in %s on line %d
4848
NULL
4949

5050
Warning: Undefined variable $c in %s on line %d
5151

5252
Warning: Trying to access array offset on value of type null in %s on line %d
5353

54-
Warning: Trying to get property '1' of non-object in %s on line %d
54+
Warning: Access to property '1' on int in %s on line %d
5555

56-
Warning: Trying to get property '' of non-object in %s on line %d
56+
Warning: Access to property '' on null in %s on line %d
5757
NULL

Zend/tests/026.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ print "ok\n";
2222

2323
?>
2424
--EXPECTF--
25-
Warning: Trying to get property 'a' of non-object in %s on line %d
25+
Warning: Access to property 'a' on null in %s on line %d
2626
ok
2727
Attempt to assign property 'a' of non-object
2828
ok

Zend/tests/033.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,6 @@ Warning: Trying to access array offset on value of type null in %s on line %d
6161

6262
Warning: Trying to access array offset on value of type null in %s on line %d
6363

64-
Warning: Trying to get property 'foo' of non-object in %s on line %d
64+
Warning: Access to property 'foo' on null in %s on line %d
6565
Attempt to assign property 'foo' of non-object
6666
Attempt to assign property 'bar' of non-object

Zend/tests/bug31098.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ ok
4444
ok
4545
ok
4646

47-
Warning: Trying to get property 'wrong' of non-object in %s on line %d
47+
Warning: Access to property 'wrong' on string in %s on line %d
4848
ok
4949

5050
Warning: Illegal string offset 'wrong' in %s on line %d

Zend/tests/bug44660.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var_dump($a);
4848
?>
4949
--EXPECTF--
5050
--> read access:
51-
Warning: Trying to get property 'p' of non-object in %s on line %d
51+
Warning: Access to property 'p' on bool in %s on line %d
5252

5353
--> direct assignment:
5454
Attempt to assign property 'p' of non-object

Zend/tests/bug47109.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ $a->{"a"."b"};
77
--EXPECTF--
88
Warning: Undefined variable $a in %s on line %d
99

10-
Warning: Trying to get property 'ab' of non-object in %s on line %d
10+
Warning: Access to property 'ab' on unknown in %s on line %d

Zend/tests/bug76667.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,26 @@ class T {
1313
{
1414
return $this->$v /= 0;
1515
}
16-
};
16+
}
1717

1818
$x = new T;
1919
$x->x = 1;
2020
?>
2121
--EXPECTF--
2222
Warning: Undefined variable $undefined in %s on line %d
2323

24-
Warning: Trying to get property '1' of non-object in %s on line %d
24+
Warning: Access to property '1' on unknown in %s on line %d
2525

2626
Warning: Division by zero in %sbug76667.php on line %d
2727

2828
Warning: Undefined variable $undefined in %s on line %d
2929

30-
Warning: Trying to get property 'NAN' of non-object in %s on line %d
30+
Warning: Access to property 'NAN' on unknown in %s on line %d
3131

3232
Warning: Division by zero in %sbug76667.php on line %d
3333

3434
Warning: Undefined variable $undefined in %s on line %d
3535

36-
Warning: Trying to get property 'NAN' of non-object in %s on line %d
36+
Warning: Access to property 'NAN' on unknown in %s on line %d
3737

3838
Warning: Division by zero in %sbug76667.php on line %d

Zend/tests/dereference_014.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ var_dump($h);
2929
--EXPECTF--
3030
Warning: Trying to access array offset on value of type null in %s on line %d
3131

32-
Warning: Trying to get property 'a' of non-object in %s on line %d
32+
Warning: Access to property 'a' on null in %s on line %d
3333
NULL
3434

3535
Warning: Trying to access array offset on value of type null in %s on line %d
3636

37-
Warning: Trying to get property 'b' of non-object in %s on line %d
37+
Warning: Access to property 'b' on null in %s on line %d
3838
NULL

Zend/tests/isset_003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Warning: Undefined variable $d in %s on line %d
3535

3636
Warning: Trying to access array offset on value of type null in %s on line %d
3737

38-
Warning: Trying to get property '' of non-object in %s on line %d
38+
Warning: Access to property '' on string in %s on line %d
3939
bool(false)
4040
bool(true)
4141
bool(false)

Zend/tests/varSyntax/encapsed_string_deref.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var_dump("foo$bar"());
2222
--EXPECTF--
2323
string(1) "f"
2424

25-
Warning: Trying to get property 'prop' of non-object in %s on line %d
25+
Warning: Access to property 'prop' on string in %s on line %d
2626
NULL
2727
Call to a member function method() on string
2828
int(42)

Zend/tests/varSyntax/magic_const_deref.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ test();
1919
--EXPECTF--
2020
string(1) "t"
2121

22-
Warning: Trying to get property 'prop' of non-object in %s on line %d
22+
Warning: Access to property 'prop' on string in %s on line %d
2323
NULL
2424
Call to a member function method() on string

Zend/tests/varSyntax/propertyOfStringError.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ Cannot take property of a string
77

88
?>
99
--EXPECTF--
10-
Warning: Trying to get property 'bar' of non-object in %s on line %d
10+
Warning: Access to property 'bar' on string in %s on line %d

Zend/zend_execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,11 +1494,11 @@ static zend_never_inline ZEND_COLD void zend_wrong_string_offset(EXECUTE_DATA_D)
14941494
zend_throw_error(NULL, "%s", msg);
14951495
}
14961496

1497-
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_property_read(zval *property)
1497+
static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_property_read(zval *object, zval *property)
14981498
{
14991499
zend_string *tmp_property_name;
15001500
zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
1501-
zend_error(E_WARNING, "Trying to get property '%s' of non-object", ZSTR_VAL(property_name));
1501+
zend_error(E_WARNING, "Access to property '%s' on %s", ZSTR_VAL(property_name), zend_get_type_by_const(Z_TYPE_P(object)));
15021502
zend_tmp_string_release(tmp_property_name);
15031503
}
15041504

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2014,7 +2014,7 @@ ZEND_VM_HOT_OBJ_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMPVAR|UNUSED|THIS|CV, CONST
20142014
if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
20152015
ZVAL_UNDEFINED_OP2();
20162016
}
2017-
zend_wrong_property_read(offset);
2017+
zend_wrong_property_read(container, offset);
20182018
ZVAL_NULL(EX_VAR(opline->result.var));
20192019
ZEND_VM_C_GOTO(fetch_obj_r_finish);
20202020
} while (0);

Zend/zend_vm_execute.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5220,7 +5220,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_
52205220
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
52215221
ZVAL_UNDEFINED_OP2();
52225222
}
5223-
zend_wrong_property_read(offset);
5223+
zend_wrong_property_read(container, offset);
52245224
ZVAL_NULL(EX_VAR(opline->result.var));
52255225
goto fetch_obj_r_finish;
52265226
} while (0);
@@ -7395,7 +7395,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_
73957395
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
73967396
ZVAL_UNDEFINED_OP2();
73977397
}
7398-
zend_wrong_property_read(offset);
7398+
zend_wrong_property_read(container, offset);
73997399
ZVAL_NULL(EX_VAR(opline->result.var));
74007400
goto fetch_obj_r_finish;
74017401
} while (0);
@@ -9651,7 +9651,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_
96519651
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
96529652
ZVAL_UNDEFINED_OP2();
96539653
}
9654-
zend_wrong_property_read(offset);
9654+
zend_wrong_property_read(container, offset);
96559655
ZVAL_NULL(EX_VAR(opline->result.var));
96569656
goto fetch_obj_r_finish;
96579657
} while (0);
@@ -13971,7 +13971,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CONST_
1397113971
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
1397213972
ZVAL_UNDEFINED_OP2();
1397313973
}
13974-
zend_wrong_property_read(offset);
13974+
zend_wrong_property_read(container, offset);
1397513975
ZVAL_NULL(EX_VAR(opline->result.var));
1397613976
goto fetch_obj_r_finish;
1397713977
} while (0);
@@ -15352,7 +15352,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_TMPVAR
1535215352
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
1535315353
ZVAL_UNDEFINED_OP2();
1535415354
}
15355-
zend_wrong_property_read(offset);
15355+
zend_wrong_property_read(container, offset);
1535615356
ZVAL_NULL(EX_VAR(opline->result.var));
1535715357
goto fetch_obj_r_finish;
1535815358
} while (0);
@@ -16627,7 +16627,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CV_HAN
1662716627
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
1662816628
ZVAL_UNDEFINED_OP2();
1662916629
}
16630-
zend_wrong_property_read(offset);
16630+
zend_wrong_property_read(container, offset);
1663116631
ZVAL_NULL(EX_VAR(opline->result.var));
1663216632
goto fetch_obj_r_finish;
1663316633
} while (0);
@@ -29418,7 +29418,7 @@ static zend_always_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R
2941829418
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
2941929419
ZVAL_UNDEFINED_OP2();
2942029420
}
29421-
zend_wrong_property_read(offset);
29421+
zend_wrong_property_read(container, offset);
2942229422
ZVAL_NULL(EX_VAR(opline->result.var));
2942329423
goto fetch_obj_r_finish;
2942429424
} while (0);
@@ -31290,7 +31290,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMPVAR
3129031290
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
3129131291
ZVAL_UNDEFINED_OP2();
3129231292
}
31293-
zend_wrong_property_read(offset);
31293+
zend_wrong_property_read(container, offset);
3129431294
ZVAL_NULL(EX_VAR(opline->result.var));
3129531295
goto fetch_obj_r_finish;
3129631296
} while (0);
@@ -33685,7 +33685,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HAN
3368533685
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
3368633686
ZVAL_UNDEFINED_OP2();
3368733687
}
33688-
zend_wrong_property_read(offset);
33688+
zend_wrong_property_read(container, offset);
3368933689
ZVAL_NULL(EX_VAR(opline->result.var));
3369033690
goto fetch_obj_r_finish;
3369133691
} while (0);
@@ -37992,7 +37992,7 @@ static zend_always_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R
3799237992
if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
3799337993
ZVAL_UNDEFINED_OP2();
3799437994
}
37995-
zend_wrong_property_read(offset);
37995+
zend_wrong_property_read(container, offset);
3799637996
ZVAL_NULL(EX_VAR(opline->result.var));
3799737997
goto fetch_obj_r_finish;
3799837998
} while (0);
@@ -41474,7 +41474,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMPVAR_HAN
4147441474
if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
4147541475
ZVAL_UNDEFINED_OP2();
4147641476
}
41477-
zend_wrong_property_read(offset);
41477+
zend_wrong_property_read(container, offset);
4147841478
ZVAL_NULL(EX_VAR(opline->result.var));
4147941479
goto fetch_obj_r_finish;
4148041480
} while (0);
@@ -46282,7 +46282,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER
4628246282
if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
4628346283
ZVAL_UNDEFINED_OP2();
4628446284
}
46285-
zend_wrong_property_read(offset);
46285+
zend_wrong_property_read(container, offset);
4628646286
ZVAL_NULL(EX_VAR(opline->result.var));
4628746287
goto fetch_obj_r_finish;
4628846288
} while (0);

ext/dom/tests/bug67949.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ bool(false)
6262
testing property access
6363
string(4) "data"
6464

65-
Warning: Trying to get property 'textContent' of non-object in %s on line %d
65+
Warning: Access to property 'textContent' on null in %s on line %d
6666
NULL
6767
testing offset not a long
6868
array(1) {
6969
[0]=>
7070
string(4) "test"
7171
}
7272

73-
Warning: Trying to get property 'textContent' of non-object in %s on line %d
73+
Warning: Access to property 'textContent' on null in %s on line %d
7474
bool(false)
7575
NULL
7676
array(1) {

ext/libxml/tests/bug61367-read.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ Warning: DOMDocument::loadXML(): Failure to process entity file in Entity, line:
5858

5959
Warning: DOMDocument::loadXML(): Entity 'file' not defined in Entity, line: 4 in %s on line %d
6060

61-
Warning: Trying to get property 'firstChild' of non-object in %s on line %d
61+
Warning: Access to property 'firstChild' on null in %s on line %d
6262

63-
Warning: Trying to get property 'nodeValue' of non-object in %s on line %d
63+
Warning: Access to property 'nodeValue' on null in %s on line %d

ext/pdo_mysql/tests/bug44327.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ object(PDORow)#%d (2) {
6060
string(19) "SELECT id FROM test"
6161
----------------------------------
6262

63-
Warning: Trying to get property 'queryString' of non-object in %s on line %d
63+
Warning: Access to property 'queryString' on bool in %s on line %d
6464
NULL

0 commit comments

Comments
 (0)