We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon 2.0.0 InjectionAwareInterface Method Signature Bug?

When we upgraded to Phalcon 2.0.0 all of our classes that implemented the InjectionAwareInterface not require the type declaration in the setDi method. So previously the function declaration was:

public function setDi($di) { $this->_di = $di; }

This no longer works and now requires the type declaration Phalcon\DiInterface on the argument. So the new declaration must be:

public function setDi(\Phalcon\DiInterface $di) { $this->_di = $di; }

I am not sure if this was by design or a bug as none of the other documentation or items in teh changelog mention this major change.

Thanks



34.6k
Accepted
answer

Yes, you have to update the signature of the methods, as now Zephir validates these interfaces, this is mentioned in the upgrading guide: https://blog.phalcon.io/post/115773676765/guide-upgrading-to-phalcon-2