--- /dev/null
+--TEST--
+Bug #60153 (Interface method prototypes not enforced when implementd via traits.)
+--FILE--
+<?php
+
+interface IFoo {
+ public function oneArgument($a);
+}
+
+trait TFoo {
+ public function oneArgument() {}
+}
+
+class C implements IFoo {
+ use TFoo;
+}
+
+--EXPECTF--
+Fatal error: Declaration of C::oneArgument() must be compatible with IFoo::oneArgument($a) in %s on line %d
add = 1; /* not found */
} else if (existing_fn->common.scope != ce) {
add = 1; /* or inherited from other class or interface */
- /* it is just a reference which was added to the subclass while doing the inheritance */
- /* so we can deleted now, and will add the overriding method afterwards */
-
- /* except, if we try to add an abstract function, then we should not delete the inherited one */
- /* delete inherited fn if the function to be added is not abstract */
- if ((fn->common.fn_flags & ZEND_ACC_ABSTRACT) == 0) {
- zend_hash_quick_del(&ce->function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h);
- }
}
if (add) {
if (prototype) {
do_inheritance_check_on_method(fn, prototype TSRMLS_CC);
}
+ /* one more thing: make sure we properly implement an abstract method */
+ if (existing_fn && existing_fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
+ do_inheritance_check_on_method(fn, existing_fn TSRMLS_CC);
+ }
+
+ /* delete inherited fn if the function to be added is not abstract */
+ if (existing_fn
+ && existing_fn->common.scope != ce
+ && (fn->common.fn_flags & ZEND_ACC_ABSTRACT) == 0) {
+ /* it is just a reference which was added to the subclass while doing
+ the inheritance, so we can deleted now, and will add the overriding
+ method afterwards.
+ Except, if we try to add an abstract function, then we should not
+ delete the inherited one */
+ zend_hash_quick_del(&ce->function_table, hash_key->arKey, hash_key->nKeyLength, hash_key->h);
+ }
+
if (fn->common.fn_flags & ZEND_ACC_ABSTRACT) {
ce->ce_flags |= ZEND_ACC_IMPLICIT_ABSTRACT_CLASS;