unserialize('O:12:"DateInterval":1:{s:4:"days";O:9:"Exception":7:{s:10:"'."\0".'*'."\0".'message";s:1:"x";s:17:"'."\0".'Exception'."\0".'string";s:1:"A";s:7:"'."\0".'*'."\0".'code";i:0;s:7:"'."\0".'*'."\0".'file";s:1:"a";s:7:"'."\0".'*'."\0".'line";i:1337;s:16:"'."\0".'Exception'."\0".'trace";a:0:{}s:19:"'."\0".'Exception'."\0".'previous";O:8:"stdClass":0:{}}}');
?>
OK
---EXPECT--
-OK
+--EXPECTF--
+Fatal error: Uncaught TypeError: Cannot assign stdClass to property Exception::$previous of type ?Throwable in %s:%d
+Stack trace:
+#0 %s(%d): unserialize('O:12:"DateInter...')
+#1 {main}
+ thrown in %s on line %d
CHECK_EXC_TYPE(ZEND_STR_CODE, IS_LONG);
CHECK_EXC_TYPE(ZEND_STR_FILE, IS_STRING);
CHECK_EXC_TYPE(ZEND_STR_LINE, IS_LONG);
- CHECK_EXC_TYPE(ZEND_STR_TRACE, IS_ARRAY);
- pvalue = zend_read_property(i_get_exception_base(object), object, "previous", sizeof("previous")-1, 1, &value);
- if (pvalue && Z_TYPE_P(pvalue) != IS_NULL && (Z_TYPE_P(pvalue) != IS_OBJECT ||
- !instanceof_function(Z_OBJCE_P(pvalue), zend_ce_throwable) ||
- pvalue == object)) {
- zend_unset_property(i_get_exception_base(object), object, "previous", sizeof("previous")-1);
- }
+ /* The type of $trace and $previous is enforced through typed properties. */
}
/* }}} */
ce, ZSTR_KNOWN(ZEND_STR_TRACE), &val, ZEND_ACC_PRIVATE, NULL,
(zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_ARRAY));
- zend_declare_property_null(ce, "previous", sizeof("previous")-1, ZEND_ACC_PRIVATE);
+ ZVAL_NULL(&val);
+ zend_declare_typed_property(
+ ce, ZSTR_KNOWN(ZEND_STR_PREVIOUS), &val, ZEND_ACC_PRIVATE, NULL,
+ (zend_type) ZEND_TYPE_INIT_CE(zend_ce_throwable, /* allow_null */ 1, 0));
}
void zend_register_default_exception(void) /* {{{ */
var_dump($e."");
?>
--EXPECTF--
-Warning: Undefined property: Exception::$file in %s on line %d
-
-Warning: Undefined property: Exception::$previous in %s on line %d
-
-Warning: Undefined property: Exception::$previous in %s on line %d
-string(41) "Exception in :1337
+Fatal error: Uncaught TypeError: Cannot assign int to property Exception::$previous of type ?Throwable in %s:%d
Stack trace:
-#0 {main}"
+#0 %s(%d): unserialize('O:9:"Exception"...')
+#1 {main}
+ thrown in %s on line %d
}
"
-string(2166) "Class [ <internal:Core> class Exception implements Throwable, Stringable ] {
+string(2177) "Class [ <internal:Core> class Exception implements Throwable, Stringable ] {
- Constants [0] {
}
Property [ protected $file = NULL ]
Property [ protected $line = NULL ]
Property [ private array $trace = Array ]
- Property [ private $previous = NULL ]
+ Property [ private ?Throwable $previous = NULL ]
}
- Methods [11] {