ZF2-142: Zend\Di ignores default parameters values

Issue Type: Bug Created: 2012-01-16T10:31:43.000+0000 Last Updated: 2012-10-08T20:15:32.000+0000 Status: Closed Fix version(s): Reporter: RafaƂ Wrzeszcz (rafal.wrzeszcz) Assignee: Ralph Schindler (ralph) Tags: - Zend\Di

Related issues: Attachments:


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.


Posted by Dominic Watson (intellix) on 2012-01-22T18:07:29.000+0000

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

Posted by Ralph Schindler (ralph) on 2012-10-08T20:15:32.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.