diff options
author | Julien Pauli <jpauli@php.net> | 2014-12-12 15:07:33 +0100 |
---|---|---|
committer | Julien Pauli <jpauli@php.net> | 2014-12-12 16:11:26 +0100 |
commit | d5dd29ce5c28ee2d04107304bb084c4b79158da7 (patch) | |
tree | 34789fefc89c7f58b194e56e0c859614f5039c52 /Zend | |
parent | d1a2c1522188481d9b54120e3f17dd9243c11d90 (diff) | |
parent | d6eb3b49c878ce01f1d9d73eebc4d9fec4330573 (diff) | |
download | php-git-d5dd29ce5c28ee2d04107304bb084c4b79158da7.tar.gz |
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5:
Updated NEWS
Fixed Bug #65576 (Constructor from trait conflicts with inherited constructor)
Conflicts:
Zend/zend_compile.c
Diffstat (limited to 'Zend')
-rw-r--r-- | Zend/tests/traits/bug65576a.phpt | 31 | ||||
-rw-r--r-- | Zend/tests/traits/bug65576b.phpt | 33 | ||||
-rw-r--r-- | Zend/zend_compile.c | 4 |
3 files changed, 66 insertions, 2 deletions
diff --git a/Zend/tests/traits/bug65576a.phpt b/Zend/tests/traits/bug65576a.phpt new file mode 100644 index 0000000000..49b2ba0c96 --- /dev/null +++ b/Zend/tests/traits/bug65576a.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #65576 (Constructor from trait conflicts with inherited constructor) +--FILE-- +<?php + +trait T +{ + public function __construct() + { + echo "Trait contructor\n"; + } +} + +class A +{ + public function __construct() + { + echo "Parent constructor\n"; + } +} + +class B extends A +{ + use T; +} + +new B(); + +--EXPECT-- +Trait contructor + diff --git a/Zend/tests/traits/bug65576b.phpt b/Zend/tests/traits/bug65576b.phpt new file mode 100644 index 0000000000..3be52ba7c9 --- /dev/null +++ b/Zend/tests/traits/bug65576b.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #65576 (Constructor from trait conflicts with inherited constructor) +--FILE-- +<?php + +trait T +{ + public function __construct() + { + parent::__construct(); + echo "Trait contructor\n"; + } +} + +class A +{ + public function __construct() + { + echo "Parent constructor\n"; + } +} + +class B extends A +{ + use T; +} + +new B(); + +--EXPECT-- +Parent constructor +Trait contructor + diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 03149091fb..c7efa47cdb 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3979,7 +3979,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, const char* mname, uint if (!strncmp(mname, ZEND_CLONE_FUNC_NAME, mname_len)) { ce->clone = fe; fe->common.fn_flags |= ZEND_ACC_CLONE; } else if (!strncmp(mname, ZEND_CONSTRUCTOR_FUNC_NAME, mname_len)) { - if (ce->constructor) { + if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name); } ce->constructor = fe; fe->common.fn_flags |= ZEND_ACC_CTOR; @@ -4006,7 +4006,7 @@ static void zend_add_magic_methods(zend_class_entry* ce, const char* mname, uint zend_str_tolower_copy(lowercase_name, ce->name, ce->name_length); lowercase_name = (char*)zend_new_interned_string(lowercase_name, ce->name_length + 1, 1 TSRMLS_CC); if (!memcmp(mname, lowercase_name, mname_len)) { - if (ce->constructor) { + if (ce->constructor && (!ce->parent || ce->constructor != ce->parent->constructor)) { zend_error_noreturn(E_COMPILE_ERROR, "%s has colliding constructor definitions coming from traits", ce->name); } ce->constructor = fe; |