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

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Quoc Vu committed May 9, 2013
175 parents 61d8584 + 24a5c98 + e9dd8c9 + 5b5a91a + db9fc36 + f8b7f2b + 09edbcb + 6a99da4 + 4a9dd4d + cc4af6e + 8a07675 + c30b083 + 0c6e411 + be4dae7 + 7465e5d + 1b64e7d + 1f50979 + 92b6722 + 1d54f79 + ab5cea3 + 4f0b000 + c18caa3 + 98036b5 + 3b5c10e + a248769 + 560d3a2 + ddfdb8f + fd4ce84 + 9e4c786 + 0c0695c + 500c51d + 2f2ebee + 145abe5 + bf5d8d7 + fe0fb99 + 5f7322a + c3af80d + cf95a03 + 6a80fae + 10ed584 + 053ab77 + 495f1ba + d688369 + 56b2490 + 47a689e + f52f94e + fec9c74 + 28a9d88 + ac66d19 + 041ae5a + 63454d4 + da02d07 + 698a4d6 + 35967e7 + 427640f + 64a533c + e408635 + c004297 + b38b581 + 9a9f950 + 47a731a + 0967316 + 37f548b + 0df2db0 + e43587e + 5784352 + 93b4f40 + 3208a48 + f5dfded + 8301af5 + d4a4329 + eaf7585 + 12feb56 + 387d3ed + eb7fedd + a9a0285 + 44fa883 + 08a171a + a4b0e54 + 730ce14 + c24c880 + 80e40b3 + 20961e5 + 8cb611e + c958861 + b8b41bc + f82d7c5 + 7784cd5 + 4ed737c + 785b23e + b537b08 + 34ecc47 + 45265ad + df6c341 + efa67eb + 736f9f8 + d3b33d9 + be06520 + be3997d + e7fb236 + 5b19875 + ed60259 + ae0af2f + 761379e + 118bbd6 + 9ce360b + 4d4425a + cc47b49 + c4aa2e1 + c152f67 + bd774aa + a95f940 + fb3126d + f420aa3 + 288aa3f + 9fa9257 + 82606a6 + cbe2b1f + 46ed6e3 + 085bc16 + 02a1820 + c8f7092 + fc19ae0 + 7d5a2cf + e35be49 + b1baf86 + 26aba26 + 306f3e6 + 104e613 + 9e0f279 + a19bb44 + 8553b0b + 5f35882 + ebdb37c + 3c57460 + d38a8d4 + 5725284 + 9bc667a + 5eedb7e + 0e7a856 + fc7c32a + d1f2eb1 + 5c87eda + 71d8d27 + a365923 + 7f777b6 + c62bcc9 + 4bd3bc3 + a183e11 + 84e6810 + edad949 + 043bfb5 + 8e6f606 + 1c2b629 + e4251d2 + e8c20f9 + 6de8d76 + e529dce + 24f43fa + 336bb38 + d86e872 + 41e010c + 6a5ab3d + ca50dd5 + 8b8277a + 379140a + 145dec3 + 34c979d + 838aade + 7e77c89 + 4357e91 + 6f1e5af + a847f61 + 88ffcfe + 73019c6 commit 6b1491a
Show file tree
Hide file tree
Showing 105 changed files with 726 additions and 524 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
18 changes: 4 additions & 14 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,19 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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
{
Expand Down Expand Up @@ -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']);
}

}

/**
Expand All @@ -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
Expand Down Expand Up @@ -146,9 +140,7 @@ public function configureDefinition(Di $di, $definition)
}
}
}

}

}

/**
Expand Down Expand Up @@ -200,7 +192,5 @@ public function configureInstance(Di $di, $instanceData)
}
}
}

}

}
6 changes: 1 addition & 5 deletions src/Definition/Annotation/Inject.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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;
Expand All @@ -14,9 +13,6 @@

/**
* Annotation for injection endpoints for dependencies
*
* @category Zend
* @package Zend_Di
*/
class Inject implements AnnotationInterface
{
Expand Down
6 changes: 1 addition & 5 deletions src/Definition/Annotation/Instantiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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;
Expand All @@ -14,9 +13,6 @@

/**
* Annotation for instantiator
*
* @category Zend
* @package Zend_Di
*/
class Instantiator implements AnnotationInterface
{
Expand Down
18 changes: 12 additions & 6 deletions src/Definition/ArrayDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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
{
Expand All @@ -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;
}

Expand Down Expand Up @@ -166,5 +173,4 @@ public function toArray()
{
return $this->dataArray;
}

}
56 changes: 50 additions & 6 deletions src/Definition/Builder/InjectionMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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
{
Expand Down Expand Up @@ -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,
);

Expand All @@ -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;
}
}
7 changes: 1 addition & 6 deletions src/Definition/Builder/PhpClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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
{
Expand Down Expand Up @@ -176,5 +172,4 @@ public function getInjectionMethods()
{
return $this->injectionMethods;
}

}
7 changes: 1 addition & 6 deletions src/Definition/BuilderDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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;
Expand All @@ -14,9 +13,6 @@

/**
* Class definitions based on a configuration array
*
* @category Zend
* @package Zend_Di
*/
class BuilderDefinition implements DefinitionInterface
{
Expand Down Expand Up @@ -322,5 +318,4 @@ public function getMethodParameters($class, $method)

return $methodParameters;
}

}
33 changes: 21 additions & 12 deletions src/Definition/ClassDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
* Zend Framework (http://framework.zend.com/)
*
* @link https://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
{
Expand Down Expand Up @@ -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;
}
Expand All @@ -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)) {
Expand Down Expand Up @@ -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;
}

/**
Expand Down
Loading

0 comments on commit 6b1491a

Please sign in to comment.