]> granicus.if.org Git - php/commitdiff
Improve error messages for invalid property access
authorMáté Kocsis <kocsismate@woohoolabs.com>
Fri, 24 Apr 2020 08:58:46 +0000 (10:58 +0200)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Mon, 18 May 2020 06:27:00 +0000 (08:27 +0200)
Closes GH-5446
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
32 files changed:
Zend/tests/024.phpt
Zend/tests/026.phpt
Zend/tests/033.phpt
Zend/tests/assign_dim_obj_null_return.phpt
Zend/tests/bug31098.phpt
Zend/tests/bug44660.phpt
Zend/tests/bug47109.phpt
Zend/tests/bug52041.phpt
Zend/tests/bug52614.phpt
Zend/tests/bug75241.phpt
Zend/tests/bug75921.phpt
Zend/tests/bug76667.phpt
Zend/tests/bug78182.phpt
Zend/tests/bug78531.phpt
Zend/tests/dereference_014.phpt
Zend/tests/isset_003.phpt
Zend/tests/varSyntax/encapsed_string_deref.phpt
Zend/tests/varSyntax/magic_const_deref.phpt
Zend/tests/varSyntax/propertyOfStringError.phpt
Zend/zend_API.c
Zend/zend_execute.c
Zend/zend_vm_def.h
Zend/zend_vm_execute.h
ext/dom/tests/bug47430.phpt
ext/dom/tests/bug67949.phpt
ext/libxml/tests/bug61367-read.phpt
ext/opcache/jit/zend_jit_disasm_x86.c
ext/opcache/jit/zend_jit_helpers.c
ext/opcache/jit/zend_jit_x86.dasc
ext/opcache/tests/assign_obj_op_of_fetch_dim.phpt
ext/opcache/tests/jit/fetch_obj_001.phpt
ext/pdo_mysql/tests/bug44327.phpt

index 5d8d55e6fa163c3e04991ba8549593c6d5738195..798ba7321475aa1443536d130a089ddc5969622a 100644 (file)
@@ -41,17 +41,17 @@ NULL
 Warning: Undefined variable $b in %s on line %d
 int(1)
 
-Warning: Trying to get property '1' of non-object in %s on line %d
+Warning: Attempt to read property '1' on int in %s on line %d
 NULL
 
-Warning: Trying to get property '1' of non-object in %s on line %d
+Warning: Attempt to read property '1' on int in %s on line %d
 NULL
 
 Warning: Undefined variable $c in %s on line %d
 
 Warning: Trying to access array offset on value of type null in %s on line %d
 
-Warning: Trying to get property '1' of non-object in %s on line %d
+Warning: Attempt to read property '1' on int in %s on line %d
 
-Warning: Trying to get property '' of non-object in %s on line %d
+Warning: Attempt to read property '' on null in %s on line %d
 NULL
index 9008abb79153569222d62b45d3aaef9ac9332d73..6c2b206184070f1220250ecdcb6b90c26178c79a 100644 (file)
@@ -22,7 +22,7 @@ print "ok\n";
 
 ?>
 --EXPECTF--
-Warning: Trying to get property 'a' of non-object in %s on line %d
+Warning: Attempt to read property 'a' on null in %s on line %d
 ok
-Attempt to assign property 'a' of non-object
+Attempt to assign property 'a' on null
 ok
index 75ae71a6745746c665ca25c1545ef37cbfc07358..8247b5907ec82ca5a7a0d16014e624e3f2c0158f 100644 (file)
@@ -61,6 +61,6 @@ Warning: Trying to access array offset on value of type null in %s on line %d
 
 Warning: Trying to access array offset on value of type null in %s on line %d
 
-Warning: Trying to get property 'foo' of non-object in %s on line %d
-Attempt to assign property 'foo' of non-object
-Attempt to assign property 'bar' of non-object
+Warning: Attempt to read property 'foo' on null in %s on line %d
+Attempt to assign property 'foo' on null
+Attempt to assign property 'bar' on null
index 1641992a0cad4a35ad742c5e6a6619f4653accc4..1f1a5a9862d6021c72c636b23bbc5ccd3dc31168 100644 (file)
@@ -79,5 +79,5 @@ Cannot add element to the array as the next element is already occupied
 Illegal offset type
 Illegal offset type
 Cannot use a scalar value as an array
