ZF2-142: Zend\Di ignores default parameters values


When method parameter has default value it is ignored by Zend\Di and it passes {{NULL}} if parameter is not defined explicitly. As an example try creating {{Zend\Authentication\Storage\Session}} without any parameters defined in Di configuration - it's constructor allows to create instance without passing any parameter and assigns default values then. But Di sees no parameter values in configuration and passes {{NULL}}, which overrides default values.

I think Di should check if parameter is specified explicitly to {{NULL}} in instance manager configuration and if not, do not pass anything (even NULL).

Problem lies in library/Zend/Di/Di.php at line 616 (commit 9bd4f0a30b1ab6b0d3ab2263b987a35bcab30393):

{{$resolvedParams[$index] = null;}} should assign default parameter vlaue if not explicitly specified by Di definition.


Let me just say... I'm new to ZF1 and ZF2 so went straight to ZF2. Just spent 7 hours to come across this... I just could not get Session to work and thought it was because I wasn't doing it correctly.

Would be nice to have this fixed or known about

This issue has been closed on Jira and moved to GitHub for issue tracking. To continue following the resolution of this issues, please visit: