mirror of
https://github.com/php/php-src.git
synced 2024-12-19 06:50:17 +08:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
3da3b4c8f8
35
Zend/tests/static_variable_in_private_trait_method.phpt
Normal file
35
Zend/tests/static_variable_in_private_trait_method.phpt
Normal file
@ -0,0 +1,35 @@
|
||||
--TEST--
|
||||
Behavior of static variable in private trait method
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
trait T {
|
||||
private static function method() {
|
||||
static $x;
|
||||
if ($x === null) $x = new stdClass;
|
||||
return $x;
|
||||
}
|
||||
|
||||
public static function method2() {
|
||||
return self::method();
|
||||
}
|
||||
}
|
||||
|
||||
class C {
|
||||
use T;
|
||||
}
|
||||
|
||||
var_dump(C::method2());
|
||||
|
||||
class D extends C {
|
||||
use T;
|
||||
}
|
||||
|
||||
var_dump(D::method2());
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
object(stdClass)#1 (0) {
|
||||
}
|
||||
object(stdClass)#2 (0) {
|
||||
}
|
@ -95,11 +95,19 @@ static zend_always_inline zend_function *zend_duplicate_function(zend_function *
|
||||
(*func->op_array.refcount)++;
|
||||
}
|
||||
if (is_interface
|
||||
|| EXPECTED(!func->op_array.static_variables)
|
||||
|| (func->op_array.fn_flags & ZEND_ACC_PRIVATE)) {
|
||||
|| EXPECTED(!func->op_array.static_variables)) {
|
||||
/* reuse the same op_array structure */
|
||||
return func;
|
||||
}
|
||||
if (func->op_array.fn_flags & ZEND_ACC_PRIVATE) {
|
||||
/* For private methods we reuse the same op_array structure even if
|
||||
* static variables are used, because it will not end up being used
|
||||
* anyway. However we still need to addref as the dtor will delref. */
|
||||
if (!(GC_FLAGS(func->op_array.static_variables) & IS_ARRAY_IMMUTABLE)) {
|
||||
GC_ADDREF(func->op_array.static_variables);
|
||||
}
|
||||
return func;
|
||||
}
|
||||
return zend_duplicate_user_function(func);
|
||||
}
|
||||
}
|
||||
|
@ -167,8 +167,9 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
|
||||
* doesn't work.
|
||||
*/
|
||||
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
|
||||
typedef ZEND_SET_ALIGNED(1, uint32_t unaligned_uint32_t);
|
||||
# define SET(n) \
|
||||
(*(uint32_t *)&ptr[(n) * 4])
|
||||
(*(unaligned_uint32_t *)&ptr[(n) * 4])
|
||||
# define GET(n) \
|
||||
SET(n)
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user