Skip to content

Commit 9313259

Browse files
committed
MAGETWO-33080: Preferences, Shared Instance creation and Compiled Factory optimization
- fixed codestyles - shared instances array is passed by a reference
1 parent 7a67359 commit 9313259

File tree

10 files changed

+45
-29
lines changed

10 files changed

+45
-29
lines changed

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ObjectManagerTest.php

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,32 @@ function ($className) {
5656
)
5757
);
5858

59+
$sharedInstances = [
60+
'Magento\Framework\App\Cache\Type\Config' => $cache,
61+
'Magento\Framework\App\ObjectManager\ConfigLoader' => $configLoader,
62+
'Magento\Framework\App\ObjectManager\ConfigCache' => $configCache,
63+
'Magento\Framework\Config\ReaderInterface' => $this->getMock(
64+
'Magento\Framework\Config\ReaderInterface'
65+
),
66+
'Magento\Framework\Config\ScopeInterface' => $this->getMock('Magento\Framework\Config\ScopeInterface'),
67+
'Magento\Framework\Config\CacheInterface' => $this->getMock('Magento\Framework\Config\CacheInterface'),
68+
'Magento\Framework\Cache\FrontendInterface' =>
69+
$this->getMock('Magento\Framework\Cache\FrontendInterface'),
70+
'Magento\Framework\App\Resource' => $this->getMockBuilder('Magento\Framework\App\Resource')
71+
->disableOriginalConstructor()
72+
->getMock(),
73+
'Magento\Framework\App\Resource\Config' => $this->getMock(
74+
'Magento\Framework\App\Resource\Config',
75+
[],
76+
[],
77+
'',
78+
false
79+
)
80+
];
5981
$model = new \Magento\TestFramework\ObjectManager(
6082
$factory,
6183
$configMock,
62-
[
63-
'Magento\Framework\App\Cache\Type\Config' => $cache,
64-
'Magento\Framework\App\ObjectManager\ConfigLoader' => $configLoader,
65-
'Magento\Framework\App\ObjectManager\ConfigCache' => $configCache,
66-
'Magento\Framework\Config\ReaderInterface' => $this->getMock(
67-
'Magento\Framework\Config\ReaderInterface'
68-
),
69-
'Magento\Framework\Config\ScopeInterface' => $this->getMock('Magento\Framework\Config\ScopeInterface'),
70-
'Magento\Framework\Config\CacheInterface' => $this->getMock('Magento\Framework\Config\CacheInterface'),
71-
'Magento\Framework\Cache\FrontendInterface' =>
72-
$this->getMock('Magento\Framework\Cache\FrontendInterface'),
73-
'Magento\Framework\App\Resource' => $this->getMockBuilder('Magento\Framework\App\Resource')
74-
->disableOriginalConstructor()
75-
->getMock(),
76-
'Magento\Framework\App\Resource\Config' => $this->getMock(
77-
'Magento\Framework\App\Resource\Config',
78-
[],
79-
[],
80-
'',
81-
false
82-
)
83-
],
84+
$sharedInstances,
8485
$primaryLoaderMock
8586
);
8687

dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Environment/ConfigTesting.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ class ConfigTesting implements ConfigInterface
1818
* @param RelationsInterface $relations
1919
*
2020
* @return void
21+
*
22+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2123
*/
2224
public function setRelations(RelationsInterface $relations)
2325
{
@@ -30,6 +32,7 @@ public function setRelations(RelationsInterface $relations)
3032
* @param ConfigCacheInterface $cache
3133
*
3234
* @return void
35+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3336
*/
3437
public function setCache(ConfigCacheInterface $cache)
3538
{
@@ -41,6 +44,7 @@ public function setCache(ConfigCacheInterface $cache)
4144
*
4245
* @param string $type
4346
* @return array
47+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4448
*/
4549
public function getArguments($type)
4650
{
@@ -52,6 +56,7 @@ public function getArguments($type)
5256
*
5357
* @param string $type
5458
* @return bool
59+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5560
*/
5661
public function isShared($type)
5762
{
@@ -96,6 +101,7 @@ public function getVirtualTypes()
96101
*
97102
* @param array $configuration
98103
* @return void
104+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
99105
*/
100106
public function extend(array $configuration)
101107
{
@@ -117,6 +123,7 @@ public function getPreferences()
117123
*
118124
* @param \Magento\Framework\Interception\ConfigInterface $interceptionConfig
119125
* @return void
126+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
120127
*/
121128
public function setInterceptionConfig(\Magento\Framework\Interception\ConfigInterface $interceptionConfig)
122129
{
@@ -128,6 +135,7 @@ public function setInterceptionConfig(\Magento\Framework\Interception\ConfigInte
128135
*
129136
* @param string $instanceName
130137
* @return string
138+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
131139
*/
132140
public function getOriginalInstanceType($instanceName)
133141
{

dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Factory/Fixture/Compiled/DependencySharedTesting.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
class DependencySharedTesting
99
{
1010
}
11-

dev/tests/unit/testsuite/Magento/Framework/ObjectManager/Factory/Fixture/Compiled/DependencyTesting.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@
88
class DependencyTesting
99
{
1010
}
11-

dev/tools/Magento/Tools/Di/Compiler/Config/Chain/BackslashTrim.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ private function resolveInstancesNames(array $arguments)
4848
* Resolves instances arguments
4949
*
5050
* @param array $argument
51+
* @return array
5152
*/
5253
private function resolveArguments(&$argument)
5354
{

dev/tools/Magento/Tools/Di/Compiler/Config/Chain/PreferencesResolving.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function modify(array $config)
3232
*
3333
* @param array $argument
3434
* @param array $preferences
35+
* @return array
3536
*/
3637
private function resolvePreferences(&$argument, &$preferences)
3738
{

dev/tools/Magento/Tools/Di/Compiler/Config/Reader.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
use Magento\Tools\Di\Compiler\ArgumentsResolverFactory;
1414
use Magento\Tools\Di\Definition\Collection as DefinitionsCollection;
1515

16+
/**
17+
* Class Reader
18+
* @package Magento\Tools\Di\Compiler\Config
19+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
20+
*/
1621
class Reader
1722
{
1823
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function getArguments($type)
8585
*
8686
* @param string $type
8787
* @return bool
88+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
8889
*/
8990
public function isShared($type)
9091
{

lib/internal/Magento/Framework/ObjectManager/Environment/AbstractEnvironment.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public function getMode()
7575
/**
7676
* Decorate factory
7777
*
78-
* @param $arguments
78+
* @param array $arguments
79+
* @return void
7980
*/
8081
protected function decorate($arguments)
8182
{
@@ -90,8 +91,8 @@ protected function decorate($arguments)
9091
/**
9192
* Creates factory
9293
*
93-
* @param $arguments
94-
* @param $factoryClass
94+
* @param array $arguments
95+
* @param string $factoryClass
9596
*
9697
* @return FactoryInterface
9798
*/

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class Compiled extends AbstractEnvironment implements EnvironmentInterface
4444
/**
4545
* Creates factory
4646
*
47-
* @param $arguments
48-
* @param $factoryClass
47+
* @param array $arguments
48+
* @param string $factoryClass
4949
*
5050
* @return FactoryInterface
5151
*/

0 commit comments

Comments
 (0)