mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-7.2'
This commit is contained in:
commit
3fde27d87d
3 changed files with 85 additions and 12 deletions
25
Zend/tests/traits/bug75607.phpt
Normal file
25
Zend/tests/traits/bug75607.phpt
Normal file
|
@ -0,0 +1,25 @@
|
|||
--TEST--
|
||||
Bug #75607 (Comparision of initial static properties failing)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
trait T1
|
||||
{
|
||||
public static $prop1 = 1;
|
||||
}
|
||||
|
||||
class Base
|
||||
{
|
||||
public static $prop1 = 1;
|
||||
}
|
||||
|
||||
class Child extends base
|
||||
{
|
||||
use T1;
|
||||
}
|
||||
|
||||
echo "DONE";
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
DONE
|
36
Zend/tests/traits/bug75607a.phpt
Normal file
36
Zend/tests/traits/bug75607a.phpt
Normal file
|
@ -0,0 +1,36 @@
|
|||
--TEST--
|
||||
Bug #75607 (Comparision of initial static properties failing)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
trait T1
|
||||
{
|
||||
public static $prop1 = 1;
|
||||
}
|
||||
|
||||
trait T2
|
||||
{
|
||||
public static $prop1 = 1;
|
||||
}
|
||||
|
||||
class Base
|
||||
{
|
||||
use T1;
|
||||
}
|
||||
|
||||
class Child extends base
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
class Grand extends Child
|
||||
{
|
||||
use T2;
|
||||
}
|
||||
|
||||
$c = new Grand();
|
||||
var_dump($c::$prop1);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(1)
|
|
@ -1599,27 +1599,39 @@ static void zend_do_traits_property_binding(zend_class_entry *ce) /* {{{ */
|
|||
if ((coliding_prop->flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))
|
||||
== (flags & (ZEND_ACC_PPP_MASK | ZEND_ACC_STATIC))) {
|
||||
/* the flags are identical, thus, the properties may be compatible */
|
||||
zval op1, op2;
|
||||
zval *op1, *op2;
|
||||
zval op1_tmp, op2_tmp;
|
||||
|
||||
if (flags & ZEND_ACC_STATIC) {
|
||||
ZVAL_COPY_OR_DUP(&op1, &ce->default_static_members_table[coliding_prop->offset]);
|
||||
ZVAL_COPY_OR_DUP(&op2, &ce->traits[i]->default_static_members_table[property_info->offset]);
|
||||
op1 = &ce->default_static_members_table[coliding_prop->offset];
|
||||
op2 = &ce->traits[i]->default_static_members_table[property_info->offset];
|
||||
ZVAL_DEREF(op1);
|
||||
ZVAL_DEREF(op2);
|
||||
} else {
|
||||
ZVAL_COPY_OR_DUP(&op1, &ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)]);
|
||||
ZVAL_COPY_OR_DUP(&op2, &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)]);
|
||||
op1 = &ce->default_properties_table[OBJ_PROP_TO_NUM(coliding_prop->offset)];
|
||||
op2 = &ce->traits[i]->default_properties_table[OBJ_PROP_TO_NUM(property_info->offset)];
|
||||
}
|
||||
|
||||
/* if any of the values is a constant, we try to resolve it */
|
||||
if (UNEXPECTED(Z_TYPE(op1) == IS_CONSTANT_AST)) {
|
||||
zval_update_constant_ex(&op1, ce);
|
||||
if (UNEXPECTED(Z_TYPE_P(op1) == IS_CONSTANT_AST)) {
|
||||
ZVAL_COPY_OR_DUP(&op1_tmp, op1);
|
||||
zval_update_constant_ex(&op1_tmp, ce);
|
||||
op1 = &op1_tmp;
|
||||
}
|
||||
if (UNEXPECTED(Z_TYPE(op2) == IS_CONSTANT_AST)) {
|
||||
zval_update_constant_ex(&op2, ce);
|
||||
if (UNEXPECTED(Z_TYPE_P(op2) == IS_CONSTANT_AST)) {
|
||||
ZVAL_COPY_OR_DUP(&op2_tmp, op2);
|
||||
zval_update_constant_ex(&op2_tmp, ce);
|
||||
op2 = &op2_tmp;
|
||||
}
|
||||
|
||||
not_compatible = fast_is_not_identical_function(&op1, &op2);
|
||||
zval_ptr_dtor_nogc(&op1);
|
||||
zval_ptr_dtor_nogc(&op2);
|
||||
not_compatible = fast_is_not_identical_function(op1, op2);
|
||||
|
||||
if (op1 == &op1_tmp) {
|
||||
zval_ptr_dtor_nogc(&op1_tmp);
|
||||
}
|
||||
if (op2 == &op2_tmp) {
|
||||
zval_ptr_dtor_nogc(&op2_tmp);
|
||||
}
|
||||
}
|
||||
|
||||
if (not_compatible) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue