diff --git a/composer.json b/composer.json index 707eadf3..d989c1a3 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,8 @@ }, "extra": { "branch-alias": { - "dev-master": "2.4-dev", - "dev-develop": "2.5-dev" + "dev-master": "2.2-dev", + "dev-develop": "2.3-dev" } }, "autoload-dev": { diff --git a/src/Config.php b/src/Config.php index aa093914..7a94729d 100644 --- a/src/Config.php +++ b/src/Config.php @@ -3,23 +3,19 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; use Traversable; -use Zend\Stdlib\ArrayUtils; use Zend\Di\Definition\ArrayDefinition; use Zend\Di\Definition\RuntimeDefinition; +use Zend\Stdlib\ArrayUtils; /** * Configures Di instances - * - * @category Zend - * @package Zend_Di */ class Config { @@ -59,11 +55,9 @@ public function configure(Di $di) if (isset($this->data['definition'])) { $this->configureDefinition($di, $this->data['definition']); } - if (isset($this->data['instance'])) { $this->configureInstance($di, $this->data['instance']); } - } /** @@ -90,8 +84,8 @@ public function configureDefinition(Di $di, $definition) $definitions[] = $definition; } } - $definitions = new DefinitionList($definitions); - $di->setDefinitionList($definitions); + $definitionList = new DefinitionList($definitions); + $di->setDefinitionList($definitionList); } elseif (isset($definitionData['use_annotations']) && $definitionData['use_annotations']) { /* @var $runtimeDefinition Definition\RuntimeDefinition */ $runtimeDefinition = $di @@ -146,9 +140,7 @@ public function configureDefinition(Di $di, $definition) } } } - } - } /** @@ -200,7 +192,5 @@ public function configureInstance(Di $di, $instanceData) } } } - } - } diff --git a/src/Definition/Annotation/Inject.php b/src/Definition/Annotation/Inject.php index 46a0131e..369e0132 100644 --- a/src/Definition/Annotation/Inject.php +++ b/src/Definition/Annotation/Inject.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition\Annotation; @@ -14,9 +13,6 @@ /** * Annotation for injection endpoints for dependencies - * - * @category Zend - * @package Zend_Di */ class Inject implements AnnotationInterface { diff --git a/src/Definition/Annotation/Instantiator.php b/src/Definition/Annotation/Instantiator.php index 2de9f205..a4cf9259 100644 --- a/src/Definition/Annotation/Instantiator.php +++ b/src/Definition/Annotation/Instantiator.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition\Annotation; @@ -14,9 +13,6 @@ /** * Annotation for instantiator - * - * @category Zend - * @package Zend_Di */ class Instantiator implements AnnotationInterface { diff --git a/src/Definition/ArrayDefinition.php b/src/Definition/ArrayDefinition.php index 3ca7bf8d..65113b7f 100644 --- a/src/Definition/ArrayDefinition.php +++ b/src/Definition/ArrayDefinition.php @@ -3,18 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; +use Zend\Di\Definition\Builder\InjectionMethod; + /** * Class definitions based on a given array - * - * @category Zend - * @package Zend_Di */ class ArrayDefinition implements DefinitionInterface { @@ -32,6 +30,15 @@ public function __construct(array $dataArray) // force lower names $dataArray[$class] = array_change_key_case($dataArray[$class], CASE_LOWER); } + foreach ($dataArray as $class => $definition) { + if (isset($definition['methods']) && is_array($definition['methods'])) { + foreach ($definition['methods'] as $type => $requirement) { + if (!is_int($requirement)) { + $dataArray[$class]['methods'][$type] = InjectionMethod::detectMethodRequirement($requirement); + } + } + } + } $this->dataArray = $dataArray; } @@ -166,5 +173,4 @@ public function toArray() { return $this->dataArray; } - } diff --git a/src/Definition/Builder/InjectionMethod.php b/src/Definition/Builder/InjectionMethod.php index aaf0ba2f..41e6f242 100644 --- a/src/Definition/Builder/InjectionMethod.php +++ b/src/Definition/Builder/InjectionMethod.php @@ -3,18 +3,16 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition\Builder; +use Zend\Di\Di; + /** * Definitions for an injection endpoint method - * - * @category Zend - * @package Zend_Di */ class InjectionMethod { @@ -59,7 +57,7 @@ public function addParameter($name, $class = null, $isRequired = null, $default $this->parameters[] = array( $name, $class, - ($isRequired == null) ? true : false, + self::detectMethodRequirement($isRequired), $default, ); @@ -74,4 +72,50 @@ public function getParameters() return $this->parameters; } + /** + * + * @param mixed $requirement + * @return int + */ + public static function detectMethodRequirement($requirement) + { + if (is_bool($requirement)) { + return $requirement ? Di::METHOD_IS_REQUIRED : Di::METHOD_IS_OPTIONAL; + } + + if (null === $requirement) { + //This is mismatch to ClassDefinition::addMethod is it ok ? is optional? + return Di::METHOD_IS_REQUIRED; + } + + if (is_int($requirement)) { + return $requirement; + } + + if (is_string($requirement)) { + switch (strtolower($requirement)) { + default: + case "require": + case "required": + return Di::METHOD_IS_REQUIRED; + break; + case "aware": + return Di::METHOD_IS_AWARE; + break; + case "optional": + return Di::METHOD_IS_OPTIONAL; + break; + case "constructor": + return Di::MEHTOD_IS_CONSTRUCTOR; + break; + case "instantiator": + return Di::METHOD_IS_INSTANTIATOR; + break; + case "eager": + return Di::METHOD_IS_EAGER; + break; + } + } + return 0; + } } diff --git a/src/Definition/Builder/PhpClass.php b/src/Definition/Builder/PhpClass.php index f9f1b865..9cc669e8 100644 --- a/src/Definition/Builder/PhpClass.php +++ b/src/Definition/Builder/PhpClass.php @@ -3,18 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition\Builder; /** * Object containing definitions for a single class - * - * @category Zend - * @package Zend_Di */ class PhpClass { @@ -176,5 +172,4 @@ public function getInjectionMethods() { return $this->injectionMethods; } - } diff --git a/src/Definition/BuilderDefinition.php b/src/Definition/BuilderDefinition.php index 1cb354ba..8191e96d 100644 --- a/src/Definition/BuilderDefinition.php +++ b/src/Definition/BuilderDefinition.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; @@ -14,9 +13,6 @@ /** * Class definitions based on a configuration array - * - * @category Zend - * @package Zend_Di */ class BuilderDefinition implements DefinitionInterface { @@ -322,5 +318,4 @@ public function getMethodParameters($class, $method) return $methodParameters; } - } diff --git a/src/Definition/ClassDefinition.php b/src/Definition/ClassDefinition.php index 45df9584..0d3fd52d 100644 --- a/src/Definition/ClassDefinition.php +++ b/src/Definition/ClassDefinition.php @@ -3,18 +3,17 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; +use Zend\Di\Definition\Builder\InjectionMethod; +use Zend\Di\Di; + /** * Class definitions for a single class - * - * @category Zend - * @package Zend_Di */ class ClassDefinition implements DefinitionInterface, PartialMarker { @@ -75,15 +74,21 @@ public function setSupertypes(array $supertypes) /** * @param string $method - * @param bool|null $isRequired + * @param mixed|bool|null $isRequired * @return self */ public function addMethod($method, $isRequired = null) { - if ($isRequired === null) { - $isRequired = ($method === '__construct') ? true : false; + if ($isRequired === null) { + if ($method === '__construct') { + $methodRequirementType = Di::METHOD_IS_CONSTRUCTOR; + } + $methodRequirementType = Di::METHOD_IS_OPTIONAL; + } else { + $methodRequirementType = InjectionMethod::detectMethodRequirement($isRequired); } - $this->methods[$method] = (bool) $isRequired; + + $this->methods[$method] = $methodRequirementType; return $this; } @@ -97,7 +102,11 @@ public function addMethod($method, $isRequired = null) public function addMethodParameter($method, $parameterName, array $parameterInfo) { if (!array_key_exists($method, $this->methods)) { - $this->methods[$method] = ($method === '__construct') ? true : false; + if ($method === '__construct') { + $this->methods[$method] = Di::METHOD_IS_CONSTRUCTOR; + } else { + $this->methods[$method] = Di::METHOD_IS_OPTIONAL; + } } if (!array_key_exists($method, $this->methodParameters)) { @@ -187,9 +196,9 @@ public function hasMethod($class, $method) if (is_array($this->methods)) { return array_key_exists($method, $this->methods); - } else { - return null; } + + return null; } /** diff --git a/src/Definition/CompilerDefinition.php b/src/Definition/CompilerDefinition.php index 5749d378..fac3d43f 100644 --- a/src/Definition/CompilerDefinition.php +++ b/src/Definition/CompilerDefinition.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; @@ -20,9 +19,6 @@ /** * Class definitions based on a set of directories to be scanned - * - * @category Zend - * @package Zend_Di */ class CompilerDefinition implements DefinitionInterface { @@ -304,161 +300,6 @@ protected function processParams(&$def, Reflection\ClassReflection $rClass, Refl } -// public function processClass($className) -// { -// $strategy = $this->introspectionStrategy; -// $sClass = $this->directoryScanner->getClass($className, true, true); -// -// if (!$sClass->isInstantiable()) { -// return; -// } -// -// // determine supertypes -// $superTypes = array(); -// if (($parentClasses = $sClass->getParentClasses()) !== null) { -// $superTypes = array_merge($superTypes, $parentClasses); -// } -// if (($interfaces = $sClass->getInterfaces())) { -// $superTypes = array_merge($superTypes, $interfaces); -// } -// -// $className = $sClass->getName(); -// $this->classes[$className] = array( -// 'supertypes' => $superTypes, -// 'instantiator' => null, -// 'methods' => array(), -// 'parameters' => array() -// ); -// -// $def = &$this->classes[$className]; -// -// if ($def['instantiator'] == null) { -// if ($sClass->isInstantiable()) { -// $def['instantiator'] = '__construct'; -// } -// } -// -// if ($sClass->hasMethod('__construct')) { -// $mScanner = $sClass->getMethod('__construct'); -// if ($mScanner->isPublic() && $mScanner->getNumberOfParameters() > 0) { -// $def['methods']['__construct'] = true; -// $this->processParams($def, $sClass, $mScanner); -// } -// } -// -// foreach ($sClass->getMethods(true) as $mScanner) { -// if (!$mScanner->isPublic()) { -// continue; -// } -// -// $methodName = $mScanner->getName(); -// -// if ($mScanner->getName() === '__construct') { -// continue; -// } -// -// if ($strategy->getUseAnnotations() == true) { -// -// $annotations = $mScanner->getAnnotations($strategy->getAnnotationManager()); -// -// if (($annotations instanceof AnnotationCollection) -// && $annotations->hasAnnotation('Zend\Di\Definition\Annotation\Inject')) { -// -// $def['methods'][$methodName] = true; -// $this->processParams($def, $sClass, $mScanner); -// continue; -// } -// } -// -// $methodPatterns = $this->introspectionStrategy->getMethodNameInclusionPatterns(); -// -// // matches a method injection pattern? -// foreach ($methodPatterns as $methodInjectorPattern) { -// preg_match($methodInjectorPattern, $methodName, $matches); -// if ($matches) { -// $def['methods'][$methodName] = false; // check ot see if this is required? -// $this->processParams($def, $sClass, $mScanner); -// continue 2; -// } -// } -// -// } -// -// $interfaceInjectorPatterns = $this->introspectionStrategy->getInterfaceInjectionInclusionPatterns(); -// -// // matches the interface injection pattern -// /** @var $sInterface \Zend\Code\Scanner\ClassScanner */ -// foreach ($sClass->getInterfaces(true) as $sInterface) { -// foreach ($interfaceInjectorPatterns as $interfaceInjectorPattern) { -// preg_match($interfaceInjectorPattern, $sInterface->getName(), $matches); -// if ($matches) { -// foreach ($sInterface->getMethods(true) as $sMethod) { -// if ($sMethod->getName() === '__construct') { - // constructor not allowed in interfaces -// continue; -// } -// $def['methods'][$sMethod->getName()] = true; -// $this->processParams($def, $sClass, $sMethod); -// } -// continue 2; -// } -// } -// } -// -// } -// -// protected function processParams(&$def, DerivedClassScanner $sClass, MethodScanner $sMethod) -// { -// if (count($sMethod->getParameters()) === 0) { -// return; -// } -// -// $methodName = $sMethod->getName(); -// -// $def['parameters'][$methodName] = array(); -// -// foreach ($sMethod->getParameters(true) as $position => $p) { -// -// /** @var $p \Zend\Code\Scanner\ParameterScanner */ -// $actualParamName = $p->getName(); -// -// $paramName = $this->createDistinctParameterName($actualParamName, $sClass->getName()); -// -// $fqName = $sClass->getName() . '::' . $sMethod->getName() . ':' . $position; -// -// $def['parameters'][$methodName][$fqName] = array(); -// -// // set the class name, if it exists -// $def['parameters'][$methodName][$fqName][] = $actualParamName; -// $def['parameters'][$methodName][$fqName][] = ($p->getClass() !== null) ? $p->getClass() : null; -// $def['parameters'][$methodName][$fqName][] = !$p->isOptional(); -// } -// } -// -// protected function createDistinctParameterName($paramName, $class) -// { -// $currentParams = array(); -// if ($this->classes[$class]['parameters'] === array()) { -// return $paramName; -// } -// foreach ($this->classes as $cdata) { -// foreach ($cdata['parameters'] as $mdata) { -// $currentParams = array_merge($currentParams, array_keys($mdata)); -// } -// } -// -// if (!in_array($paramName, $currentParams)) { -// return $paramName; -// } -// -// $alt = 2; -// while (in_array($paramName . (string) $alt, $currentParams)) { -// $alt++; -// } -// -// return $paramName . (string) $alt; -// } - /** * {@inheritDoc} */ diff --git a/src/Definition/DefinitionInterface.php b/src/Definition/DefinitionInterface.php index 04b9b139..135e2bde 100644 --- a/src/Definition/DefinitionInterface.php +++ b/src/Definition/DefinitionInterface.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; -/** - * @category Zend - * @package Zend_Di - */ interface DefinitionInterface { /** diff --git a/src/Definition/IntrospectionStrategy.php b/src/Definition/IntrospectionStrategy.php index 45aec4d5..e7c487f9 100644 --- a/src/Definition/IntrospectionStrategy.php +++ b/src/Definition/IntrospectionStrategy.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; @@ -16,9 +15,6 @@ /** * Strategy used to discover methods to be considered as endpoints for dependency injection based on implemented * interfaces, annotations and method names - * - * @category Zend - * @package Zend_Di */ class IntrospectionStrategy { @@ -136,5 +132,4 @@ public function getInterfaceInjectionInclusionPatterns() { return $this->interfaceInjectionInclusionPatterns; } - } diff --git a/src/Definition/PartialMarker.php b/src/Definition/PartialMarker.php index 4a34203b..7e8b91c4 100644 --- a/src/Definition/PartialMarker.php +++ b/src/Definition/PartialMarker.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; -/** - * @category Zend - * @package Zend_Di - */ interface PartialMarker { } diff --git a/src/Definition/RuntimeDefinition.php b/src/Definition/RuntimeDefinition.php index 22a07a96..9df696ed 100644 --- a/src/Definition/RuntimeDefinition.php +++ b/src/Definition/RuntimeDefinition.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Definition; @@ -13,12 +12,10 @@ use Zend\Code\Annotation\AnnotationCollection; use Zend\Code\Reflection; use Zend\Di\Definition\Annotation; +use Zend\Di\Di; /** * Class definitions based on runtime reflection - * - * @category Zend - * @package Zend_Di */ class RuntimeDefinition implements DefinitionInterface { @@ -252,7 +249,7 @@ protected function processClass($class) } if ($rClass->hasMethod('__construct')) { - $def['methods']['__construct'] = true; // required + $def['methods']['__construct'] = Di::METHOD_IS_CONSTRUCTOR; // required $this->processParams($def, $rClass, $rClass->getMethod('__construct')); } @@ -270,7 +267,8 @@ protected function processClass($class) if (($annotations instanceof AnnotationCollection) && $annotations->hasAnnotation('Zend\Di\Definition\Annotation\Inject')) { - $def['methods'][$methodName] = true; + // use '@inject' and search for parameters + $def['methods'][$methodName] = Di::METHOD_IS_EAGER; $this->processParams($def, $rClass, $rMethod); continue; } @@ -282,7 +280,7 @@ protected function processClass($class) foreach ($methodPatterns as $methodInjectorPattern) { preg_match($methodInjectorPattern, $methodName, $matches); if ($matches) { - $def['methods'][$methodName] = false; // check ot see if this is required? + $def['methods'][$methodName] = Di::METHOD_IS_OPTIONAL; // check ot see if this is required? $this->processParams($def, $rClass, $rMethod); continue 2; } @@ -308,7 +306,7 @@ protected function processClass($class) // constructor not allowed in interfaces continue; } - $def['methods'][$rMethod->getName()] = true; + $def['methods'][$rMethod->getName()] = Di::METHOD_IS_AWARE; $this->processParams($def, $rClass, $rMethod); } continue 2; diff --git a/src/DefinitionList.php b/src/DefinitionList.php index ae7a7f94..33345ee2 100644 --- a/src/DefinitionList.php +++ b/src/DefinitionList.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; @@ -14,9 +13,6 @@ /** * Class definition based on multiple definitions - * - * @category Zend - * @package Zend_Di */ class DefinitionList extends SplDoublyLinkedList implements Definition\DefinitionInterface { @@ -146,9 +142,11 @@ public function getClassSupertypes($class) foreach ($this as $definition) { if ($definition->hasClass($class)) { $supertypes = array_merge($supertypes, $definition->getClassSupertypes($class)); - if (!$definition instanceof Definition\PartialMarker) { - return $supertypes; + if ($definition instanceof Definition\PartialMarker) { + continue; } + + return $supertypes; } } return $supertypes; @@ -165,9 +163,9 @@ public function getInstantiator($class) $value = $definition->getInstantiator($class); if ($value === null && $definition instanceof Definition\PartialMarker) { continue; - } else { - return $value; } + + return $value; } } @@ -184,9 +182,9 @@ public function hasMethods($class) if ($definition->hasClass($class)) { if ($definition->hasMethods($class) === false && $definition instanceof Definition\PartialMarker) { continue; - } else { - return $definition->hasMethods($class); } + + return $definition->hasMethods($class); } } @@ -198,14 +196,14 @@ public function hasMethods($class) */ public function hasMethod($class, $method) { + if (!$this->hasMethods($class)) { + return false; + } + /** @var $definition Definition\DefinitionInterface */ foreach ($this as $definition) { - if ($definition->hasClass($class)) { - if ($definition->hasMethods($class) === false && $definition instanceof Definition\PartialMarker) { - continue; - } else { - return $definition->hasMethod($class, $method); - } + if ($definition->hasClass($class) && $definition->hasMethod($class, $method)) { + return true; } } @@ -221,11 +219,11 @@ public function getMethods($class) $methods = array(); foreach ($this as $definition) { if ($definition->hasClass($class)) { - if ($definition instanceof Definition\PartialMarker) { - $methods = array_merge($definition->getMethods($class), $methods); - } else { + if (!$definition instanceof Definition\PartialMarker) { return array_merge($definition->getMethods($class), $methods); } + + $methods = array_merge($definition->getMethods($class), $methods); } } @@ -256,5 +254,4 @@ public function getMethodParameters($class, $method) return array(); } - } diff --git a/src/DependencyInjectionInterface.php b/src/DependencyInjectionInterface.php index dedf955c..dd12a369 100644 --- a/src/DependencyInjectionInterface.php +++ b/src/DependencyInjectionInterface.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; -/** - * @category Zend - * @package Zend_Di - */ interface DependencyInjectionInterface extends LocatorInterface { /** diff --git a/src/Di.php b/src/Di.php index 13c797a3..b68791d7 100644 --- a/src/Di.php +++ b/src/Di.php @@ -3,21 +3,19 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; use Closure; use ReflectionClass; +use Zend\Di\Exception\RuntimeException as DiRuntimeException; +use Zend\ServiceManager\Exception\ExceptionInterface as ServiceManagerException; /** * Dependency injector that can generate instances using class definitions and configured instance parameters - * - * @category Zend - * @package Zend_Di */ class Di implements DependencyInjectionInterface { @@ -50,6 +48,56 @@ class Di implements DependencyInjectionInterface */ protected $references = array(); + /** + * Resolve method policy + * + * EAGER: explore type preference or go through + */ + const RESOLVE_EAGER = 1; + + /** + * Resolve method policy + * + * STRICT: explore type preference or throw exception + */ + const RESOLVE_STRICT = 2; + + /** + * + * use only specified parameters + */ + const METHOD_IS_OPTIONAL = 0; + + /** + * + * resolve mode RESOLVE_EAGER + */ + const METHOD_IS_AWARE = 1; + + /** + * + * resolve mode RESOLVE_EAGER | RESOLVE_STRICT + */ + const METHOD_IS_CONSTRUCTOR = 3; + + /** + * + * resolve mode RESOLVE_EAGER | RESOLVE_STRICT + */ + const METHOD_IS_INSTANTIATOR = 3; + + /** + * + * resolve mode RESOLVE_EAGER | RESOLVE_STRICT + */ + const METHOD_IS_REQUIRED = 3; + + /** + * + * resolve mode RESOLVE_EAGER + */ + const METHOD_IS_EAGER = 1; + /** * Constructor * @@ -119,6 +167,30 @@ public function instanceManager() return $this->instanceManager; } + /** + * @param $name + * @param array $params + * @param string $method + * @return array + */ + protected function getCallParameters($name, array $params, $method = "__construct") + { + $im = $this->instanceManager; + $class = $im->hasAlias($name) ? $im->getClassFromAlias($name) : $name; + if ($this->definitions->hasClass($class)) { + $callParameters = array(); + if ($this->definitions->hasMethod($class, $method)) { + foreach ($this->definitions->getMethodParameters($class, $method) as $param) { + if (isset($params[$param[0]])) { + $callParameters[$param[0]] = $params[$param[0]]; + } + } + } + return $callParameters; + } + return $params; + } + /** * Lazy-load a class * @@ -136,21 +208,22 @@ public function get($name, array $params = array()) $im = $this->instanceManager; - if ($params) { - $fastHash = $im->hasSharedInstanceWithParameters($name, $params, true); + $callParameters = $this->getCallParameters($name, $params); + if ($callParameters) { + $fastHash = $im->hasSharedInstanceWithParameters($name, $callParameters, true); if ($fastHash) { array_pop($this->instanceContext); - return $im->getSharedInstanceWithParameters(null, array(), $fastHash); } - } else { - if ($im->hasSharedInstance($name, $params)) { - array_pop($this->instanceContext); + } - return $im->getSharedInstance($name, $params); - } + if ($im->hasSharedInstance($name, $callParameters)) { + array_pop($this->instanceContext); + return $im->getSharedInstance($name, $callParameters); } - $config = $im->getConfig($name); + + + $config = $im->getConfig($name); $instance = $this->newInstance($name, $params, $config['shared']); array_pop($this->instanceContext); @@ -226,8 +299,8 @@ public function newInstance($name, array $params = array(), $isShared = true) } if ($isShared) { - if ($params) { - $this->instanceManager->addSharedInstanceWithParameters($instance, $name, $params); + if ($callParameters = $this->getCallParameters($name, $params)) { + $this->instanceManager->addSharedInstanceWithParameters($instance, $name, $callParameters); } else { $this->instanceManager->addSharedInstance($instance, $name); } @@ -287,9 +360,9 @@ protected function handleInjectDependencies($instance, $injectionMethods, $param if ($injectionMethods) { foreach ($injectionMethods as $type => $typeInjectionMethods) { - foreach ($typeInjectionMethods as $typeInjectionMethod => $methodIsRequired) { + foreach ($typeInjectionMethods as $typeInjectionMethod => $methodRequirementType) { if (!isset($calledMethods[$typeInjectionMethod])) { - if ($this->resolveAndCallInjectionMethodForInstance($instance, $typeInjectionMethod, $params, $instanceAlias, $methodIsRequired, $type)) { + if ($this->resolveAndCallInjectionMethodForInstance($instance, $typeInjectionMethod, $params, $instanceAlias, $methodRequirementType, $type)) { $calledMethods[$typeInjectionMethod] = true; } } @@ -325,14 +398,14 @@ protected function handleInjectDependencies($instance, $injectionMethods, $param foreach ($objectsToInject as $objectToInject) { $calledMethods = array('__construct' => true); foreach ($injectionMethods as $type => $typeInjectionMethods) { - foreach ($typeInjectionMethods as $typeInjectionMethod => $methodIsRequired) { + foreach ($typeInjectionMethods as $typeInjectionMethod => $methodRequirementType) { if (!isset($calledMethods[$typeInjectionMethod])) { $methodParams = $definitions->getMethodParameters($type, $typeInjectionMethod); if ($methodParams) { foreach ($methodParams as $methodParam) { $objectToInjectClass = $this->getClass($objectToInject); if ($objectToInjectClass == $methodParam[1] || self::isSubclassOf($objectToInjectClass, $methodParam[1])) { - if ($this->resolveAndCallInjectionMethodForInstance($instance, $typeInjectionMethod, array($methodParam[0] => $objectToInject), $instanceAlias, true, $type)) { + if ($this->resolveAndCallInjectionMethodForInstance($instance, $typeInjectionMethod, array($methodParam[0] => $objectToInject), $instanceAlias, self::METHOD_IS_REQUIRED, $type)) { $calledMethods[$typeInjectionMethod] = true; } continue 3; @@ -346,7 +419,7 @@ protected function handleInjectDependencies($instance, $injectionMethods, $param } if ($methodsToCall) { foreach ($methodsToCall as $methodInfo) { - $this->resolveAndCallInjectionMethodForInstance($instance, $methodInfo['method'], $methodInfo['args'], $instanceAlias, true, $instanceClass); + $this->resolveAndCallInjectionMethodForInstance($instance, $methodInfo['method'], $methodInfo['args'], $instanceAlias, self::METHOD_IS_REQUIRED, $instanceClass); } } } @@ -370,7 +443,7 @@ protected function createInstanceViaConstructor($class, $params, $alias = null) { $callParameters = array(); if ($this->definitions->hasMethod($class, '__construct')) { - $callParameters = $this->resolveMethodParameters($class, '__construct', $params, $alias, true, true); + $callParameters = $this->resolveMethodParameters($class, '__construct', $params, $alias, self::METHOD_IS_CONSTRUCTOR, true); } // Hack to avoid Reflection in most common use cases @@ -417,7 +490,7 @@ protected function createInstanceViaCallback($callback, $params, $alias) $callParameters = array(); if ($this->definitions->hasMethod($class, $method)) { - $callParameters = $this->resolveMethodParameters($class, $method, $params, $alias, true, true); + $callParameters = $this->resolveMethodParameters($class, $method, $params, $alias, self::METHOD_IS_INSTANTIATOR, true); } return call_user_func_array($callback, $callParameters); @@ -431,14 +504,14 @@ protected function createInstanceViaCallback($callback, $params, $alias) * @param string $method * @param array $params * @param string $alias - * @param bool $methodIsRequired + * @param bool $methodRequirementType * @param string|null $methodClass * @return bool */ - protected function resolveAndCallInjectionMethodForInstance($instance, $method, $params, $alias, $methodIsRequired, $methodClass = null) + protected function resolveAndCallInjectionMethodForInstance($instance, $method, $params, $alias, $methodRequirementType, $methodClass = null) { $methodClass = ($methodClass) ?: $this->getClass($instance); - $callParameters = $this->resolveMethodParameters($methodClass, $method, $params, $alias, $methodIsRequired); + $callParameters = $this->resolveMethodParameters($methodClass, $method, $params, $alias, $methodRequirementType); if ($callParameters == false) { return false; } @@ -458,14 +531,24 @@ protected function resolveAndCallInjectionMethodForInstance($instance, $method, * @param string $method * @param array $callTimeUserParams * @param string $alias - * @param bool $methodIsRequired + * @param int|bolean $methodRequirementType * @param bool $isInstantiator * @throws Exception\MissingPropertyException * @throws Exception\CircularDependencyException * @return array */ - protected function resolveMethodParameters($class, $method, array $callTimeUserParams, $alias, $methodIsRequired, $isInstantiator = false) + protected function resolveMethodParameters($class, $method, array $callTimeUserParams, $alias, $methodRequirementType, $isInstantiator = false) { + //for BC + if (is_bool($methodRequirementType)) { + if ($isInstantiator) { + $methodRequirementType = Di::METHOD_IS_INSTANTIATOR; + } elseif ($methodRequirementType) { + $methodRequirementType = Di::METHOD_IS_REQUIRED; + } else { + $methodRequirementType = Di::METHOD_IS_OPTIONAL; + } + } // parameters for this method, in proper order, to be returned $resolvedParams = array(); @@ -474,9 +557,9 @@ protected function resolveMethodParameters($class, $method, array $callTimeUserP // computed parameters array $computedParams = array( - 'value' => array(), - 'required' => array(), - 'optional' => array() + 'value' => array(), + 'retrieval' => array(), + 'optional' => array() ); // retrieve instance configurations for all contexts @@ -532,13 +615,13 @@ protected function resolveMethodParameters($class, $method, array $callTimeUserP if ($type !== false && is_string($callTimeCurValue)) { if ($this->instanceManager->hasAlias($callTimeCurValue)) { // was an alias provided? - $computedParams['required'][$fqParamPos] = array( + $computedParams['retrieval'][$fqParamPos] = array( $callTimeUserParams[$name], $this->instanceManager->getClassFromAlias($callTimeCurValue) ); } elseif ($this->definitions->hasClass($callTimeUserParams[$name])) { // was a known class provided? - $computedParams['required'][$fqParamPos] = array( + $computedParams['retrieval'][$fqParamPos] = array( $callTimeCurValue, $callTimeCurValue ); @@ -577,13 +660,13 @@ protected function resolveMethodParameters($class, $method, array $callTimeUserP $computedParams['value'][$fqParamPos] = $iConfigCurValue; } elseif (is_string($iConfigCurValue) && isset($aliases[$iConfigCurValue])) { - $computedParams['required'][$fqParamPos] = array( + $computedParams['retrieval'][$fqParamPos] = array( $iConfig[$thisIndex]['parameters'][$name], $this->instanceManager->getClassFromAlias($iConfigCurValue) ); } elseif (is_string($iConfigCurValue) && $this->definitions->hasClass($iConfigCurValue)) { - $computedParams['required'][$fqParamPos] = array( + $computedParams['retrieval'][$fqParamPos] = array( $iConfigCurValue, $iConfigCurValue ); @@ -604,45 +687,49 @@ protected function resolveMethodParameters($class, $method, array $callTimeUserP // PRIORITY 6 - globally preferred implementations // next consult alias level preferred instances - if ($alias && $this->instanceManager->hasTypePreferences($alias)) { - $pInstances = $this->instanceManager->getTypePreferences($alias); - foreach ($pInstances as $pInstance) { - if (is_object($pInstance)) { - $computedParams['value'][$fqParamPos] = $pInstance; - continue 2; - } - $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? - $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; - if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) { - $computedParams['required'][$fqParamPos] = array($pInstance, $pInstanceClass); - continue 2; + // RESOLVE_EAGER wants to inject the cross-cutting concerns. + // If you want to retrieve an instance from TypePreferences, + // use AwareInterface or specify the method requirement option METHOD_IS_EAGER at ClassDefinition + if ($methodRequirementType & self::RESOLVE_EAGER) { + if ($alias && $this->instanceManager->hasTypePreferences($alias)) { + $pInstances = $this->instanceManager->getTypePreferences($alias); + foreach ($pInstances as $pInstance) { + if (is_object($pInstance)) { + $computedParams['value'][$fqParamPos] = $pInstance; + continue 2; + } + $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? + $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; + if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) { + $computedParams['retrieval'][$fqParamPos] = array($pInstance, $pInstanceClass); + continue 2; + } } } - } - // next consult class level preferred instances - if ($type && $this->instanceManager->hasTypePreferences($type)) { - $pInstances = $this->instanceManager->getTypePreferences($type); - foreach ($pInstances as $pInstance) { - if (is_object($pInstance)) { - $computedParams['value'][$fqParamPos] = $pInstance; - continue 2; - } - $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? - $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; - if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) { - $computedParams['required'][$fqParamPos] = array($pInstance, $pInstanceClass); - continue 2; + // next consult class level preferred instances + if ($type && $this->instanceManager->hasTypePreferences($type)) { + $pInstances = $this->instanceManager->getTypePreferences($type); + foreach ($pInstances as $pInstance) { + if (is_object($pInstance)) { + $computedParams['value'][$fqParamPos] = $pInstance; + continue 2; + } + $pInstanceClass = ($this->instanceManager->hasAlias($pInstance)) ? + $this->instanceManager->getClassFromAlias($pInstance) : $pInstance; + if ($pInstanceClass === $type || self::isSubclassOf($pInstanceClass, $type)) { + $computedParams['retrieval'][$fqParamPos] = array($pInstance, $pInstanceClass); + continue 2; + } } } } - if (!$isRequired) { $computedParams['optional'][$fqParamPos] = true; } - if ($type && $isRequired && $methodIsRequired) { - $computedParams['required'][$fqParamPos] = array($type, $type); + if ($type && $isRequired && ($methodRequirementType & self::RESOLVE_EAGER)) { + $computedParams['retrieval'][$fqParamPos] = array($type, $type); } } @@ -654,26 +741,62 @@ protected function resolveMethodParameters($class, $method, array $callTimeUserP if (isset($computedParams['value'][$fqParamPos])) { // if there is a value supplied, use it $resolvedParams[$index] = $computedParams['value'][$fqParamPos]; - } elseif (isset($computedParams['required'][$fqParamPos])) { + } elseif (isset($computedParams['retrieval'][$fqParamPos])) { // detect circular dependencies! (they can only happen in instantiators) - if ($isInstantiator && in_array($computedParams['required'][$fqParamPos][1], $this->currentDependencies)) { + if ($isInstantiator && in_array($computedParams['retrieval'][$fqParamPos][1], $this->currentDependencies)) { throw new Exception\CircularDependencyException( "Circular dependency detected: $class depends on {$value[1]} and viceversa" ); } array_push($this->currentDependencies, $class); - $dConfig = $this->instanceManager->getConfig($computedParams['required'][$fqParamPos][0]); + $dConfig = $this->instanceManager->getConfig($computedParams['retrieval'][$fqParamPos][0]); - if ($dConfig['shared'] === false) { - $resolvedParams[$index] = $this->newInstance($computedParams['required'][$fqParamPos][0], $callTimeUserParams, false); - } else { - $resolvedParams[$index] = $this->get($computedParams['required'][$fqParamPos][0], $callTimeUserParams); + try { + if ($dConfig['shared'] === false) { + $resolvedParams[$index] = $this->newInstance($computedParams['retrieval'][$fqParamPos][0], $callTimeUserParams, false); + } else { + $resolvedParams[$index] = $this->get($computedParams['retrieval'][$fqParamPos][0], $callTimeUserParams); + } + } catch (DiRuntimeException $e) { + if ($methodRequirementType & self::RESOLVE_STRICT) { + //finally ( be aware to do at the end of flow) + array_pop($this->currentDependencies); + // if this item was marked strict, + // plus it cannot be resolve, and no value exist, bail out + throw new Exception\MissingPropertyException(sprintf( + 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, + (($value[0] === null) ? 'value' : 'instance/object' ) + ), + $e->getCode(), + $e); + } else { + //finally ( be aware to do at the end of flow) + array_pop($this->currentDependencies); + return false; + } + } catch (ServiceManagerException $e) { + // Zend\ServiceManager\Exception\ServiceNotCreatedException + if ($methodRequirementType & self::RESOLVE_STRICT) { + //finally ( be aware to do at the end of flow) + array_pop($this->currentDependencies); + // if this item was marked strict, + // plus it cannot be resolve, and no value exist, bail out + throw new Exception\MissingPropertyException(sprintf( + 'Missing %s for parameter ' . $name . ' for ' . $class . '::' . $method, + (($value[0] === null) ? 'value' : 'instance/object' ) + ), + $e->getCode(), + $e); + } else { + //finally ( be aware to do at the end of flow) + array_pop($this->currentDependencies); + return false; + } } - array_pop($this->currentDependencies); } elseif (!array_key_exists($fqParamPos, $computedParams['optional'])) { - if ($methodIsRequired) { + if ($methodRequirementType & self::RESOLVE_STRICT) { // if this item was not marked as optional, // plus it cannot be resolve, and no value exist, bail out throw new Exception\MissingPropertyException(sprintf( diff --git a/src/Display/Console.php b/src/Display/Console.php index 92a92694..26b06253 100644 --- a/src/Display/Console.php +++ b/src/Display/Console.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Display; @@ -14,9 +13,6 @@ /** * Exporter for class definitions - * - * @category Zend - * @package Zend_Di */ class Console { @@ -179,5 +175,4 @@ protected function renderClassDefinition($definition, $class) } echo PHP_EOL; } - } diff --git a/src/Exception/CircularDependencyException.php b/src/Exception/CircularDependencyException.php index c9bb0df5..84012f9f 100644 --- a/src/Exception/CircularDependencyException.php +++ b/src/Exception/CircularDependencyException.php @@ -3,19 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; use DomainException; -/** - * @category Zend - * @package Zend_Di - */ class CircularDependencyException extends DomainException implements ExceptionInterface { } diff --git a/src/Exception/ClassNotFoundException.php b/src/Exception/ClassNotFoundException.php index a88a133d..b6b380ea 100644 --- a/src/Exception/ClassNotFoundException.php +++ b/src/Exception/ClassNotFoundException.php @@ -3,19 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; use DomainException; -/** - * @category Zend - * @package Zend_Di - */ class ClassNotFoundException extends DomainException implements ExceptionInterface { } diff --git a/src/Exception/ExceptionInterface.php b/src/Exception/ExceptionInterface.php index e3f185c3..02cf66d4 100644 --- a/src/Exception/ExceptionInterface.php +++ b/src/Exception/ExceptionInterface.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; -/** - * @category Zend - * @package Zend_Di - */ interface ExceptionInterface { } diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 6f097a8c..ae7c0aba 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; -/** - * @category Zend - * @package Zend_Di - */ class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface { } diff --git a/src/Exception/InvalidCallbackException.php b/src/Exception/InvalidCallbackException.php index 3f1b49a0..d80f06e9 100644 --- a/src/Exception/InvalidCallbackException.php +++ b/src/Exception/InvalidCallbackException.php @@ -3,18 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; /** * Exception to be thrown when an invalid php callback is provided - * - * @category Zend - * @package Zend_Di */ class InvalidCallbackException extends InvalidArgumentException { diff --git a/src/Exception/InvalidParamNameException.php b/src/Exception/InvalidParamNameException.php index 47e42452..bcb1e3f5 100644 --- a/src/Exception/InvalidParamNameException.php +++ b/src/Exception/InvalidParamNameException.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; -/** - * @category Zend - * @package Zend_Di - */ class InvalidParamNameException extends InvalidArgumentException { } diff --git a/src/Exception/InvalidPositionException.php b/src/Exception/InvalidPositionException.php index 3ac44b64..8a0ad80e 100644 --- a/src/Exception/InvalidPositionException.php +++ b/src/Exception/InvalidPositionException.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; -/** - * @category Zend - * @package Zend_Di - */ class InvalidPositionException extends InvalidArgumentException { } diff --git a/src/Exception/MissingPropertyException.php b/src/Exception/MissingPropertyException.php index 29a7f6fb..d2656ab9 100644 --- a/src/Exception/MissingPropertyException.php +++ b/src/Exception/MissingPropertyException.php @@ -3,19 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; use DomainException; -/** - * @category Zend - * @package Zend_Di - */ class MissingPropertyException extends DomainException implements ExceptionInterface { } diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index 7fb086ca..c33f1d55 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; -/** - * @category Zend - * @package Zend_Di - */ class RuntimeException extends \RuntimeException implements ExceptionInterface { } diff --git a/src/Exception/UndefinedReferenceException.php b/src/Exception/UndefinedReferenceException.php index 782d7b44..3d314a20 100644 --- a/src/Exception/UndefinedReferenceException.php +++ b/src/Exception/UndefinedReferenceException.php @@ -3,19 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\Exception; use DomainException; -/** - * @category Zend - * @package Zend_Di - */ class UndefinedReferenceException extends DomainException implements ExceptionInterface { } diff --git a/src/InstanceManager.php b/src/InstanceManager.php index 7618a847..e204090b 100644 --- a/src/InstanceManager.php +++ b/src/InstanceManager.php @@ -3,18 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; /** * Registry of instantiated objects, their names and the parameters used to build them - * - * @category Zend - * @package Zend_Di */ class InstanceManager /* implements InstanceManagerInterface */ { @@ -55,7 +51,7 @@ class InstanceManager /* implements InstanceManagerInterface */ * alias|class => bool */ 'shared' => true - ); + ); /** * An array of instance configuration data @@ -335,9 +331,9 @@ public function getConfig($aliasOrClass) $key = ($this->hasAlias($aliasOrClass)) ? 'alias:' . $this->getBaseAlias($aliasOrClass) : $aliasOrClass; if (isset($this->configurations[$key])) { return $this->configurations[$key]; - } else { - return $this->configurationTemplate; } + + return $this->configurationTemplate; } /** diff --git a/src/LocatorInterface.php b/src/LocatorInterface.php index 88ee6fc5..b4758d45 100644 --- a/src/LocatorInterface.php +++ b/src/LocatorInterface.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; -/** - * @category Zend - * @package Zend_Di - */ interface LocatorInterface { /** diff --git a/src/ServiceLocator.php b/src/ServiceLocator.php index 2d94527b..fd7d097b 100644 --- a/src/ServiceLocator.php +++ b/src/ServiceLocator.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; @@ -14,9 +13,6 @@ /** * Simple service locator implementation capable of using closures to generate instances - * - * @category Zend - * @package Zend_Di */ class ServiceLocator implements ServiceLocatorInterface { diff --git a/src/ServiceLocator/DependencyInjectorProxy.php b/src/ServiceLocator/DependencyInjectorProxy.php index c6056170..97bb4df6 100644 --- a/src/ServiceLocator/DependencyInjectorProxy.php +++ b/src/ServiceLocator/DependencyInjectorProxy.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\ServiceLocator; @@ -16,9 +15,6 @@ /** * Proxy used to analyze how instances are created by a given Di. Overrides Zend\Di\Di to produce artifacts that * represent the process used to instantiate a particular instance - * - * @category Zend - * @package Zend_Di */ class DependencyInjectorProxy extends Di { diff --git a/src/ServiceLocator/Generator.php b/src/ServiceLocator/Generator.php index f5c19926..a7182590 100644 --- a/src/ServiceLocator/Generator.php +++ b/src/ServiceLocator/Generator.php @@ -3,9 +3,8 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\ServiceLocator; @@ -20,9 +19,6 @@ /** * Generator that creates the body of a service locator that can emulate the logic of the given Zend\Di\Di instance * without class definitions - * - * @category Zend - * @package Zend_Di */ class Generator { diff --git a/src/ServiceLocator/GeneratorInstance.php b/src/ServiceLocator/GeneratorInstance.php index ef5e64ca..10e3c20a 100644 --- a/src/ServiceLocator/GeneratorInstance.php +++ b/src/ServiceLocator/GeneratorInstance.php @@ -3,18 +3,14 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di\ServiceLocator; /** * Container for methods and parameters used by by Di to create a particular instance - * - * @category Zend - * @package Zend_Di */ class GeneratorInstance { diff --git a/src/ServiceLocatorInterface.php b/src/ServiceLocatorInterface.php index 283c7ba9..32e2370b 100644 --- a/src/ServiceLocatorInterface.php +++ b/src/ServiceLocatorInterface.php @@ -3,17 +3,12 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @package Zend_Di */ namespace Zend\Di; -/** - * @category Zend - * @package Zend_Di - */ interface ServiceLocatorInterface extends LocatorInterface { /** diff --git a/test/ConfigTest.php b/test/ConfigTest.php index 93a8418d..91cb050d 100644 --- a/test/ConfigTest.php +++ b/test/ConfigTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/Definition/ArrayDefinitionTest.php b/test/Definition/ArrayDefinitionTest.php index aa8bcdc5..08edf9d4 100644 --- a/test/Definition/ArrayDefinitionTest.php +++ b/test/Definition/ArrayDefinitionTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/Definition/BuilderDefinitionTest.php b/test/Definition/BuilderDefinitionTest.php index 8ac99064..bdd64984 100644 --- a/test/Definition/BuilderDefinitionTest.php +++ b/test/Definition/BuilderDefinitionTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/Definition/ClassDefinitionTest.php b/test/Definition/ClassDefinitionTest.php index 00518192..afe97047 100644 --- a/test/Definition/ClassDefinitionTest.php +++ b/test/Definition/ClassDefinitionTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/Definition/CompilerDefinitionTest.php b/test/Definition/CompilerDefinitionTest.php index cdc5c05a..a27a3ffc 100644 --- a/test/Definition/CompilerDefinitionTest.php +++ b/test/Definition/CompilerDefinitionTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/Definition/RuntimeDefinitionTest.php b/test/Definition/RuntimeDefinitionTest.php index febefd81..9390504c 100644 --- a/test/Definition/RuntimeDefinitionTest.php +++ b/test/Definition/RuntimeDefinitionTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/DefinitionListTest.php b/test/DefinitionListTest.php index ea9a9352..33c4520c 100644 --- a/test/DefinitionListTest.php +++ b/test/DefinitionListTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository -* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) +* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ @@ -12,6 +12,7 @@ use Zend\Di\DefinitionList; use Zend\Di\Definition\ClassDefinition; +use Zend\Di\Definition\BuilderDefinition; use PHPUnit_Framework_TestCase as TestCase; @@ -29,6 +30,31 @@ public function testGetClassSupertypes() $definitionList = new DefinitionList(array($definitionClassA, $definitionClassB)); $this->assertEquals($superTypesA, $definitionList->getClassSupertypes("A")); + } + + public function testHasMethod() + { + $definitionClass = new ClassDefinition('foo'); + $definitionClass->addMethod('doFoo'); + $definitionList = new DefinitionList(array($definitionClass)); + + $this->assertTrue($definitionList->hasMethod('foo', 'doFoo')); + $this->assertFalse($definitionList->hasMethod('foo', 'doBar')); + + $definitionClass->addMethod('doBar'); + + $this->assertTrue($definitionList->hasMethod('foo', 'doBar')); + } + + public function testHasMethodAvoidAskingFromDefinitionsWhichDoNotIncludeClass() + { + $builderDefinition = new BuilderDefinition(); + + $definitionClass = new ClassDefinition('foo'); + $definitionClass->addMethod('doFoo'); + + $definitionList = new DefinitionList(array($builderDefinition, $definitionClass)); + $this->assertTrue($definitionList->hasMethod('foo', 'doFoo')); } } diff --git a/test/DiCompatibilityTest.php b/test/DiCompatibilityTest.php new file mode 100644 index 00000000..89b0ec23 --- /dev/null +++ b/test/DiCompatibilityTest.php @@ -0,0 +1,117 @@ +get($class); + + $this->assertInstanceOf($class, $bareObject, 'Test instantiate simple'); + $this->assertInstanceOf($class, $diObject, 'Test $di->get'); + } + + /** + * provides known classes invokable without parameters + * + * @return array + */ + public function providesSimpleClasses() + { + return array( + array('Zend\Di\Di'), + array('Zend\EventManager\EventManager'), + array('Zend\Filter\Null'), + array('Zend\Form\Form'), + array('Zend\Log\Logger'), + array('Zend\Stdlib\SplStack'), + array('Zend\View\Model\ViewModel'), + ); + } + + /** + * + * error: Missing argument 1 for $class::__construct() + * @dataProvider providesClassWithConstructionParameters + * @expectedException PHPUnit_Framework_Error + * @param string $class + */ + public function testRaiseErrorMissingConstructorRequiredParameter($class) + { + $bareObject = new $class; + $this->assertInstanceOf($class, $bareObject, 'Test instantiate simple'); + } + + /** + * + * @dataProvider providesClassWithConstructionParameters + * @expectedException \Zend\Di\Exception\MissingPropertyException + * @param string $class + */ + public function testWillThrowExceptionMissingConstructorRequiredParameterWithDi($class) + { + $di = new Di(); + $diObject = $di->get($class); + $this->assertInstanceOf($class, $diObject, 'Test $di->get'); + } + + /** + * + * @dataProvider providesClassWithConstructionParameters + * @param string $class + */ + public function testCanCreateInstanceWithConstructorRequiredParameter($class, $args) + { + $reflection = new \ReflectionClass($class); + $bareObject = $reflection->newInstanceArgs($args); + $this->assertInstanceOf($class, $bareObject, 'Test instantiate with constructor required parameters'); + } + + /** + * @dataProvider providesClassWithConstructionParameters + * @param string $class + */ + public function testCanCreateInstanceWithConstructorRequiredParameterWithDi($class, $args) + { + $di = new Di(); + $diObject = $di->get($class, $args); + $this->assertInstanceOf($class, $diObject, 'Test $di->get with constructor required paramters'); + } + + public function providesClassWithConstructionParameters() + { + $serviceManager = new \Zend\ServiceManager\ServiceManager; + $serviceManager->setService('EventManager', new \Zend\EventManager\EventManager); + $serviceManager->setService('Request', new \StdClass); + $serviceManager->setService('Response', new \StdClass); + + return array( + array('Zend\Config\Config', array('array' => array())), + array('Zend\Db\Adapter\Adapter', array('driver' => array('driver' => 'Pdo_Sqlite'))), + array('Zend\Mvc\Application', array('configuration' => array(), 'serviceManager' => $serviceManager)), + ); + } +} diff --git a/test/DiTest.php b/test/DiTest.php index 4623c237..01fae76a 100644 --- a/test/DiTest.php +++ b/test/DiTest.php @@ -3,19 +3,18 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ namespace ZendTest\Di; -use Zend\Di\Di; -use Zend\Di\DefinitionList; -use Zend\Di\InstanceManager; use Zend\Di\Config; use Zend\Di\Definition; - +use Zend\Di\DefinitionList; +use Zend\Di\Di; +use Zend\Di\InstanceManager; class DiTest extends \PHPUnit_Framework_TestCase { @@ -78,8 +77,8 @@ public function testGetRetrievesDifferentInstanceOnSubsequentCallsIfSharingDisab 'instance' => array( 'ZendTest\Di\TestAsset\BasicClass' => array( 'shared' => false, - ), ), + ), )); $di = new Di(null, null, $config); $obj1 = $di->get('ZendTest\Di\TestAsset\BasicClass'); @@ -89,6 +88,31 @@ public function testGetRetrievesDifferentInstanceOnSubsequentCallsIfSharingDisab $this->assertNotSame($obj1, $obj2); } + public function testGetRetrievesSameSharedInstanceOnUsingInConstructor() + { + $config = new Config(array( + 'instance' => array( + 'ZendTest\Di\TestAsset\BasicClass' => array( + 'shared' => true, + ), + ), + )); + $di = new Di(null, null, $config); + $obj1 = $di->get('ZendTest\Di\TestAsset\BasicClassWithParent', array('foo' => 0)); + $obj2 = $di->get('ZendTest\Di\TestAsset\BasicClassWithParent', array('foo' => 1)); + $obj3 = $di->get('ZendTest\Di\TestAsset\BasicClassWithParent', array('foo' => 2, 'non_exists' => 1)); + $objParent1 = $di->get('ZendTest\Di\TestAsset\BasicClass'); + $objParent2 = $di->get('ZendTest\Di\TestAsset\BasicClass', array('foo' => 1)); + + $this->assertInstanceOf('ZendTest\Di\TestAsset\BasicClassWithParent', $obj1); + $this->assertInstanceOf('ZendTest\Di\TestAsset\BasicClassWithParent', $obj2); + $this->assertInstanceOf('ZendTest\Di\TestAsset\BasicClassWithParent', $obj3); + $this->assertSame($obj1->parent, $obj2->parent); + $this->assertSame($obj2->parent, $obj3->parent); + $this->assertSame($obj3->parent, $objParent1); + $this->assertSame($obj3->parent, $objParent2); + } + public function testGetThrowsExceptionWhenUnknownClassIsUsed() { $di = new Di(); @@ -431,7 +455,13 @@ public function testNewInstanceThrowsExceptionWhenEnteringInMiddleOfCircularDepe */ public function testNewInstanceWillUsePreferredClassForInterfaceHints() { - $di = new Di(); + $definitionList = new DefinitionList(array( + $classdef = new Definition\ClassDefinition('ZendTest\Di\TestAsset\PreferredImplClasses\C'), + new Definition\RuntimeDefinition() + )); + $classdef->addMethod('setA', Di::METHOD_IS_EAGER); + $di = new Di($definitionList); + $di->instanceManager()->addTypePreference( 'ZendTest\Di\TestAsset\PreferredImplClasses\A', 'ZendTest\Di\TestAsset\PreferredImplClasses\BofA' @@ -444,6 +474,35 @@ public function testNewInstanceWillUsePreferredClassForInterfaceHints() $this->assertSame($a, $d->a); } + public function testMatchPreferredClassWithAwareInterface() + { + $di = new Di(); + + $di->instanceManager()->addTypePreference( + 'ZendTest\Di\TestAsset\PreferredImplClasses\A', + 'ZendTest\Di\TestAsset\PreferredImplClasses\BofA' + ); + + $e = $di->get('ZendTest\Di\TestAsset\PreferredImplClasses\E'); + $this->assertInstanceOf('ZendTest\Di\TestAsset\PreferredImplClasses\BofA', $e->a); + } + + public function testWillNotUsePreferredClassForInterfaceHints() + { + $di = new Di(); + + $di->instanceManager()->addTypePreference( + 'ZendTest\Di\TestAsset\PreferredImplClasses\A', + 'ZendTest\Di\TestAsset\PreferredImplClasses\BofA' + ); + + $c = $di->get('ZendTest\Di\TestAsset\PreferredImplClasses\C'); + $a = $c->a; + $this->assertNull($a); + $d = $di->get('ZendTest\Di\TestAsset\PreferredImplClasses\D'); + $this->assertNull($d->a); + } + public function testInjectionInstancesCanBeInjectedMultipleTimes() { $definitionList = new DefinitionList(array( @@ -754,4 +813,33 @@ public function testDiWillInjectDefaultParameters() $this->assertSame('defaultConstruct', $optionalParams->b); $this->assertSame(array(), $optionalParams->c); } + + /** + * @group SharedInstance + */ + public function testGetWithParamsWillUseSharedInstance() + { + $di = new Di; + + $sharedInstanceClass = 'ZendTest\Di\TestAsset\ConstructorInjection\A'; + $retrievedInstanceClass = 'ZendTest\Di\TestAsset\ConstructorInjection\C'; + + // Provide definitions for $retrievedInstanceClass, but not for $sharedInstanceClass. + $arrayDefinition = array($retrievedInstanceClass => array ( + 'supertypes' => array ( ), + 'instantiator' => '__construct', + 'methods' => array ('__construct' => true), + 'parameters' => array ( '__construct' => array ( + "$retrievedInstanceClass::__construct:0" => array ('a', $sharedInstanceClass, true, NULL), + "$retrievedInstanceClass::__construct:1" => array ('params', NULL, false, array()), + )), + )); + + // This also disables scanning of class A. + $di->setDefinitionList(new DefinitionList(new Definition\ArrayDefinition($arrayDefinition))); + + $di->instanceManager()->addSharedInstance(new $sharedInstanceClass, $sharedInstanceClass); + $returnedC = $di->get($retrievedInstanceClass, array('params' => array('test'))); + $this->assertInstanceOf($retrievedInstanceClass, $returnedC); + } } diff --git a/test/InstanceManagerTest.php b/test/InstanceManagerTest.php index 82b22ebc..cb818b6a 100644 --- a/test/InstanceManagerTest.php +++ b/test/InstanceManagerTest.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/ServiceLocator/DependencyInjectorProxyTest.php b/test/ServiceLocator/DependencyInjectorProxyTest.php index 0ea48ce7..d7815ab9 100644 --- a/test/ServiceLocator/DependencyInjectorProxyTest.php +++ b/test/ServiceLocator/DependencyInjectorProxyTest.php @@ -1,4 +1,12 @@ parent = $parent; + } +} diff --git a/test/TestAsset/CallbackClasses/A.php b/test/TestAsset/CallbackClasses/A.php index a9ad085a..5ff32d31 100644 --- a/test/TestAsset/CallbackClasses/A.php +++ b/test/TestAsset/CallbackClasses/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CallbackClasses/B.php b/test/TestAsset/CallbackClasses/B.php index 002e2ca8..4b91529e 100644 --- a/test/TestAsset/CallbackClasses/B.php +++ b/test/TestAsset/CallbackClasses/B.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CallbackClasses/C.php b/test/TestAsset/CallbackClasses/C.php index 1004d252..cfa5f345 100644 --- a/test/TestAsset/CallbackClasses/C.php +++ b/test/TestAsset/CallbackClasses/C.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CircularClasses/A.php b/test/TestAsset/CircularClasses/A.php index 2bb95291..719c9af3 100644 --- a/test/TestAsset/CircularClasses/A.php +++ b/test/TestAsset/CircularClasses/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CircularClasses/B.php b/test/TestAsset/CircularClasses/B.php index 0e7f9b3b..0ead116b 100644 --- a/test/TestAsset/CircularClasses/B.php +++ b/test/TestAsset/CircularClasses/B.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CircularClasses/C.php b/test/TestAsset/CircularClasses/C.php index 6e1631e5..12c47353 100644 --- a/test/TestAsset/CircularClasses/C.php +++ b/test/TestAsset/CircularClasses/C.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CircularClasses/D.php b/test/TestAsset/CircularClasses/D.php index 61170047..c8b7ab01 100644 --- a/test/TestAsset/CircularClasses/D.php +++ b/test/TestAsset/CircularClasses/D.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CircularClasses/E.php b/test/TestAsset/CircularClasses/E.php index d0e11917..6883dc21 100644 --- a/test/TestAsset/CircularClasses/E.php +++ b/test/TestAsset/CircularClasses/E.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CircularClasses/X.php b/test/TestAsset/CircularClasses/X.php index ff9c0e67..58befddf 100644 --- a/test/TestAsset/CircularClasses/X.php +++ b/test/TestAsset/CircularClasses/X.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CompilerClasses/A.php b/test/TestAsset/CompilerClasses/A.php index 611ccfed..dcc8a117 100644 --- a/test/TestAsset/CompilerClasses/A.php +++ b/test/TestAsset/CompilerClasses/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CompilerClasses/B.php b/test/TestAsset/CompilerClasses/B.php index 79f74e1f..72424ce4 100644 --- a/test/TestAsset/CompilerClasses/B.php +++ b/test/TestAsset/CompilerClasses/B.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CompilerClasses/C.php b/test/TestAsset/CompilerClasses/C.php index b6b9a680..c232e9f7 100644 --- a/test/TestAsset/CompilerClasses/C.php +++ b/test/TestAsset/CompilerClasses/C.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CompilerClasses/D.php b/test/TestAsset/CompilerClasses/D.php index c4d02dee..6ff4e351 100644 --- a/test/TestAsset/CompilerClasses/D.php +++ b/test/TestAsset/CompilerClasses/D.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CompilerClasses/E.php b/test/TestAsset/CompilerClasses/E.php index cb79f8e2..f15bbf83 100644 --- a/test/TestAsset/CompilerClasses/E.php +++ b/test/TestAsset/CompilerClasses/E.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/CompilerClasses/F.php b/test/TestAsset/CompilerClasses/F.php index 9317f74f..35a52131 100644 --- a/test/TestAsset/CompilerClasses/F.php +++ b/test/TestAsset/CompilerClasses/F.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ComposedClass.php b/test/TestAsset/ComposedClass.php index b2a607d8..3a60014f 100644 --- a/test/TestAsset/ComposedClass.php +++ b/test/TestAsset/ComposedClass.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ConstructorInjection/A.php b/test/TestAsset/ConstructorInjection/A.php index 61849a61..339217c8 100644 --- a/test/TestAsset/ConstructorInjection/A.php +++ b/test/TestAsset/ConstructorInjection/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ConstructorInjection/B.php b/test/TestAsset/ConstructorInjection/B.php index 11984eee..43eb0c01 100644 --- a/test/TestAsset/ConstructorInjection/B.php +++ b/test/TestAsset/ConstructorInjection/B.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ConstructorInjection/C.php b/test/TestAsset/ConstructorInjection/C.php new file mode 100644 index 00000000..751efa1b --- /dev/null +++ b/test/TestAsset/ConstructorInjection/C.php @@ -0,0 +1,22 @@ +a = $a; + $this->params = $params; + } +} diff --git a/test/TestAsset/ConstructorInjection/OptionalParameters.php b/test/TestAsset/ConstructorInjection/OptionalParameters.php index 045e7e63..6fa0298a 100644 --- a/test/TestAsset/ConstructorInjection/OptionalParameters.php +++ b/test/TestAsset/ConstructorInjection/OptionalParameters.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ConstructorInjection/X.php b/test/TestAsset/ConstructorInjection/X.php index 565277a3..e3f7ae76 100644 --- a/test/TestAsset/ConstructorInjection/X.php +++ b/test/TestAsset/ConstructorInjection/X.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ConstructorInjection/Y.php b/test/TestAsset/ConstructorInjection/Y.php index 783d6972..dee7e356 100644 --- a/test/TestAsset/ConstructorInjection/Y.php +++ b/test/TestAsset/ConstructorInjection/Y.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ConstructorInjection/Z.php b/test/TestAsset/ConstructorInjection/Z.php index 67d692e5..40fa24a5 100644 --- a/test/TestAsset/ConstructorInjection/Z.php +++ b/test/TestAsset/ConstructorInjection/Z.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/ContainerExtension.php b/test/TestAsset/ContainerExtension.php index 7f14ef2b..b0a52f23 100644 --- a/test/TestAsset/ContainerExtension.php +++ b/test/TestAsset/ContainerExtension.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/DummyParams.php b/test/TestAsset/DummyParams.php index a46cbf27..f5769c42 100644 --- a/test/TestAsset/DummyParams.php +++ b/test/TestAsset/DummyParams.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InheritanceClasses/A.php b/test/TestAsset/InheritanceClasses/A.php index e65cd54b..9abf6fda 100644 --- a/test/TestAsset/InheritanceClasses/A.php +++ b/test/TestAsset/InheritanceClasses/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InheritanceClasses/B.php b/test/TestAsset/InheritanceClasses/B.php index aeb3f426..1d4640d9 100644 --- a/test/TestAsset/InheritanceClasses/B.php +++ b/test/TestAsset/InheritanceClasses/B.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InheritanceClasses/C.php b/test/TestAsset/InheritanceClasses/C.php index 0631ab94..1ee95f00 100644 --- a/test/TestAsset/InheritanceClasses/C.php +++ b/test/TestAsset/InheritanceClasses/C.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InjectionClasses/A.php b/test/TestAsset/InjectionClasses/A.php index dc971f2b..1f4bdace 100644 --- a/test/TestAsset/InjectionClasses/A.php +++ b/test/TestAsset/InjectionClasses/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InjectionClasses/B.php b/test/TestAsset/InjectionClasses/B.php index be1e4d19..a757983b 100644 --- a/test/TestAsset/InjectionClasses/B.php +++ b/test/TestAsset/InjectionClasses/B.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InjectionClasses/C.php b/test/TestAsset/InjectionClasses/C.php index 630fa4f1..95c30e73 100644 --- a/test/TestAsset/InjectionClasses/C.php +++ b/test/TestAsset/InjectionClasses/C.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InspectedClass.php b/test/TestAsset/InspectedClass.php index 8a62305e..923c20b4 100644 --- a/test/TestAsset/InspectedClass.php +++ b/test/TestAsset/InspectedClass.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/InvalidCompilerClasses/InvalidClass.php b/test/TestAsset/InvalidCompilerClasses/InvalidClass.php index 27c8f46a..82b4daa9 100644 --- a/test/TestAsset/InvalidCompilerClasses/InvalidClass.php +++ b/test/TestAsset/InvalidCompilerClasses/InvalidClass.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/OptionalArg.php b/test/TestAsset/OptionalArg.php index db011d30..4a500ae4 100644 --- a/test/TestAsset/OptionalArg.php +++ b/test/TestAsset/OptionalArg.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/PreferredImplClasses/A.php b/test/TestAsset/PreferredImplClasses/A.php index d14c3e91..e69469eb 100644 --- a/test/TestAsset/PreferredImplClasses/A.php +++ b/test/TestAsset/PreferredImplClasses/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/PreferredImplClasses/AAwareInterface.php b/test/TestAsset/PreferredImplClasses/AAwareInterface.php new file mode 100644 index 00000000..5afed28a --- /dev/null +++ b/test/TestAsset/PreferredImplClasses/AAwareInterface.php @@ -0,0 +1,15 @@ +a = $a; + } +} diff --git a/test/TestAsset/SetterInjection/A.php b/test/TestAsset/SetterInjection/A.php index 66881ab7..6b2dc325 100644 --- a/test/TestAsset/SetterInjection/A.php +++ b/test/TestAsset/SetterInjection/A.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SetterInjection/B.php b/test/TestAsset/SetterInjection/B.php index b091332f..c7f640b1 100644 --- a/test/TestAsset/SetterInjection/B.php +++ b/test/TestAsset/SetterInjection/B.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SetterInjection/C.php b/test/TestAsset/SetterInjection/C.php index 5b452f7c..20a19605 100644 --- a/test/TestAsset/SetterInjection/C.php +++ b/test/TestAsset/SetterInjection/C.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SetterInjection/D.php b/test/TestAsset/SetterInjection/D.php index da2e76f8..5bc64bc1 100644 --- a/test/TestAsset/SetterInjection/D.php +++ b/test/TestAsset/SetterInjection/D.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SetterInjection/StaticSetter.php b/test/TestAsset/SetterInjection/StaticSetter.php index 307b3a01..2aff5700 100644 --- a/test/TestAsset/SetterInjection/StaticSetter.php +++ b/test/TestAsset/SetterInjection/StaticSetter.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SetterInjection/X.php b/test/TestAsset/SetterInjection/X.php index 55f0f48d..61496ac5 100644 --- a/test/TestAsset/SetterInjection/X.php +++ b/test/TestAsset/SetterInjection/X.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SetterInjection/Y.php b/test/TestAsset/SetterInjection/Y.php index 17268b63..ef3adb69 100644 --- a/test/TestAsset/SetterInjection/Y.php +++ b/test/TestAsset/SetterInjection/Y.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SetterInjection/Z.php b/test/TestAsset/SetterInjection/Z.php index 131a5447..cde2dea8 100644 --- a/test/TestAsset/SetterInjection/Z.php +++ b/test/TestAsset/SetterInjection/Z.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SharedInstance/Lister.php b/test/TestAsset/SharedInstance/Lister.php index da0ee5cb..3f7e753f 100644 --- a/test/TestAsset/SharedInstance/Lister.php +++ b/test/TestAsset/SharedInstance/Lister.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SharedInstance/Movie.php b/test/TestAsset/SharedInstance/Movie.php index 05d80902..43a08c74 100644 --- a/test/TestAsset/SharedInstance/Movie.php +++ b/test/TestAsset/SharedInstance/Movie.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SharedInstance/SharedLister.php b/test/TestAsset/SharedInstance/SharedLister.php index bec4cfb3..9bce8ba6 100644 --- a/test/TestAsset/SharedInstance/SharedLister.php +++ b/test/TestAsset/SharedInstance/SharedLister.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/SharedInstance/Venue.php b/test/TestAsset/SharedInstance/Venue.php index aea8ad8c..25ae295e 100644 --- a/test/TestAsset/SharedInstance/Venue.php +++ b/test/TestAsset/SharedInstance/Venue.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/StaticFactory.php b/test/TestAsset/StaticFactory.php index faac19fb..2a6824e3 100644 --- a/test/TestAsset/StaticFactory.php +++ b/test/TestAsset/StaticFactory.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */ diff --git a/test/TestAsset/Struct.php b/test/TestAsset/Struct.php index dda0bc64..6180d1b2 100644 --- a/test/TestAsset/Struct.php +++ b/test/TestAsset/Struct.php @@ -3,7 +3,7 @@ * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository - * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @package Zend_Di */