Skip to content

Commit d9219f9

Browse files
committed
Enable better trait conflict error message
I don't think there is any reason to disable this anymore, at least all the messages generated in tests look correct and more useful.
1 parent fff5771 commit d9219f9

File tree

10 files changed

+9
-14
lines changed

10 files changed

+9
-14
lines changed

Zend/tests/traits/bugs/case-sensitive.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ class MyClass {
2020
}
2121
?>
2222
--EXPECTF--
23-
Fatal error: Trait method M1 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
23+
Fatal error: Trait method B::M1 has not been applied as MyClass::M1, because of collision with A::M1 in %s on line %d

Zend/tests/traits/conflict001.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ class TraitsTest {
2222
}
2323
?>
2424
--EXPECTF--
25-
Fatal error: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d
25+
Fatal error: Trait method THello2::hello has not been applied as TraitsTest::hello, because of collision with THello1::hello in %s on line %d

Zend/tests/traits/conflict003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ class Talker {
2828

2929
?>
3030
--EXPECTF--
31-
Fatal error: Trait method smallTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d
31+
Fatal error: Trait method B::smallTalk has not been applied as Talker::smallTalk, because of collision with A::smallTalk in %s on line %d

Zend/tests/traits/error_011.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ var_dump($x->test());
2323

2424
?>
2525
--EXPECTF--
26-
Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d
26+
Fatal error: Trait method c::test has not been applied as bar::test, because of collision with foo::test in %s on line %d

Zend/tests/traits/error_015.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ var_dump($x->test());
2323

2424
?>
2525
--EXPECTF--
26-
Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d
26+
Fatal error: Trait method baz::test has not been applied as bar::test, because of collision with foo::test in %s on line %d

Zend/tests/traits/language010.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ $o->world();
2727

2828
?>
2929
--EXPECTF--
30-
Fatal error: Trait method world has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
30+
Fatal error: Trait method World::world has not been applied as MyClass::world, because of collision with Hello::world in %s on line %d

Zend/tests/traits/language011.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ $o->sayWorld();
2727

2828
?>
2929
--EXPECTF--
30-
Fatal error: Trait method sayHello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
30+
Fatal error: Trait method World::sayHello has not been applied as MyClass::sayHello, because of collision with Hello::sayHello in %s on line %d

Zend/tests/traits/language014.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ $o->world();
2727

2828
?>
2929
--EXPECTF--
30-
Fatal error: Trait method hello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d
30+
Fatal error: Trait method World::world has not been applied as MyClass::hello, because of collision with Hello::hello in %s on line %d

Zend/tests/traits/methods_002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ var_dump(clone $o);
2525

2626
?>
2727
--EXPECTF--
28-
Fatal error: Trait method __clone has not been applied, because there are collisions with other trait methods on bar in %s on line %d
28+
Fatal error: Trait method baz::__clone has not been applied as bar::__clone, because of collision with foo::__clone in %s on line %d

Zend/zend_inheritance.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,15 +1612,10 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_
16121612
} else if (UNEXPECTED((existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT)
16131613
&& !(existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT))) {
16141614
/* two traits can't define the same non-abstract method */
1615-
#if 1
1616-
zend_error_noreturn(E_COMPILE_ERROR, "Trait method %s has not been applied, because there are collisions with other trait methods on %s",
1617-
ZSTR_VAL(name), ZSTR_VAL(ce->name));
1618-
#else /* TODO: better error message */
16191615
zend_error_noreturn(E_COMPILE_ERROR, "Trait method %s::%s has not been applied as %s::%s, because of collision with %s::%s",
16201616
ZSTR_VAL(fn->common.scope->name), ZSTR_VAL(fn->common.function_name),
16211617
ZSTR_VAL(ce->name), ZSTR_VAL(name),
16221618
ZSTR_VAL(existing_fn->common.scope->name), ZSTR_VAL(existing_fn->common.function_name));
1623-
#endif
16241619
} else {
16251620
/* inherited members are overridden by members inserted by traits */
16261621
/* check whether the trait method fulfills the inheritance requirements */

0 commit comments

Comments
 (0)