mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fix #[\Deprecated] for __call() and __callStatic() (#17592)
* Fix `#[\Deprecated]` for `__call()` and `__callStatic()` Fixes php/php-src#17597. * Do not duplicate the `attributes` table in `zend_get_call_trampoline_func()`
This commit is contained in:
2
NEWS
2
NEWS
@@ -20,6 +20,8 @@ PHP NEWS
|
||||
(nielsdos, ilutov)
|
||||
. Fix may_have_extra_named_args flag for ZEND_AST_UNPACK. (nielsdos)
|
||||
. Fix NULL arithmetic in System V shared memory emulation for Windows. (cmb)
|
||||
. Fixed bug GH-17597 (#[\Deprecated] does not work for __call() and
|
||||
__callStatic()). (timwolla)
|
||||
|
||||
- DOM:
|
||||
. Fixed bug GH-17397 (Assertion failure ext/dom/php_dom.c). (nielsdos)
|
||||
|
||||
24
Zend/tests/attributes/deprecated/functions/magic_call.phpt
Normal file
24
Zend/tests/attributes/deprecated/functions/magic_call.phpt
Normal file
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
#[\Deprecated]: __call() and __callStatic()
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
class Clazz {
|
||||
#[\Deprecated]
|
||||
function __call(string $name, array $params) {
|
||||
}
|
||||
|
||||
#[\Deprecated("due to some reason")]
|
||||
static function __callStatic(string $name, array $params) {
|
||||
}
|
||||
}
|
||||
|
||||
$cls = new Clazz();
|
||||
$cls->test();
|
||||
Clazz::test2();
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Deprecated: Method Clazz::test() is deprecated in %s
|
||||
|
||||
Deprecated: Method Clazz::test2() is deprecated, due to some reason in %s on line %d
|
||||
@@ -1617,7 +1617,13 @@ ZEND_API zend_function *zend_get_call_trampoline_func(const zend_class_entry *ce
|
||||
func->fn_flags = ZEND_ACC_CALL_VIA_TRAMPOLINE
|
||||
| ZEND_ACC_PUBLIC
|
||||
| ZEND_ACC_VARIADIC
|
||||
| (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE);
|
||||
| (fbc->common.fn_flags & (ZEND_ACC_RETURN_REFERENCE|ZEND_ACC_DEPRECATED));
|
||||
if (fbc->common.attributes) {
|
||||
func->attributes = fbc->common.attributes;
|
||||
GC_TRY_ADDREF(func->attributes);
|
||||
} else {
|
||||
func->attributes = NULL;
|
||||
}
|
||||
if (is_static) {
|
||||
func->fn_flags |= ZEND_ACC_STATIC;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,12 @@ ZEND_API bool ZEND_FASTCALL zend_asymmetric_property_has_set_access(const zend_p
|
||||
} while (0)
|
||||
|
||||
#define zend_free_trampoline(func) do { \
|
||||
HashTable *attributes = (func)->common.attributes; \
|
||||
if (attributes && !(GC_FLAGS(attributes) & GC_IMMUTABLE) && !GC_DELREF(attributes)) { \
|
||||
zend_array_destroy(attributes); \
|
||||
} \
|
||||
if ((func) == &EG(trampoline)) { \
|
||||
EG(trampoline).common.attributes = NULL; \
|
||||
EG(trampoline).common.function_name = NULL; \
|
||||
} else { \
|
||||
efree(func); \
|
||||
|
||||
Reference in New Issue
Block a user