-Attempt to assign property 'foo' of non-object
-Attempt to assign property 'foo' of non-object
+Attempt to assign property 'foo' on bool
+Attempt to assign property 'foo' on bool
index 3276782c0162bd698937ba500933901ac47c15a8..4d01d36cd8673e220d08bdb402209062faadc0af 100644 (file)
@@ -44,7 +44,7 @@ ok
 ok
 ok
 
-Warning: Trying to get property 'wrong' of non-object in %s on line %d
+Warning: Attempt to read property 'wrong' on string in %s on line %d
 ok
 
 Warning: Illegal string offset 'wrong' in %s on line %d
index fbe4a90dcdc7bf33906dc60222c7eae675b2081a..5097fa7518389ba9f7ee92427cb38fe42fa1e31f 100644 (file)
@@ -5,7 +5,7 @@ Bug #44660 (Indexed and reference assignment to property of non-object don't tri
 $s = "hello";
 $a = true;
 
-echo "--> read access: ";
+echo "--> read access:";
 echo $a->p;
 
 echo "\n--> direct assignment:\n";
@@ -47,23 +47,23 @@ echo "\n--> Confirm assignments have had no impact:\n";
 var_dump($a);
 ?>
 --EXPECTF--
---> read access: 
-Warning: Trying to get property 'p' of non-object in %s on line %d
+--> read access:
+Warning: Attempt to read property 'p' on bool in %s on line %d
 
 --> direct assignment:
-Attempt to assign property 'p' of non-object
+Attempt to assign property 'p' on bool
 
 --> increment:
-Attempt to increment/decrement property 'p' of non-object
+Attempt to increment/decrement property 'p' on bool
 
 --> reference assignment:
-Attempt to modify property 'p' of non-object
+Attempt to modify property 'p' on bool
 
 --> reference assignment:
-Attempt to modify property 'p' of non-object
+Attempt to modify property 'p' on bool
 
 --> indexed assignment:
-Attempt to modify property 'p' of non-object
+Attempt to modify property 'p' on bool
 
 --> Confirm assignments have had no impact:
 bool(true)
index b796c420bdd79ae4b2540eca61ea26104b49b5a8..ed1c6d706e98f487127f074b2b2db6a8665a3c2d 100644 (file)
@@ -7,4 +7,4 @@ $a->{"a"."b"};
 --EXPECTF--
 Warning: Undefined variable $a in %s on line %d
 
-Warning: Trying to get property 'ab' of non-object in %s on line %d
+Warning: Attempt to read property 'ab' on null in %s on line %d
index 8068b2d45141d8ec531c44cd310b5fef3b2e5309..bc5297c8d30551e611fe2f937fa67185eed7e73a 100644 (file)
@@ -48,22 +48,22 @@ var_dump(foo());
 ?>
 --EXPECTF--
 Warning: Undefined variable $x in %s on line %d
-Attempt to assign property 'a' of non-object
+Attempt to assign property 'a' on null
 
 Warning: Undefined variable $x in %s on line %d
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
 
 Warning: Undefined variable $x in %s on line %d
-Attempt to increment/decrement property 'a' of non-object
+Attempt to increment/decrement property 'a' on null
 
 Warning: Undefined variable $x in %s on line %d
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
 
 Warning: Undefined variable $x in %s on line %d
-Attempt to assign property 'a' of non-object
+Attempt to assign property 'a' on null
 
 Warning: Undefined variable $x in %s on line %d
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
 
 Warning: Undefined variable $x in %s on line %d
 
index 30c1fc488ad40731ad372b77879d14a4241c1ccf..955d873d8c0d1a86c8e1e78a5b9a1098241edbfd 100644 (file)
@@ -75,7 +75,7 @@ array(0) {
 }
 array(0) {
 }
-Attempt to assign property 'a' of non-object
+Attempt to assign property 'a' on null
 NULL
 object(stdClass)#3 (1) {
   ["a"]=>
index d6c2d79e2d6d0ef6994b98c84c66b46ae9e0c333..832ca4402494a45d78afaf068dab6d4712501511 100644 (file)
@@ -7,7 +7,7 @@ $d->d = &$d + $d->d/=0;
 var_dump($d);
 ?>
 --EXPECTF--
-Fatal error: Uncaught Error: Attempt to modify property 'd' of non-object in %s:%d
+Fatal error: Uncaught Error: Attempt to modify property 'd' on null in %s:%d
 Stack trace:
 #0 {main}
   thrown in %s on line %d
index c309266d93d41e03d723d76abf1e29f3ecbd636d..cb016b78443201a7a146e0af4581ad18fedba5d0 100644 (file)
@@ -45,23 +45,23 @@ unset($null);
 
 ?>
 --EXPECTF--
