mirror of
https://github.com/php/php-src.git
synced 2026-04-03 06:02:23 +02:00
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
This commit is contained in:
31
Zend/tests/traits/bug65576a.phpt
Normal file
31
Zend/tests/traits/bug65576a.phpt
Normal file
@@ -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
|
||||
|
||||
33
Zend/tests/traits/bug65576b.phpt
Normal file
33
Zend/tests/traits/bug65576b.phpt
Normal file
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user