Skip to content

Commit 47d08ac

Browse files
Review fixes
1 parent 8d5eedc commit 47d08ac

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed

Zend/zend_attributes.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,17 @@ static zend_string *validate_deprecated(
116116
zend_class_entry *scope
117117
) {
118118
if (target != ZEND_ATTRIBUTE_TARGET_CLASS) {
119-
// Being used for a method or something, validation does not apply
119+
/* Being used for a method or something, validation does not apply */
120120
return NULL;
121121
}
122-
if (scope->ce_flags & ZEND_ACC_TRAIT) {
123-
scope->ce_flags |= ZEND_ACC_DEPRECATED;
124-
return NULL;
122+
if (!(scope->ce_flags & ZEND_ACC_TRAIT)) {
123+
const char *type = zend_get_object_type_case(scope, false);
124+
return zend_strpprintf(0, "Cannot apply #[Deprecated] to %s %s", type, ZSTR_VAL(scope->name));
125125
}
126126

127-
const char *type = "class";
128-
if (scope->ce_flags & ZEND_ACC_INTERFACE) {
129-
type = "interface";
130-
} else if (scope->ce_flags & ZEND_ACC_ENUM) {
131-
type = "enum";
132-
}
133-
return zend_strpprintf(0, "Cannot apply #[Deprecated] to %s %s", type, ZSTR_VAL(scope->name));
127+
scope->ce_flags |= ZEND_ACC_DEPRECATED;
128+
return NULL;
129+
134130
}
135131

136132
ZEND_METHOD(Attribute, __construct)

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2006,7 +2006,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_constant(const zend_consta
20062006
zend_string_release(message_suffix);
20072007
}
20082008

2009-
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_trait(
2009+
ZEND_API ZEND_COLD void zend_use_of_deprecated_trait(
20102010
zend_class_entry *trait,
20112011
const zend_string *used_by
20122012
) {

Zend/zend_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_function(const zend_functi
6666
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_nodiscard_function(const zend_function *fbc);
6767
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_class_constant(const zend_class_constant *c, const zend_string *constant_name);
6868
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_constant(const zend_constant *c, const zend_string *constant_name);
69-
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_deprecated_trait(zend_class_entry *trait, const zend_string *used_by);
69+
ZEND_API ZEND_COLD void zend_use_of_deprecated_trait(zend_class_entry *trait, const zend_string *used_by);
7070
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_false_to_array_deprecated(void);
7171
ZEND_COLD void ZEND_FASTCALL zend_param_must_be_ref(const zend_function *func, uint32_t arg_num);
7272
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_use_resource_as_offset(const zval *dim);

Zend/zend_inheritance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ ZEND_API zend_class_entry *zend_do_link_class(zend_class_entry *ce, zend_string
35253525
return NULL;
35263526
}
35273527
if (UNEXPECTED(trait->ce_flags & ZEND_ACC_DEPRECATED)) {
3528-
zend_deprecated_trait(trait, ce->name);
3528+
zend_use_of_deprecated_trait(trait, ce->name);
35293529
if (UNEXPECTED(EG(exception))) {
35303530
free_alloca(traits_and_interfaces, use_heap);
35313531
return NULL;

0 commit comments

Comments
 (0)