Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Zend\Di Shared Support hotfix for type checking of shared configurati…
Browse files Browse the repository at this point in the history
…on status
  • Loading branch information
Ralph Schindler committed Mar 20, 2012
1 parent 4ed737c commit 7784cd5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Di.php
Expand Up @@ -601,7 +601,7 @@ protected function resolveMethodParameters($class, $method, array $callTimeUserP
}
array_push($this->currentDependencies, $class);
$dConfig = $this->instanceManager->getConfiguration($computedParams['required'][$fqParamPos][0]);
if ($dConfig['shared'] == false) {
if ($dConfig['shared'] === false) {
$resolvedParams[$index] = $this->newInstance($computedParams['required'][$fqParamPos][0], $callTimeUserParams, false);
} else {
$resolvedParams[$index] = $this->get($computedParams['required'][$fqParamPos][0], $callTimeUserParams);
Expand Down
2 changes: 1 addition & 1 deletion src/InstanceManager.php
Expand Up @@ -244,7 +244,7 @@ public function setConfiguration($aliasOrClass, array $configuration, $append =
$configuration = array(
'parameters' => isset($configuration['parameters']) ? $configuration['parameters'] : array(),
'injections' => isset($configuration['injections']) ? $configuration['injections'] : array(),
'shared' => isset($configuration['shared']) ? $configuration['shared'] : array(),
'shared' => isset($configuration['shared']) ? $configuration['shared'] : true
);
$this->configurations[$key] = array_replace_recursive($this->configurations[$key], $configuration);
}
Expand Down
4 changes: 2 additions & 2 deletions test/ConfigurationTest.php
Expand Up @@ -34,11 +34,11 @@ public function testConfigurationCanConfigureInstanceManagerWithIniFile()
$this->assertContains('my-dbAdapter', $im->getTypePreferences('my-mapper'));

$this->assertTrue($im->hasConfiguration('My\DbAdapter'));
$expected = array('parameters' => array('username' => 'readonly', 'password' => 'mypassword'), 'injections' => array(), 'shared' => array());
$expected = array('parameters' => array('username' => 'readonly', 'password' => 'mypassword'), 'injections' => array(), 'shared' => true);
$this->assertEquals($expected, $im->getConfiguration('My\DbAdapter'));

$this->assertTrue($im->hasConfiguration('my-dbAdapter'));
$expected = array('parameters' => array('username' => 'readwrite'), 'injections' => array(), 'shared' => array());
$expected = array('parameters' => array('username' => 'readwrite'), 'injections' => array(), 'shared' => true);
$this->assertEquals($expected, $im->getConfiguration('my-dbAdapter'));
}

Expand Down
2 changes: 1 addition & 1 deletion test/InstanceManagerTest.php
Expand Up @@ -71,7 +71,7 @@ public function testInstanceManagerResolvesRecursiveAliasesForConfiguration()
$im->setConfiguration('bar-alias', $config);

$config['injections'] = array();
$config['shared'] = array();
$config['shared'] = true;

$this->assertEquals($config, $im->getConfiguration('foo-alias'));
}
Expand Down

0 comments on commit 7784cd5

Please sign in to comment.