Skip to content

Commit 0eb7ab5

Browse files
committed
MAGETWO-33080: Preferences, Shared Instance creation and Compiled Factory optimization
- fixed refactoring bug
1 parent 3df55f9 commit 0eb7ab5

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

dev/tests/unit/testsuite/Magento/Framework/App/FactoryStub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public function __construct($config, $objectManager = null, $definitions = null,
2525
/**
2626
* Create instance with call time arguments
2727
*
28-
* @param string $type
28+
* @param string $requestedType
2929
* @param array $arguments
3030
* @return object
3131
* @throws \BadMethodCallException
3232
*/
33-
public function create($type, array $arguments = [])
33+
public function create($requestedType, array $arguments = [])
3434
{
3535
throw new \BadMethodCallException(__METHOD__);
3636
}

lib/internal/Magento/Framework/ObjectManager/Factory/Compiled.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ public function __construct(
4545
/**
4646
* Create instance with call time arguments
4747
*
48-
* @param string $type
48+
* @param string $requestedType
4949
* @param array $arguments
5050
* @return object
5151
* @throws \Exception
5252
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
5353
*/
54-
public function create($type, array $arguments = [])
54+
public function create($requestedType, array $arguments = [])
5555
{
5656
/** @TODO get rid of ltrim() usage and place it to client code */
57-
$args = $this->config->getArguments($type);
58-
$type = $this->config->getInstanceType($type);
57+
$args = $this->config->getArguments($requestedType);
58+
$type = $this->config->getInstanceType($requestedType);
5959
if ($args === null) {
6060
return new $type();
6161
}

lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Developer.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,31 +60,31 @@ protected function _resolveArguments($requestedType, array $parameters, array $a
6060
/**
6161
* Create instance with call time arguments
6262
*
63-
* @param string $type
63+
* @param string $requestedType
6464
* @param array $arguments
6565
* @return object
6666
* @throws \Exception
6767
*
6868
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
6969
*/
70-
public function create($type, array $arguments = [])
70+
public function create($requestedType, array $arguments = [])
7171
{
72-
$type = $this->config->getInstanceType($type);
72+
$type = $this->config->getInstanceType($requestedType);
7373
$parameters = $this->definitions->getParameters($type);
7474
if ($parameters == null) {
7575
return new $type();
7676
}
77-
if (isset($this->creationStack[$type])) {
77+
if (isset($this->creationStack[$requestedType])) {
7878
$lastFound = end($this->creationStack);
7979
$this->creationStack = [];
80-
throw new \LogicException("Circular dependency: {$type} depends on {$lastFound} and vice versa.");
80+
throw new \LogicException("Circular dependency: {$requestedType} depends on {$lastFound} and vice versa.");
8181
}
82-
$this->creationStack[$type] = $type;
82+
$this->creationStack[$requestedType] = $requestedType;
8383
try {
84-
$args = $this->_resolveArguments($type, $parameters, $arguments);
85-
unset($this->creationStack[$type]);
84+
$args = $this->_resolveArguments($requestedType, $parameters, $arguments);
85+
unset($this->creationStack[$requestedType]);
8686
} catch (\Exception $e) {
87-
unset($this->creationStack[$type]);
87+
unset($this->creationStack[$requestedType]);
8888
throw $e;
8989
}
9090

lib/internal/Magento/Framework/ObjectManager/Factory/Dynamic/Production.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ protected function _resolveArguments($requestedType, array $parameters, array $a
4646
/**
4747
* Create instance with call time arguments
4848
*
49-
* @param string $type
49+
* @param string $requestedType
5050
* @param array $arguments
5151
*
5252
* @return object
5353
*
5454
* @throws \Exception
5555
*/
56-
public function create($type, array $arguments = [])
56+
public function create($requestedType, array $arguments = [])
5757
{
58-
$type = $this->config->getInstanceType($type);
58+
$type = $this->config->getInstanceType($requestedType);
5959
$parameters = $this->definitions->getParameters($type);
6060
if ($parameters == null) {
6161
return new $type();
6262
}
63-
$args = $this->_resolveArguments($type, $parameters, $arguments);
63+
$args = $this->_resolveArguments($requestedType, $parameters, $arguments);
6464

6565
return $this->createObject($type, $args);
6666
}

lib/internal/Magento/Framework/ObjectManager/FactoryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ interface FactoryInterface
1010
/**
1111
* Create instance with call time arguments
1212
*
13-
* @param string $type
13+
* @param string $requestedType
1414
* @param array $arguments
1515
* @return object
1616
* @throws \LogicException
1717
* @throws \BadMethodCallException
1818
*/
19-
public function create($type, array $arguments = []);
19+
public function create($requestedType, array $arguments = []);
2020
}

lib/internal/Magento/Framework/ObjectManager/Profiler/FactoryDecorator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ public function setObjectManager(\Magento\Framework\ObjectManagerInterface $obje
4141
/**
4242
* {@inheritdoc}
4343
*/
44-
public function create($type, array $arguments = [])
44+
public function create($requestedType, array $arguments = [])
4545
{
46-
$this->log->startCreating($type);
47-
$result = $this->subject->create($type, $arguments);
46+
$this->log->startCreating($requestedType);
47+
$result = $this->subject->create($requestedType, $arguments);
4848
$loggerClassName = get_class($result) . "\\Logger";
4949
$wrappedResult = new $loggerClassName($result, $this->log);
5050
$this->log->stopCreating($result);

0 commit comments

Comments
 (0)