Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 47fc970

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix `#[\Deprecated]` for `__call()` and `__callStatic()` (#17592)
2 parents 60ee42e + f37b165 commit 47fc970

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
#[\Deprecated]: __call() and __callStatic()
3+
--FILE--
4+
<?php
5+
6+
class Clazz {
7+
#[\Deprecated]
8+
function __call(string $name, array $params) {
9+
}
10+
11+
#[\Deprecated("due to some reason")]
12+
static function __callStatic(string $name, array $params) {
13+
}
14+
}
15+
16+
$cls = new Clazz();
17+
$cls->test();
18+
Clazz::test2();
19+
20+
?>
21+
--EXPECTF--
22+
Deprecated: Method Clazz::test() is deprecated in %s
23+
24+
Deprecated: Method Clazz::test2() is deprecated, due to some reason in %s on line %d

‎Zend/zend_object_handlers.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,13 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
16171617
func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE
16181618
| ZEND_ACC_PUBLIC
16191619
| ZEND_ACC_VARIADIC
1620-
| (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE);
1620+
| (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_DEPRECATED));
1621+
if (fbc->common.attributes) {
1622+
func->attributes = fbc->common.attributes;
1623+
GC_TRY_ADDREF(func->attributes);
1624+
} else {
1625+
func->attributes = NULL;
1626+
}
16211627
if (is_static) {
16221628
func->fn_flags |= ZEND_ACC_STATIC;
16231629
}

‎Zend/zend_object_handlers.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,12 @@ ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_p
339339
} while (0)
340340

341341
#define zend_free_trampoline(func) do { \
342+
HashTable *attributes = (func)->common.attributes; \
343+
if (attributes && !(GC_FLAGS(attributes) & GC_IMMUTABLE) && !GC_DELREF(attributes)) { \
344+
zend_array_destroy(attributes); \
345+
} \
342346
if ((func) == &EG(trampoline)) { \
347+
EG(trampoline).common.attributes = NULL; \
343348
EG(trampoline).common.function_name = NULL; \
344349
} else { \
345350
efree(func); \

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /