Skip to content

Commit cc2d2c3

Browse files
Names in deprecation warnings
1 parent eaf2b3c commit cc2d2c3

File tree

9 files changed

+20
-9
lines changed

9 files changed

+20
-9
lines changed

Zend/tests/attributes/deprecated/class_alias/access_constant.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ var_dump(MyAlias::TEST);
1212

1313
?>
1414
--EXPECTF--
15-
Deprecated: Alias is deprecated in %s on line %d
15+
Deprecated: Alias MyAlias for class Clazz is deprecated in %s on line %d
1616
int(1)

Zend/tests/attributes/deprecated/class_alias/access_static_prop.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ MyAlias::$v = true;
1212

1313
?>
1414
--EXPECTF--
15-
Deprecated: Alias is deprecated in %s on line %d
15+
Deprecated: Alias MyAlias for class Clazz is deprecated in %s on line %d

Zend/tests/attributes/deprecated/class_alias/call_static_method.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ MyAlias::doNothing();
1414

1515
?>
1616
--EXPECTF--
17-
Deprecated: Alias is deprecated in %s on line %d
17+
Deprecated: Alias MyAlias for class Clazz is deprecated in %s on line %d
1818
Clazz::doNothing

Zend/tests/attributes/deprecated/class_alias/messages.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ MyAlias::doNothing();
2323

2424
?>
2525
--EXPECTF--
26-
Deprecated: Alias is deprecated since 8.4, don't use the alias in %s on line %d
26+
Deprecated: Alias MyAlias for class Clazz is deprecated since 8.4, don't use the alias in %s on line %d
2727
int(1)
2828

29-
Deprecated: Alias is deprecated since 8.4, don't use the alias in %s on line %d
29+
Deprecated: Alias MyAlias for class Clazz is deprecated since 8.4, don't use the alias in %s on line %d
3030

31-
Deprecated: Alias is deprecated since 8.4, don't use the alias in %s on line %d
31+
Deprecated: Alias MyAlias for class Clazz is deprecated since 8.4, don't use the alias in %s on line %d
3232

33-
Deprecated: Alias is deprecated since 8.4, don't use the alias in %s on line %d
33+
Deprecated: Alias MyAlias for class Clazz is deprecated since 8.4, don't use the alias in %s on line %d

Zend/tests/attributes/deprecated/class_alias/use_constructor.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ $o = new MyAlias();
1414

1515
?>
1616
--EXPECTF--
17-
Deprecated: Alias is deprecated in %s on line %d
17+
Deprecated: Alias MyAlias for class Clazz is deprecated in %s on line %d
1818
Clazz::__construct

Zend/zend_API.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,6 +3603,9 @@ ZEND_API zend_result zend_register_class_alias_ex(const char *name, size_t name_
36033603
*/
36043604
zend_class_alias *alias = zend_class_alias_init(ce);
36053605

3606+
zend_string *original_name = zend_string_init(name, name_len, persistent);
3607+
alias->name = original_name;
3608+
36063609
ZVAL_ALIAS_PTR(&zv, alias);
36073610

36083611
ret = zend_hash_add(CG(class_table), lcname, &zv);

Zend/zend_class_alias.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ zend_class_alias * zend_class_alias_init(zend_class_entry *ce) {
2727
GC_SET_REFCOUNT(alias, 1);
2828

2929
alias->ce = ce;
30+
alias->name = NULL;
3031
alias->attributes = NULL;
3132
alias->alias_flags = 0;
3233

@@ -42,7 +43,9 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_class_alias(const zend_cla
4243
return;
4344
}
4445

45-
zend_error_unchecked(E_USER_DEPRECATED, "Alias is deprecated%S",
46+
zend_error_unchecked(E_USER_DEPRECATED, "Alias %s for class %s is deprecated%S",
47+
ZSTR_VAL(alias->name),
48+
ZSTR_VAL(alias->ce->name),
4649
message_suffix
4750
);
4851

Zend/zend_class_alias.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
struct _zend_class_alias {
2525
zend_refcounted_h gc;
2626
zend_class_entry *ce;
27+
zend_string *name;
2728
HashTable *attributes;
2829
uint32_t alias_flags;
2930
};

Zend/zend_opcode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ ZEND_API void destroy_zend_class(zval *zv)
303303
zend_hash_release(class_alias->attributes);
304304
class_alias->attributes = NULL;
305305
}
306+
if (class_alias->name) {
307+
zend_string_release(class_alias->name);
308+
class_alias->name = NULL;
309+
}
306310
return;
307311
}
308312

0 commit comments

Comments
 (0)