You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make sure all trait method references are converted to absolute
method references in advance. This regresses one error message
that I don't think is particularly valuable.
Copy file name to clipboardExpand all lines: Zend/tests/traits/bug54441.phpt
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -16,4 +16,4 @@ class Boo {
16
16
17
17
?>
18
18
--EXPECTF--
19
-
Fatal error: The modifiers for the trait alias dontKnow() need to be changed in the same statement in which the alias is defined. Error in %s on line %d
19
+
Fatal error: The modifiers of the trait method dontKnow() are changed, but this method does not exist. Error in %s on line %d
/* And, ensure that the referenced method is resolvable, too. */
1877
1859
if (!zend_hash_exists(&trait->function_table, lcname)) {
1878
1860
zend_error_noreturn(E_COMPILE_ERROR, "An alias was defined for %s::%s but this method does not exist", ZSTR_VAL(trait->name), ZSTR_VAL(cur_method_ref->method_name));
1879
1861
}
1880
-
zend_string_release_ex(lcname, 0);
1862
+
} else {
1863
+
/* Find out which trait this method refers to. */
1864
+
trait=NULL;
1865
+
for (j=0; j<ce->num_traits; j++) {
1866
+
if (traits[j]) {
1867
+
if (zend_hash_exists(&traits[j]->function_table, lcname)) {
1868
+
if (!trait) {
1869
+
trait=traits[j];
1870
+
continue;
1871
+
}
1872
+
1873
+
// TODO: This is ambiguous! The first trait is assumed.
1874
+
break;
1875
+
}
1876
+
}
1877
+
}
1878
+
1879
+
/* Non-absolute method reference refers to method that does not exist. */
1880
+
if (!trait) {
1881
+
if (cur_alias->alias) {
1882
+
zend_error_noreturn(E_COMPILE_ERROR,
1883
+
"An alias (%s) was defined for method %s(), but this method does not exist",
1884
+
ZSTR_VAL(cur_alias->alias),
1885
+
ZSTR_VAL(cur_alias->trait_method.method_name));
1886
+
} else {
1887
+
zend_error_noreturn(E_COMPILE_ERROR,
1888
+
"The modifiers of the trait method %s() are changed, but this method does not exist. Error",
1889
+
ZSTR_VAL(cur_alias->trait_method.method_name));
1890
+
}
1891
+
}
1892
+
1893
+
aliases[i] =trait;
1894
+
1895
+
/* TODO: try to avoid this assignment (it's necessary only for reflection) */
0 commit comments