ZF2-438: Autoloading error while passing string value as call time user param to Di::newInstance for typeless parameter

Issue Type: Bug Created: 2012-08-01T20:31:59.000+0000 Last Updated: 2012-10-08T20:15:04.000+0000 Status: Closed Fix version(s): Reporter: Anton Kril (akril) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend\Di

Related issues: Attachments:


Preconditons: - Include path autoloader is registered - RuntimeDefinition is used - class with typeless constructor parameter exists Example:

<pre class="highlight">
class A
    public function __construct($someParam)
  • New A instance is requested like:
<pre class="highlight">
$di->newInstance('A', array('someParam' => 'someValue')

Expected Result: New instance is created with $someParam = 'someValue'

Actual Result: Fatal error: require() [function.require]: Failed opening required 'someValue.php'


Posted by Anton Kril (akril) on 2012-08-01T20:41:58.000+0000

This issue appears because runtime definition sets type of a typeless parameter to null.

While Di::resolveMethodParameters checks for $type==false in line 531. Only parameters with type === false are considered string parameters. All other parameters are considered class names/aliases.

Maybe it would be better to perceive string values as aliases/class names only for type hinted parameters?

Posted by Ralph Schindler (ralph) on 2012-10-08T20:15:04.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-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

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