Skip to content

Commit 8a4bbf9

Browse files
committed
Merge remote-tracking branch '33161/di-compile-tests-regex' into novcommpr-2
2 parents 52cee22 + 59e9ddd commit 8a4bbf9

File tree

10 files changed

+85
-42
lines changed

10 files changed

+85
-42
lines changed

app/code/Magento/Catalog/etc/di.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2013 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
@@ -73,7 +73,6 @@
7373
<preference for="Magento\Catalog\Model\Indexer\Product\Price\UpdateIndexInterface" type="Magento\Catalog\Model\Indexer\Product\Price\InvalidateIndex" />
7474
<preference for="Magento\Catalog\Model\Product\Gallery\ImagesConfigFactoryInterface" type="Magento\Catalog\Model\Product\Gallery\ImagesConfigFactory" />
7575
<preference for="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface" type="Magento\Catalog\Model\Product\Configuration\Item\ItemResolverComposite" />
76-
<preference for="Magento\Catalog\Api\Data\MassActionInterface" type="Magento\Catalog\Model\MassAction" />
7776
<preference for="Magento\Catalog\Model\ProductLink\Data\ListCriteriaInterface" type="Magento\Catalog\Model\ProductLink\Data\ListCriteria" />
7877
<preference for="Magento\Catalog\Api\CategoryListDeleteBySkuInterface" type="Magento\Catalog\Model\CategoryLinkRepository"/>
7978
<preference for="Magento\Theme\CustomerData\MessagesProviderInterface" type="Magento\Catalog\Model\Theme\CustomerData\MessagesProvider"/>

app/code/Magento/RemoteStorage/etc/di.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2020 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
99
<preference for="Magento\RemoteStorage\Driver\Adapter\Cache\CacheInterface" type="Magento\RemoteStorage\Driver\Adapter\Cache\Generic"/>
1010
<preference for="Magento\RemoteStorage\Driver\Adapter\CachedAdapterInterface" type="Magento\RemoteStorage\Driver\Adapter\CachedAdapter"/>
1111
<preference for="Magento\RemoteStorage\Driver\Adapter\MetadataProviderInterface" type="Magento\RemoteStorage\Driver\Adapter\MetadataProvider"/>
12-
<preference for="Magento\RemoteStorage\Driver\Adapter\MetadataProviderFactoryInterface" type="Magento\RemoteStorage\Driver\Adapter\MetadataProviderFactory"/>
1312
<preference for="Magento\Framework\Filesystem\DriverPool" type="Magento\RemoteStorage\Driver\DriverPool"/>
1413
<preference for="Magento\Framework\File\Uploader" type="Magento\RemoteStorage\Model\File\Uploader"/>
1514
<virtualType name="remoteWriteFactory" type="Magento\Framework\Filesystem\Directory\WriteFactory">

app/etc/di.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0"?>
22
<!--
33
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
4+
* Copyright 2013 Adobe
5+
* All Rights Reserved.
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
@@ -82,7 +82,6 @@
8282
<preference for="Magento\Framework\Json\DecoderInterface" type="Magento\Framework\Json\Decoder" />
8383
<preference for="Magento\Framework\Message\ManagerInterface" type="Magento\Framework\Message\Manager" />
8484
<preference for="Magento\Framework\App\Config\ValueInterface" type="Magento\Framework\App\Config\Value" />
85-
<preference for="Magento\Framework\Interception\ChainInterface" type="Magento\Framework\Interception\Chain\Chain" />
8685
<preference for="Magento\Framework\Module\Output\ConfigInterface" type="Magento\Framework\Module\Output\Config" />
8786
<preference for="Magento\Framework\View\Design\Theme\CustomizationInterface" type="Magento\Framework\View\Design\Theme\Customization" />
8887
<preference for="Magento\Framework\View\Asset\ConfigInterface" type="Magento\Framework\View\Asset\Config" />

dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_classes.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22
/**
3+
* Copyright 2011 Adobe
4+
* All Rights Reserved.
5+
*
36
* Obsolete classes
47
*
58
* Format: array(<class_name>[, <replacement>])
69
*
710
* @codingStandardsIgnoreFile
8-
*
9-
* Copyright © Magento, Inc. All rights reserved.
10-
* See COPYING.txt for license details.
1111
*/
1212
return [
1313
['Mage_Admin_Helper_Data', 'Magento\Backend\Helper\Data'],
@@ -2845,7 +2845,7 @@
28452845
['Magento\Framework\Stdlib\CookieManager', 'Magento\Framework\Stdlib\CookieManagerInterface'],
28462846
['Magento\Framework\Interception\PluginList', 'Magento\Framework\Interception\PluginListInterface'],
28472847
['Magento\Framework\Interception\Config', 'Magento\Framework\Interception\ConfigInterface'],
2848-
['Magento\Framework\Interception\Chain', 'Magento\Framework\Interception\ChainInterface'],
2848+
['Magento\Framework\Interception\Chain'],
28492849
['Magento\Framework\Interception\Definition', 'Magento\Framework\Interception\DefinitionInterface'],
28502850
['Magento\Framework\ObjectManager\Factory', 'Magento\Framework\ObjectManager\FactoryInterface'],
28512851
['Magento\Framework\ObjectManager\Config', 'Magento\Framework\ObjectManager\ConfigInterface'],

setup/src/Magento/Setup/Console/Command/DiCompileCommand.php

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
6+
67
namespace Magento\Setup\Console\Command;
78

89
use Magento\Framework\App\ObjectManager;
@@ -30,8 +31,7 @@
3031
*/
3132
class DiCompileCommand extends Command
3233
{
33-
/** Command name */
34-
const NAME = 'setup:di:compile';
34+
public const NAME = 'setup:di:compile';
3535

3636
/**
3737
* @var \Magento\Framework\App\DeploymentConfig
@@ -79,8 +79,6 @@ class DiCompileCommand extends Command
7979
private $file;
8080

8181
/**
82-
* Constructor
83-
*
8482
* @param DeploymentConfig $deploymentConfig
8583
* @param DirectoryList $directoryList
8684
* @param Manager $taskManager
@@ -89,6 +87,7 @@ class DiCompileCommand extends Command
8987
* @param DriverInterface $fileDriver
9088
* @param \Magento\Framework\Component\ComponentRegistrar $componentRegistrar
9189
* @param File|null $file
90+
*
9291
* @throws \Magento\Setup\Exception
9392
*/
9493
public function __construct(
@@ -151,6 +150,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
151150
foreach ($errors as $line) {
152151
$output->writeln($line);
153152
}
153+
154154
// we must have an exit code higher than zero to indicate something was wrong
155155
return Cli::RETURN_FAILURE;
156156
}
@@ -224,13 +224,15 @@ function (OperationInterface $operation) use ($progressBar) {
224224
// we must have an exit code higher than zero to indicate something was wrong
225225
return Cli::RETURN_FAILURE;
226226
}
227+
227228
return Cli::RETURN_SUCCESS;
228229
}
229230

230231
/**
231232
* Build list of module path regexps which should be excluded from compilation
232233
*
233234
* @param string[] $modulePaths
235+
*
234236
* @return string[]
235237
*/
236238
private function getExcludedModulePaths(array $modulePaths)
@@ -251,6 +253,7 @@ private function getExcludedModulePaths(array $modulePaths)
251253
$vendorPathsRegExps[] = $vendorDir
252254
. '/(?:' . join('|', $vendorModules) . ')';
253255
}
256+
254257
$basePathsRegExps[] = preg_quote($basePath, '#')
255258
. '/(?:' . join('|', $vendorPathsRegExps) . ')';
256259
}
@@ -266,6 +269,7 @@ private function getExcludedModulePaths(array $modulePaths)
266269
* Build list of library path regexps which should be excluded from compilation
267270
*
268271
* @param string[] $libraryPaths
272+
*
269273
* @return string[]
270274
*/
271275
private function getExcludedLibraryPaths(array $libraryPaths)
@@ -288,6 +292,7 @@ function ($libraryPath) {
288292
* Get excluded setup application paths
289293
*
290294
* @param string $setupPath
295+
*
291296
* @return string[]
292297
*/
293298
private function getExcludedSetupPaths($setupPath)
@@ -301,6 +306,7 @@ private function getExcludedSetupPaths($setupPath)
301306
* Delete directories by their code from "var" directory
302307
*
303308
* @param array $directoryCodeList
309+
*
304310
* @return void
305311
*/
306312
private function cleanupFilesystem($directoryCodeList)
@@ -314,6 +320,7 @@ private function cleanupFilesystem($directoryCodeList)
314320
* Configure Object Manager
315321
*
316322
* @param OutputInterface $output
323+
*
317324
* @return void
318325
*/
319326
private function configureObjectManager(OutputInterface $output)
@@ -365,6 +372,7 @@ private function configureObjectManager(OutputInterface $output)
365372
* Returns operations configuration
366373
*
367374
* @param array $compiledPathsList
375+
*
368376
* @return array
369377
*/
370378
private function getOperationsConfiguration(
@@ -399,6 +407,7 @@ private function getOperationsConfiguration(
399407
OperationFactory::AREA_CONFIG_GENERATOR => [
400408
$compiledPathsList['application'],
401409
$compiledPathsList['library'],
410+
$compiledPathsList['setup'],
402411
$compiledPathsList['generated_helpers'],
403412
],
404413
OperationFactory::INTERCEPTION_CACHE => [

setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
6+
67
namespace Magento\Setup\Module\Di\Code\Reader\Decorator;
78

89
use Magento\Setup\Module\Di\Code\Reader\ClassesScanner;
910
use Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator;
1011
use Magento\Framework\Exception\FileSystemException;
1112

12-
/**
13-
* Class Area
14-
*
15-
* @package Magento\Setup\Module\Di\Code\Reader\Decorator
16-
*/
1713
class Area implements \Magento\Setup\Module\Di\Code\Reader\ClassesScannerInterface
1814
{
1915
/**
@@ -50,7 +46,7 @@ public function getList($path)
5046
{
5147
$classes = [];
5248
foreach ($this->classesScanner->getList($path) as $className) {
53-
$classes[$className] = $this->classReaderDecorator->getConstructor($className);
49+
$classes[$className] = (array) $this->classReaderDecorator->getConstructor($className);
5450
}
5551

5652
return $classes;

setup/src/Magento/Setup/Module/Di/Compiler/ArgumentsResolver.php

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22
/**
3-
*
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
65
*/
76

87
namespace Magento\Setup\Module\Di\Compiler;
@@ -193,7 +192,11 @@ private function getConfiguredArguments($instanceType)
193192
$configuredArguments = $this->diContainerConfig->getArguments($instanceType);
194193
return array_map(
195194
function ($type) {
196-
if (isset($type['instance'])) {
195+
if (is_object($type)) {
196+
return;
197+
}
198+
199+
if (is_array($type) && isset($type['instance'])) {
197200
$type['instance'] = ltrim($type['instance'], '\\');
198201
}
199202

setup/src/Magento/Setup/Module/Di/Compiler/Config/Reader.php

+40-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Setup\Module\Di\Compiler\Config;
88

99
use Magento\Framework\App;
10+
use Magento\Framework\Exception\LocalizedException;
1011
use Magento\Framework\ObjectManager\ConfigInterface;
12+
use Magento\Framework\Phrase;
1113
use Magento\Setup\Module\Di\Code\Reader\ClassReaderDecorator;
1214
use Magento\Setup\Module\Di\Code\Reader\Type;
1315
use Magento\Setup\Module\Di\Compiler\ArgumentsResolverFactory;
@@ -91,6 +93,42 @@ public function generateCachePerScope(
9193
foreach ($definitionsCollection->getInstancesNamesList() as $instanceName) {
9294
$preference = $areaConfig->getPreference($instanceName);
9395
if ($instanceName !== $preference) {
96+
if (array_key_exists($preference, $areaConfig->getVirtualTypes())) {
97+
// Special handling is required for virtual types.
98+
$config['preferences'][$instanceName] = $preference;
99+
continue;
100+
}
101+
102+
if (!class_exists($preference)) {
103+
throw new LocalizedException(new Phrase(
104+
'Preference declared for "%instanceName" as "%preference", but the latter does not exist.',
105+
[
106+
'instanceName' => $instanceName,
107+
'preference' => $preference,
108+
]
109+
));
110+
}
111+
112+
// Classes defined by PHP extensions are allowed.
113+
$reflection = new \ReflectionClass($preference);
114+
if ($reflection->getExtension()) {
115+
$config['preferences'][$instanceName] = $preference;
116+
continue;
117+
}
118+
119+
if (!$definitionsCollection->hasInstance($preference)) {
120+
// See 'excludePatterns' in Magento\Setup\Module\Di\Code\Reader\ClassesScanner,
121+
// populated via Magento\Setup\Console\Command\DiCompileCommand
122+
throw new LocalizedException(new Phrase(
123+
'Preference declared for "%instanceName" as "%preference", but the latter'
124+
. ' has not been included in dependency injection compilation.',
125+
[
126+
'instanceName' => $instanceName,
127+
'preference' => $preference,
128+
]
129+
));
130+
}
131+
94132
$config['preferences'][$instanceName] = $preference;
95133
}
96134
}

setup/src/Magento/Setup/Module/Di/Definition/Collection.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66

77
namespace Magento\Setup\Module\Di\Definition;
@@ -91,6 +91,6 @@ public function getInstancesNamesList()
9191
*/
9292
public function hasInstance($instanceName)
9393
{
94-
return isset($this->definitions[$instanceName]);
94+
return array_key_exists($instanceName, $this->definitions);
9595
}
9696
}

setup/src/Magento/Setup/Test/Unit/Module/Di/Compiler/Config/ReaderTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
3-
* Copyright © Magento, Inc. All rights reserved.
4-
* See COPYING.txt for license details.
3+
* Copyright 2015 Adobe
4+
* All Rights Reserved.
55
*/
66
declare(strict_types=1);
77

@@ -174,8 +174,8 @@ private function getVirtualTypes()
174174
private function getPreferences()
175175
{
176176
return [
177-
'Interface1' => 'ConcreteType1',
178-
'ThirdPartyInterface' => 'ConcreteType2'
177+
'Interface1' => 'DateTime',
178+
'ThirdPartyInterface' => 'DateTimeZone',
179179
];
180180
}
181181

@@ -187,8 +187,8 @@ private function getPreferencesMap()
187187
return [
188188
['ConcreteType1', 'ConcreteType1'],
189189
['ConcreteType2', 'ConcreteType2'],
190-
['Interface1', 'ConcreteType1'],
191-
['ThirdPartyInterface', 'ConcreteType2']
190+
['Interface1', 'DateTime'],
191+
['ThirdPartyInterface', 'DateTimeZone'],
192192
];
193193
}
194194

0 commit comments

Comments
 (0)