-Attempt to assign property 'a' of non-object
+Attempt to assign property 'a' on null
 
 Warning: Undefined variable $null in %s on line %d
 NULL
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
 
 Warning: Undefined variable $null in %s on line %d
 NULL
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
 
 Warning: Undefined variable $null in %s on line %d
 NULL
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
 
 Warning: Undefined variable $null in %s on line %d
 NULL
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
 
 Warning: Undefined variable $null in %s on line %d
 NULL
index 259329722ebd94b2372a6378bd625b70f6750545..73d12de525a4a06c233cc6987e93c2225bf30d65 100644 (file)
@@ -13,7 +13,7 @@ class T {
     {
         return $this->$v /= 0;
     }
-};
+}
 
 $x = new T;
 $x->x = 1;
@@ -21,18 +21,18 @@ $x->x = 1;
 --EXPECTF--
 Warning: Undefined variable $undefined in %s on line %d
 
-Warning: Trying to get property '1' of non-object in %s on line %d
+Warning: Attempt to read property '1' on null in %s on line %d
 
-Warning: Division by zero in %sbug76667.php on line %d
+Warning: Division by zero in %s on line %d
 
 Warning: Undefined variable $undefined in %s on line %d
 
-Warning: Trying to get property 'NAN' of non-object in %s on line %d
+Warning: Attempt to read property 'NAN' on null in %s on line %d
 
-Warning: Division by zero in %sbug76667.php on line %d
+Warning: Division by zero in %s on line %d
 
 Warning: Undefined variable $undefined in %s on line %d
 
-Warning: Trying to get property 'NAN' of non-object in %s on line %d
+Warning: Attempt to read property 'NAN' on null in %s on line %d
 
