--- /dev/null
+--TEST--
+Bug #79526 (`__sleep` error message doesn't include the name of the class)
+--FILE--
+<?php
+class A
+{
+ public function __sleep() {
+ return 1;
+ }
+}
+
+
+serialize(new A());
+
+class B
+{
+ public function __sleep() {
+ return [1];
+ }
+}
+
+
+serialize(new B());
+?>
+Done
+--EXPECTF--
+Notice: serialize(): A::__sleep should return an array only containing the names of instance-variables to serialize in %sbug79526.php on line %d
+
+Notice: serialize(): B::__sleep should return an array only containing the names of instance-variables to serialize in %sbug79526.php on line %d
+
+Notice: serialize(): "1" returned as member variable from __sleep() but does not exist in %sbug79526.php on line %d
+Done
}
if (!HASH_OF(retval)) {
+ zend_class_entry *ce;
+ ZEND_ASSERT(Z_TYPE_P(struc) == IS_OBJECT);
+ ce = Z_OBJCE_P(struc);
zval_ptr_dtor(retval);
- php_error_docref(NULL, E_NOTICE, "__sleep should return an array only containing the names of instance-variables to serialize");
+ php_error_docref(NULL, E_NOTICE, "%s::__sleep should return an array only containing the names of instance-variables to serialize", ZSTR_VAL(ce->name));
return FAILURE;
}
ZVAL_DEREF(name_val);
if (Z_TYPE_P(name_val) != IS_STRING) {
php_error_docref(NULL, E_NOTICE,
- "__sleep should return an array only containing the names of instance-variables to serialize.");
+ "%s::__sleep should return an array only containing the names of instance-variables to serialize",
+ ZSTR_VAL(ce->name));
}
name = zval_get_tmp_string(name_val, &tmp_name);