From 1d2a63da5fd0e63b40778c74234edce2f7b0d04d Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Sun, 12 Dec 2010 16:48:02 +0000 Subject: [PATCH] Changed collision warning for Traits to fatal error. #This change is made to have all possible cases of collisions consistently handled as fatal errors. #The reason to have it fatal is that most likely something changed unexpectedly and needs urgent attention by the developer, since it will fail eventually anyway for instance because the expected method is missing in the class. #Discussed in this thread: http://marc.info/?l=php-internals&m=129155790226876 --- Zend/tests/traits/bugs/case-sensitive.phpt | 4 +--- Zend/tests/traits/conflict001.phpt | 2 +- Zend/tests/traits/conflict003.phpt | 4 +--- Zend/tests/traits/error_011.phpt | 4 +--- Zend/tests/traits/error_015.phpt | 4 +--- Zend/tests/traits/language011.phpt | 6 +----- Zend/tests/traits/methods_002.phpt | 4 +--- Zend/zend_compile.c | 2 +- 8 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Zend/tests/traits/bugs/case-sensitive.phpt b/Zend/tests/traits/bugs/case-sensitive.phpt index 1d7b77a0c4..13d4188f2f 100644 --- a/Zend/tests/traits/bugs/case-sensitive.phpt +++ b/Zend/tests/traits/bugs/case-sensitive.phpt @@ -20,6 +20,4 @@ class MyClass { } ?> --EXPECTF-- -Warning: Trait method M1 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d - -Warning: Trait method M2 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d \ No newline at end of file +Fatal error: Trait method M1 has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d diff --git a/Zend/tests/traits/conflict001.phpt b/Zend/tests/traits/conflict001.phpt index a129b63dae..32346b3d92 100644 --- a/Zend/tests/traits/conflict001.phpt +++ b/Zend/tests/traits/conflict001.phpt @@ -22,4 +22,4 @@ class TraitsTest { } ?> --EXPECTF-- -Warning: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d \ No newline at end of file +Fatal error: Trait method hello has not been applied, because there are collisions with other trait methods on TraitsTest in %s on line %d \ No newline at end of file diff --git a/Zend/tests/traits/conflict003.phpt b/Zend/tests/traits/conflict003.phpt index 5a6d9cf915..0e71063f19 100644 --- a/Zend/tests/traits/conflict003.phpt +++ b/Zend/tests/traits/conflict003.phpt @@ -28,6 +28,4 @@ class Talker { ?> --EXPECTF-- -Warning: Trait method smallTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d - -Warning: Trait method bigTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d \ No newline at end of file +Fatal error: Trait method smallTalk has not been applied, because there are collisions with other trait methods on Talker in %s on line %d \ No newline at end of file diff --git a/Zend/tests/traits/error_011.phpt b/Zend/tests/traits/error_011.phpt index a6372a43d4..2d266dd1ec 100644 --- a/Zend/tests/traits/error_011.phpt +++ b/Zend/tests/traits/error_011.phpt @@ -23,6 +23,4 @@ var_dump($x->test()); ?> --EXPECTF-- -Warning: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d - -Fatal error: Call to undefined method bar::test() in %s on line %d +Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d diff --git a/Zend/tests/traits/error_015.phpt b/Zend/tests/traits/error_015.phpt index ec47c0d8e2..efcffea5f3 100644 --- a/Zend/tests/traits/error_015.phpt +++ b/Zend/tests/traits/error_015.phpt @@ -23,6 +23,4 @@ var_dump($x->test()); ?> --EXPECTF-- -Warning: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d - -Fatal error: Call to undefined method bar::test() in %s on line %d +Fatal error: Trait method test has not been applied, because there are collisions with other trait methods on bar in %s on line %d diff --git a/Zend/tests/traits/language011.phpt b/Zend/tests/traits/language011.phpt index 8c4b1a489a..cf535b4c11 100644 --- a/Zend/tests/traits/language011.phpt +++ b/Zend/tests/traits/language011.phpt @@ -27,8 +27,4 @@ $o->sayWorld(); ?> --EXPECTF-- -Warning: Trait method sayWorld has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d - -Warning: Trait method sayHello has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d - -Fatal error: Call to undefined method MyClass::sayHello() in %s on line %d \ No newline at end of file +Fatal error: Trait method sayWorld has not been applied, because there are collisions with other trait methods on MyClass in %s on line %d diff --git a/Zend/tests/traits/methods_002.phpt b/Zend/tests/traits/methods_002.phpt index 58fbf93fb9..4ed64c1a55 100644 --- a/Zend/tests/traits/methods_002.phpt +++ b/Zend/tests/traits/methods_002.phpt @@ -25,6 +25,4 @@ var_dump(clone $o); ?> --EXPECTF-- -Warning: Trait method __clone has not been applied, because there are collisions with other trait methods on bar in %s on line %d -object(bar)#%d (0) { -} +Fatal error: Trait method __clone has not been applied, because there are collisions with other trait methods on bar in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ac31da4157..5a18514d23 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3459,7 +3459,7 @@ static int zend_traits_merge_functions(zend_function *fn TSRMLS_DC, int num_args if (zend_hash_quick_find(&ce->function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h, (void **)&class_fn) == FAILURE || class_fn->common.scope != ce) { - zend_error(E_WARNING, "Trait method %s has not been applied, because there are collisions with other trait methods on %s", fn->common.function_name, ce->name); + zend_error(E_ERROR, "Trait method %s has not been applied, because there are collisions with other trait methods on %s", fn->common.function_name, ce->name); } zend_function_dtor(fn); -- 2.40.0