From d9219f997df2e5852f76e04767baaca4acf729e7 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 10 Mar 2020 16:17:32 +0100 Subject: [PATCH] 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. --- Zend/tests/traits/bugs/case-sensitive.phpt | 2 +- Zend/tests/traits/conflict001.phpt | 2 +- Zend/tests/traits/conflict003.phpt | 2 +- Zend/tests/traits/error_011.phpt | 2 +- Zend/tests/traits/error_015.phpt | 2 +- Zend/tests/traits/language010.phpt | 2 +- Zend/tests/traits/language011.phpt | 2 +- Zend/tests/traits/language014.phpt | 2 +- Zend/tests/traits/methods_002.phpt | 2 +- Zend/zend_inheritance.c | 5 ----- 10 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Zend/tests/traits/bugs/case-sensitive.phpt b/Zend/tests/traits/bugs/case-sensitive.phpt index 080b6b7cce..b0a2e4b545 100644 --- a/Zend/tests/traits/bugs/case-sensitive.phpt +++ b/Zend/tests/traits/bugs/case-sensitive.phpt @@ -20,4 +20,4 @@ class MyClass { } ?> --EXPECTF-- -Fatal error: Trait method M1 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d +Fatal error: Trait method B::M1 has not been applied as MyClass::M1, because of collision with A::M1 in %s on line %d diff --git a/Zend/tests/traits/conflict001.phpt b/Zend/tests/traits/conflict001.phpt index c288df7351..16dd6fc2d5 100644 --- a/Zend/tests/traits/conflict001.phpt +++ b/Zend/tests/traits/conflict001.phpt @@ -22,4 +22,4 @@ class TraitsTest { } ?> --EXPECTF-- -Fatal error: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d +Fatal error: Trait method THello2::hello has not been applied as TraitsTest::hello, because of collision with THello1::hello in %s on line %d diff --git a/Zend/tests/traits/conflict003.phpt b/Zend/tests/traits/conflict003.phpt index e274063a6f..23ab97edc6 100644 --- a/Zend/tests/traits/conflict003.phpt +++ b/Zend/tests/traits/conflict003.phpt @@ -28,4 +28,4 @@ class Talker { ?> --EXPECTF-- -Fatal error: Trait method smallTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d +Fatal error: Trait method B::smallTalk has not been applied as Talker::smallTalk, because of collision with A::smallTalk in %s on line %d diff --git a/Zend/tests/traits/error_011.phpt b/Zend/tests/traits/error_011.phpt index 5042a4be1c..9fb6bffe8b 100644 --- a/Zend/tests/traits/error_011.phpt +++ b/Zend/tests/traits/error_011.phpt @@ -23,4 +23,4 @@ var_dump($x->test()); ?> --EXPECTF-- -Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d +Fatal error: Trait method c::test has not been applied as bar::test, because of collision with foo::test in %s on line %d diff --git a/Zend/tests/traits/error_015.phpt b/Zend/tests/traits/error_015.phpt index e494eb680e..c1309bd713 100644 --- a/Zend/tests/traits/error_015.phpt +++ b/Zend/tests/traits/error_015.phpt @@ -23,4 +23,4 @@ var_dump($x->test()); ?> --EXPECTF-- -Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d +Fatal error: Trait method baz::test has not been applied as bar::test, because of collision with foo::test in %s on line %d diff --git a/Zend/tests/traits/language010.phpt b/Zend/tests/traits/language010.phpt index cd518f43e2..a5e85d0796 100644 --- a/Zend/tests/traits/language010.phpt +++ b/Zend/tests/traits/language010.phpt @@ -27,4 +27,4 @@ $o->world(); ?> --EXPECTF-- -Fatal error: Trait method world has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d +Fatal error: Trait method World::world has not been applied as MyClass::world, because of collision with Hello::world in %s on line %d diff --git a/Zend/tests/traits/language011.phpt b/Zend/tests/traits/language011.phpt index 1f5b496308..6b66da86ce 100644 --- a/Zend/tests/traits/language011.phpt +++ b/Zend/tests/traits/language011.phpt @@ -27,4 +27,4 @@ $o->sayWorld(); ?> --EXPECTF-- -Fatal error: Trait method sayHello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d +Fatal error: Trait method World::sayHello has not been applied as MyClass::sayHello, because of collision with Hello::sayHello in %s on line %d diff --git a/Zend/tests/traits/language014.phpt b/Zend/tests/traits/language014.phpt index 20dcdea7c8..2e1046fc3d 100644 --- a/Zend/tests/traits/language014.phpt +++ b/Zend/tests/traits/language014.phpt @@ -27,4 +27,4 @@ $o->world(); ?> --EXPECTF-- -Fatal error: Trait method hello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d +Fatal error: Trait method World::world has not been applied as MyClass::hello, because of collision with Hello::hello in %s on line %d diff --git a/Zend/tests/traits/methods_002.phpt b/Zend/tests/traits/methods_002.phpt index b23f8df27a..2c72f6c5a6 100644 --- a/Zend/tests/traits/methods_002.phpt +++ b/Zend/tests/traits/methods_002.phpt @@ -25,4 +25,4 @@ var_dump(clone $o); ?> --EXPECTF-- -Fatal error: Trait method __clone has not been applied, because there are collisions with other trait methods on bar in %s on line %d +Fatal error: Trait method baz::__clone has not been applied as bar::__clone, because of collision with foo::__clone in %s on line %d diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index eab275e509..a4371db6f2 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1612,15 +1612,10 @@ static void zend_add_trait_method(zend_class_entry *ce, zend_string *name, zend_ } else if (UNEXPECTED((existing_fn->common.scope->ce_flags & ZEND_ACC_TRAIT) && !(existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT))) { /* two traits can't define the same non-abstract method */ -#if 1 - zend_error_noreturn(E_COMPILE_ERROR, "Trait method %s has not been applied, because there are collisions with other trait methods on %s", - ZSTR_VAL(name), ZSTR_VAL(ce->name)); -#else /* TODO: better error message */ zend_error_noreturn(E_COMPILE_ERROR, "Trait method %s::%s has not been applied as %s::%s, because of collision with %s::%s", ZSTR_VAL(fn->common.scope->name), ZSTR_VAL(fn->common.function_name), ZSTR_VAL(ce->name), ZSTR_VAL(name), ZSTR_VAL(existing_fn->common.scope->name), ZSTR_VAL(existing_fn->common.function_name)); -#endif } else { /* inherited members are overridden by members inserted by traits */ /* check whether the trait method fulfills the inheritance requirements */ -- 2.40.0