-Warning: Division by zero in %sbug76667.php on line %d
+Warning: Division by zero in %s on line %d
index d7f10e94dfac3a478b47766e25306be1c3d5880f..1f9a8b853031b59c5615be1712bc00a0379f7296 100644 (file)
@@ -12,5 +12,5 @@ try {
 var_dump($var);
 ?>
 --EXPECT--
-Attempt to modify property 'prop' of non-object
+Attempt to modify property 'prop' on null
 NULL
index 682ff50c5b62012a23fee86712d19017fdc0a55a..9ddcbf3724182026e27ef12316057fc34d298e6f 100644 (file)
@@ -25,13 +25,13 @@ try {
 ?>
 --EXPECTF--
 Warning: Undefined variable $u1 in %s on line %d
-Attempt to assign property 'a' of non-object
+Attempt to assign property 'a' on null
 
 Warning: Undefined variable $u2 in %s on line %d
-Attempt to increment/decrement property 'a' of non-object
+Attempt to increment/decrement property 'a' on null
 
 Warning: Undefined variable $u3 in %s on line %d
-Attempt to increment/decrement property 'a' of non-object
+Attempt to increment/decrement property 'a' on null
 
 Warning: Undefined variable $u4 in %s on line %d
-Attempt to modify property 'a' of non-object
+Attempt to modify property 'a' on null
index c6f21ab0ed92a0fe2ab72f2a8fcf47970a87acba..7b115cf48a076c13cc7a613b6d5f7bb7cc71144f 100644 (file)
@@ -29,10 +29,10 @@ var_dump($h);
 --EXPECTF--
 Warning: Trying to access array offset on value of type null in %s on line %d
 
-Warning: Trying to get property 'a' of non-object in %s on line %d
+Warning: Attempt to read property 'a' on null in %s on line %d
 NULL
 
 Warning: Trying to access array offset on value of type null in %s on line %d
 
-Warning: Trying to get property 'b' of non-object in %s on line %d
+Warning: Attempt to read property 'b' on null in %s on line %d
 NULL
index dc7f045de3b9335abec296583423e055102f67d5..4812d8e394df46e7c8c3a47fddc91eafc506ac09 100644 (file)
@@ -35,7 +35,7 @@ Warning: Undefined variable $d in %s on line %d
 
 Warning: Trying to access array offset on value of type null in %s on line %d
 
-Warning: Trying to get property '' of non-object in %s on line %d
+Warning: Attempt to read property '' on string in %s on line %d
 bool(false)
 bool(true)
 bool(false)
index e880f0f1ffd5a8b32f8736edfb81323842ed8cd3..10af3c115898d926c127663ed0ecaf94c0a47d23 100644 (file)
@@ -22,7 +22,7 @@ var_dump("foo$bar"());
 --EXPECTF--
 string(1) "f"
 
-Warning: Trying to get property 'prop' of non-object in %s on line %d
+Warning: Attempt to read property 'prop' on string in %s on line %d
 NULL
 Call to a member function method() on string
 int(42)
index 28ca4b7f40822236b7a52d6522195648c2291cd9..dc293ba6abf879f7b4ece9f08332dad1af7ec4a3 100644 (file)
@@ -19,6 +19,6 @@ test();
 --EXPECTF--
 string(1) "t"
 
-Warning: Trying to get property 'prop' of non-object in %s on line %d
+Warning: Attempt to read property 'prop' on string in %s on line %d
 NULL
 Call to a member function method() on string
index 446f1372cd7294be3f53c391fe89026d44aea7b8..2d47fd5c4d7af78b8ae6c4d867f75a4bdbd7521b 100644 (file)
@@ -7,4 +7,4 @@ Cannot take property of a string
 
 ?>
 --EXPECTF--
-Warning: Trying to get property 'bar' of non-object in %s on line %d
+Warning: Attempt to read property 'bar' on string in %s on line %d
index 01f9277214d77e88e02e0dab2ca4b702615c02e8..cd72a6f1568a6a576a479dbeb154e6a8c70d1deb 100644 (file)
@@ -133,7 +133,8 @@ ZEND_API const char *zend_get_type_by_const(int type) /* {{{ */
 ZEND_API const char *zend_zval_type_name(const zval *arg) /* {{{ */
 {
        ZVAL_DEREF(arg);
-       return zend_get_type_by_const(Z_TYPE_P(arg));
+
+       return Z_ISUNDEF_P(arg) ? "null" : zend_get_type_by_const(Z_TYPE_P(arg));
 }
 /* }}} */
 
index 2eb7b1726010c99db858eb8a8330de35720c3b0d..f302363621226cf83f8764ae3df2c90116510960 100644 (file)
@@ -621,17 +621,22 @@ static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_throw_non_object_erro
         || opline->opcode == ZEND_POST_INC_OBJ
         || opline->opcode == ZEND_POST_DEC_OBJ) {
                zend_throw_error(NULL,
-                       "Attempt to increment/decrement property '%s' of non-object",
-                       ZSTR_VAL(property_name));
+                       "Attempt to increment/decrement property '%s' on %s",
+                       ZSTR_VAL(property_name), zend_zval_type_name(object)
+               );
        } else if (opline->opcode == ZEND_FETCH_OBJ_W
                        || opline->opcode == ZEND_FETCH_OBJ_RW
                        || opline->opcode == ZEND_FETCH_OBJ_FUNC_ARG
                        || opline->opcode == ZEND_ASSIGN_OBJ_REF) {
                zend_throw_error(NULL,
-                       "Attempt to modify property '%s' of non-object", ZSTR_VAL(property_name));
+                       "Attempt to modify property '%s' on %s",
+                       ZSTR_VAL(property_name), zend_zval_type_name(object)
+               );
        } else {
                zend_throw_error(NULL,
-                       "Attempt to assign property '%s' of non-object", ZSTR_VAL(property_name));
+                       "Attempt to assign property '%s' on %s",
+                       ZSTR_VAL(property_name), zend_zval_type_name(object)
+               );
        }
        zend_tmp_string_release(tmp_property_name);
 
@@ -1494,11 +1499,11 @@ static zend_never_inline ZEND_COLD void zend_wrong_string_offset(EXECUTE_DATA_D)
        zend_throw_error(NULL, "%s", msg);
 }
 
-static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_property_read(zval *property)
+static zend_never_inline ZEND_COLD void ZEND_FASTCALL zend_wrong_property_read(zval *object, zval *property)
 {
        zend_string *tmp_property_name;
        zend_string *property_name = zval_get_tmp_string(property, &tmp_property_name);
-       zend_error(E_WARNING, "Trying to get property '%s' of non-object", ZSTR_VAL(property_name));
+       zend_error(E_WARNING, "Attempt to read property '%s' on %s", ZSTR_VAL(property_name), zend_zval_type_name(object));
        zend_tmp_string_release(tmp_property_name);
 }
 
