Skip to content

Commit 9242c54

Browse files
committed
Improve handling of empty #[\Deprecated] message
1 parent b7c48c9 commit 9242c54

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
#[\Deprecated]: Empty message
3+
--FILE--
4+
<?php
5+
6+
#[\Deprecated("")]
7+
function test() {
8+
}
9+
10+
test();
11+
12+
?>
13+
--EXPECTF--
14+
Deprecated: Function test() is deprecated in %s on line %d

Zend/zend_execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ ZEND_API ZEND_COLD void zend_wrong_string_offset_error(void)
17261726
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_function *fbc)
17271727
{
17281728
zend_attribute *deprecated;
1729-
zend_string *message_suffix = NULL;
1729+
zend_string *message_suffix = zend_empty_string;
17301730

17311731
if (fbc->common.attributes != NULL) {
17321732
deprecated = zend_get_attribute_str(fbc->common.attributes, "deprecated", sizeof("deprecated")-1);
@@ -1742,7 +1742,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_functi
17421742

17431743
int code = fbc->type == ZEND_INTERNAL_FUNCTION ? E_DEPRECATED : E_USER_DEPRECATED;
17441744

1745-
if (message_suffix != NULL) {
1745+
if (ZSTR_LEN(message_suffix) > 0) {
17461746
if (fbc->common.scope) {
17471747
zend_error_unchecked(code, "Method %s::%s() is deprecated, %S",
17481748
ZSTR_VAL(fbc->common.scope->name),

0 commit comments

Comments
 (0)