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 'Maks3w/hotfix/di-fixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/InstanceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public function getConfiguration($aliasOrClass)
*/
public function setParameters($aliasOrClass, array $parameters)
{
return $this->setConfiguration($aliasOrClass, array('parameters' => $parameters), true);
$this->setConfiguration($aliasOrClass, array('parameters' => $parameters), true);
}

/**
Expand All @@ -290,12 +290,12 @@ public function setParameters($aliasOrClass, array $parameters)
*/
public function setInjections($aliasOrClass, array $injections)
{
return $this->setConfiguration($aliasOrClass, array('injections' => $injections), true);
$this->setConfiguration($aliasOrClass, array('injections' => $injections), true);
}

public function setShared($aliasOrClass, $isShared)
{
return $this->setConfiguration($aliasOrClass, array('shared' => $isShared), true);
$this->setConfiguration($aliasOrClass, array('shared' => $isShared), true);
}

public function hasTypePreferences($interfaceOrAbstract)
Expand Down
5 changes: 2 additions & 3 deletions src/ServiceLocator/DependencyInjectorProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
class DependencyInjectorProxy extends Di
{
/**
* @var DependencyInjector
* @var Di
*/
protected $di;

/**
* @param DependencyInjector $di
* @return void
* @param Di $di
*/
public function __construct(Di $di)
{
Expand Down
36 changes: 18 additions & 18 deletions src/ServiceLocator/Generator.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?php
// @todo refactor to use new Definition interface

namespace Zend\Di\ServiceLocator;

use Zend\Di\Di,
Zend\CodeGenerator\Php as CodeGen,
Zend\Di\DependencyInjectionInterface,
Zend\Code\Generator as CodeGen,
Zend\Di\Exception;

/**
* @todo refactor to use new Definition interface
*/
class Generator
{
protected $containerClass = 'ApplicationContext';

/** @var DependencyInjectorProxy */
protected $injector;

protected $namespace;
Expand All @@ -20,8 +23,7 @@ class Generator
*
* Requires a DependencyInjection manager on which to operate.
*
* @param DependencyInjectionInterface $injector
* @return void
* @param Di $injector
*/
public function __construct(Di $injector)
{
Expand Down Expand Up @@ -59,7 +61,7 @@ public function setNamespace($namespace)
* created the specified class and service locator methods.
*
* @param null|string $filename
* @return CodeGen\PhpFile
* @return CodeGen\FileGenerator
*/
public function getCodeGenerator($filename = null)
{
Expand Down Expand Up @@ -124,7 +126,7 @@ public function getCodeGenerator($filename = null)

// Create method call code
$methods = '';
foreach ($meta->getMethods() as $key => $methodData) {
foreach ($meta->getMethods() as $methodData) {
if (!isset($methodData['name']) && !isset($methodData['method'])) {
continue;
}
Expand Down Expand Up @@ -185,7 +187,7 @@ public function getCodeGenerator($filename = null)
// End getter body
$getterBody .= "return \$object;\n";

$getterDef = new CodeGen\PhpMethod();
$getterDef = new CodeGen\MethodGenerator();
$getterDef->setName($getter)
->setBody($getterBody);
$getters[] = $getterDef;
Expand All @@ -212,16 +214,14 @@ public function getCodeGenerator($filename = null)
$switch .= "}\n\n";

// Build get() method
$nameParam = new CodeGen\PhpParameter();
$nameParam = new CodeGen\ParameterGenerator();
$nameParam->setName('name');
$defaultParams = new CodeGen\PhpParameterDefaultValue();
$defaultParams->setValue(array());
$paramsParam = new CodeGen\PhpParameter();
$paramsParam = new CodeGen\ParameterGenerator();
$paramsParam->setName('params')
->setType('array')
->setDefaultValue($defaultParams);
->setDefaultValue(array());

$get = new CodeGen\PhpMethod();
$get = new CodeGen\MethodGenerator();
$get->setName('get');
$get->setParameters(array(
$nameParam,
Expand All @@ -238,15 +238,15 @@ public function getCodeGenerator($filename = null)
}

// Create class code generation object
$container = new CodeGen\PhpClass();
$container = new CodeGen\ClassGenerator();
$container->setName($this->containerClass)
->setExtendedClass('ServiceLocator')
->addMethodFromGenerator($get)
->addMethods($getters)
->addMethods($aliasMethods);

// Create PHP file code generation object
$classFile = new CodeGen\PhpFile();
$classFile = new CodeGen\FileGenerator();
$classFile->setUse('Zend\Di\ServiceLocator')
->setClass($container);

Expand Down Expand Up @@ -294,12 +294,12 @@ protected function reduceAliases(array $aliasList)
*
* @param string $alias
* @param class $class Class to which alias refers
* @return CodeGen\PhpMethod
* @return CodeGen\MethodGenerator
*/
protected function getCodeGenMethodFromAlias($alias, $class)
{
$alias = $this->normalizeAlias($alias);
$method = new CodeGen\PhpMethod();
$method = new CodeGen\MethodGenerator();
$method->setName($alias)
->setBody(sprintf('return $this->get(\'%s\');', $class));
return $method;
Expand Down

0 comments on commit ddfdb8f

Please sign in to comment.