index de0dfa2f357c3894e6536349b4ee7e9cee985f29..9cccd2e2f99eb35d9e734f9a31058d00d0b2c8de 100644 (file)
@@ -2014,7 +2014,7 @@ ZEND_VM_HOT_OBJ_HANDLER(82, ZEND_FETCH_OBJ_R, CONST|TMPVAR|UNUSED|THIS|CV, CONST
                        if (OP2_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        ZEND_VM_C_GOTO(fetch_obj_r_finish);
                } while (0);
index 0bf16a6fee8125cd189c6be3cb056a4be06b3ce8..1c10b8ccbfe46c89f4cde4443162d684621c8936 100644 (file)
@@ -5220,7 +5220,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_
                        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -7395,7 +7395,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_
                        if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -9651,7 +9651,7 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_
                        if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -13970,7 +13970,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CONST_
                        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -15351,7 +15351,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_TMPVAR
                        if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -16626,7 +16626,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_TMPVAR_CV_HAN
                        if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -29416,7 +29416,7 @@ static zend_always_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R
                        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -31288,7 +31288,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_TMPVAR
                        if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -33683,7 +33683,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_UNUSED_CV_HAN
                        if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -37989,7 +37989,7 @@ static zend_always_inline ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R
                        if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -41471,7 +41471,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_TMPVAR_HAN
                        if ((IS_TMP_VAR|IS_VAR) == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
@@ -46279,7 +46279,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_FETCH_OBJ_R_SPEC_CV_CV_HANDLER
                        if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(offset) == IS_UNDEF)) {
                                ZVAL_UNDEFINED_OP2();
                        }
-                       zend_wrong_property_read(offset);
+                       zend_wrong_property_read(container, offset);
                        ZVAL_NULL(EX_VAR(opline->result.var));
                        goto fetch_obj_r_finish;
                } while (0);
index 7be332ecc10cb970194cb8ef7933523b561a7e67..2d5733fe31562d298badab096d8cef33a702b590 100644 (file)
@@ -25,8 +25,8 @@ print_r($arr);
 
 ?>
 --EXPECT--
-Attempt to assign property 'nodeValue' of non-object
-Attempt to assign property 'nodeValue' of non-object
+Attempt to assign property 'nodeValue' on null
+Attempt to assign property 'nodeValue' on null
 Array
 (
     [0] => Value
index c49f0e4e0e3e1d7ae97d0d6843b23645997c253f..f6a12b9812426edbe21d89d8fea6417f0ddd87ba 100644 (file)
@@ -62,7 +62,7 @@ bool(false)
 testing property access
 string(4) "data"
 
-Warning: Trying to get property 'textContent' of non-object in %s on line %d
+Warning: Attempt to read property 'textContent' on null in %s on line %d
 NULL
 testing offset not a long
 array(1) {
@@ -70,7 +70,7 @@ array(1) {
   string(4) "test"
 }
 
-Warning: Trying to get property 'textContent' of non-object in %s on line %d
+Warning: Attempt to read property 'textContent' on null in %s on line %d
 bool(false)
 NULL
 array(1) {
index 97b6513094b8e513d7ba21019c5c942512651fb9..2dd8ca7c21ad54e98173db79082504afe6bc9a5f 100644 (file)
@@ -58,6 +58,6 @@ Warning: DOMDocument::loadXML(): Failure to process entity file in Entity, line:
 
 Warning: DOMDocument::loadXML(): Entity 'file' not defined in Entity, line: 4 in %s on line %d
 
-Warning: Trying to get property 'firstChild' of non-object in %s on line %d
+Warning: Attempt to read property 'firstChild' on null in %s on line %d
 
-Warning: Trying to get property 'nodeValue' of non-object in %s on line %d
+Warning: Attempt to read property 'nodeValue' on null in %s on line %d
index 44b23e1a19df8995cfec87fa8336952d04d47ed4..99de6145e2192ae57e0f6fcc6e7f9be5ca890914 100644 (file)
@@ -448,6 +448,7 @@ static int zend_jit_disasm_init(void)
        REGISTER_HELPER(zend_jit_assign_op_to_typed_ref);
        REGISTER_HELPER(zend_jit_only_vars_by_reference);
        REGISTER_HELPER(zend_jit_invalid_array_access);
+       REGISTER_HELPER(zend_jit_invalid_property_read);
        REGISTER_HELPER(zend_jit_prepare_assign_dim_ref);
        REGISTER_HELPER(zend_jit_pre_inc);
        REGISTER_HELPER(zend_jit_pre_dec);
index 3bfce1a8546a608af3f6f411a15107600836eeb3..ed7708126ca8a78a801b06ab5e9fcd49b6622a56 100644 (file)
@@ -1506,8 +1506,12 @@ static void ZEND_FASTCALL zend_jit_only_vars_by_reference(zval *arg)
 
 static void ZEND_FASTCALL zend_jit_invalid_array_access(zval *container)
 {
-       const char *type = Z_ISUNDEF_P(container) ? "null" : zend_zval_type_name(container);
-       zend_error(E_WARNING, "Trying to access array offset on value of type %s", type);
+       zend_error(E_WARNING, "Trying to access array offset on value of type %s", zend_zval_type_name(container));
+}
+
+static void ZEND_FASTCALL zend_jit_invalid_property_read(zval *container, const char *property_name)
+{
+       zend_error(E_WARNING, "Attempt to read property '%s' on %s", property_name, zend_zval_type_name(container));
 }
 
 static zval * ZEND_FASTCALL zend_jit_prepare_assign_dim_ref(zval *ref) {
index 4af3481c51f441822c77baf8144e4dc40cc61637..34d92e4347296cb6b72961c6e93407d03754292d 100644 (file)
@@ -10537,7 +10537,7 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
        zval *member;
        uint32_t offset;
        zend_bool may_be_dynamic = 1;
-       zend_jit_addr op1_addr = 0;
+       zend_jit_addr op1_addr = 0, orig_op1_addr = 0;
        zend_jit_addr res_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, opline->result.var);
        zend_jit_addr this_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FP, offsetof(zend_execute_data, This));
        zend_jit_addr prop_addr;
@@ -10552,7 +10552,7 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
        if (opline->op1_type == IS_UNUSED) {
                |       GET_ZVAL_PTR FCARG1a, this_addr
        } else {
-               op1_addr = OP1_ADDR();
+               op1_addr = orig_op1_addr = OP1_ADDR();
                if (op1_info & MAY_BE_REF) {
                        |       LOAD_ZVAL_ADDR r0, op1_addr
                        |       ZVAL_DEREF r0, op1_info
@@ -10659,19 +10659,9 @@ static int zend_jit_fetch_obj_read(dasm_State **Dst, const zend_op *opline, cons
                                |       EXT_CALL zend_jit_undefined_op_helper, r0
                                |1:
                        }
-                       |.if X64
-                               |       mov CARG1, E_WARNING
-                               |       LOAD_ADDR CARG2, "Trying to get property '%s' of non-object"
-                               |       LOAD_ADDR CARG3, Z_STRVAL_P(member)
-                               |       EXT_CALL zend_error, r0
-                       |.else
-                               |       sub r4, 4
-                               |       push Z_STRVAL_P(member)
-                               |       push "Trying to get property '%s' of non-object"
-                               |       push E_WARNING
-                               |       EXT_CALL zend_error, r0
-                               |       add r4, 16
-                       |.endif
+                       |       LOAD_ZVAL_ADDR FCARG1a, orig_op1_addr
+                       |       LOAD_ADDR FCARG2a, Z_STRVAL_P(member)
+                       |       EXT_CALL zend_jit_invalid_property_read, r0
                }
                |       SET_ZVAL_TYPE_INFO res_addr, IS_NULL
                |       jmp >9
index 2c070517781830c79f8dc60af19260fdbb8efe90..4b570baaaf800c66d2b29fbb065412d29074cff5 100644 (file)
@@ -17,4 +17,4 @@ try {
 ?>
 --EXPECTF--
 Notice: Undefined offset: 0 in %s on line %d
-Attempt to assign property 'y' of non-object
+Attempt to assign property 'y' on null
index d309442187e74103bc43e794622c105a8238f7eb..49de772b66c9fd831ff5971ada6c34f9f1f0c5c5 100644 (file)
@@ -128,10 +128,10 @@ object(stdClass)#%d (2) {
   array(0) {
   }
 }
-Attempt to modify property 'abc' of non-object
+Attempt to modify property 'abc' on array
 array(0) {
 }
-Attempt to modify property 'abc' of non-object
+Attempt to modify property 'abc' on null
 NULL
-Attempt to modify property 'abc' of non-object
+Attempt to modify property 'abc' on string
 string(0) ""
index 5adc8209e799f7abe4635485cd8a97aeda08f761..4b0b7d9bd019cba8779c768ed9e0185162dfc8fe 100644 (file)
@@ -60,5 +60,5 @@ object(PDORow)#%d (2) {
 string(19) "SELECT id FROM test"
 ----------------------------------
 
-Warning: Trying to get property 'queryString' of non-object in %s on line %d
+Warning: Attempt to read property 'queryString' on bool in %s on line %d
 NULL