Skip to content

Commit 8a6d064

Browse files
committed
#31854: Utilized Magento DI for loading types Laminas DI cannot handle
1 parent 53f2905 commit 8a6d064

18 files changed

+60
-24
lines changed

app/code/Magento/Deploy/Console/InputValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class InputValidator
7272
*/
7373
public function __construct(
7474
Locale $localeValidator,
75-
$versionValidatorFactory = null
75+
?RegexFactory $versionValidatorFactory = null
7676
) {
7777
$this->localeValidator = $localeValidator;
7878
$this->versionValidatorFactory = $versionValidatorFactory ?:

app/code/Magento/Indexer/Console/Command/IndexerReindexCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class IndexerReindexCommand extends AbstractIndexerManageCommand
5858
*/
5959
public function __construct(
6060
ObjectManagerFactory $objectManagerFactory,
61-
$indexerRegistry = null,
62-
$dependencyInfoProvider = null,
63-
$makeSharedValid = null
61+
IndexerRegistry $indexerRegistry = null,
62+
DependencyInfoProvider $dependencyInfoProvider = null,
63+
MakeSharedIndexValid $makeSharedValid = null
6464
) {
6565
$this->indexerRegistry = $indexerRegistry;
6666
$this->dependencyInfoProvider = $dependencyInfoProvider;

lib/internal/Magento/Framework/App/DeploymentConfig/Writer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(
7171
ConfigFilePool $configFilePool,
7272
DeploymentConfig $deploymentConfig,
7373
Writer\FormatterInterface $formatter = null,
74-
$commentParser = null
74+
CommentParser $commentParser = null
7575
) {
7676
$this->reader = $reader;
7777
$this->filesystem = $filesystem;

lib/internal/Magento/Framework/App/MaintenanceMode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class MaintenanceMode
4848
* @param \Magento\Framework\Filesystem $filesystem
4949
* @param Manager|null $eventManager
5050
*/
51-
public function __construct(Filesystem $filesystem, $eventManager = null)
51+
public function __construct(Filesystem $filesystem, ?Manager $eventManager = null)
5252
{
5353
$this->flagDir = $filesystem->getDirectoryWrite(self::FLAG_DIR);
5454
$this->eventManager = $eventManager ?: ObjectManager::getInstance()->get(Manager::class);

lib/internal/Magento/Framework/Setup/FilePermissions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class FilePermissions
7575
public function __construct(
7676
Filesystem $filesystem,
7777
DirectoryList $directoryList,
78-
$state = null
78+
State $state = null
7979
) {
8080
$this->filesystem = $filesystem;
8181
$this->directoryList = $directoryList;

setup/config/application.config.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
use Laminas\Di\InjectorInterface;
7+
use Magento\Setup\Di\MagentoDiFactory;
88
use Magento\Setup\Mvc\Bootstrap\InitParamListener;
99

1010
return [
@@ -23,6 +23,12 @@
2323
'service_manager' => [
2424
'factories' => [
2525
InitParamListener::BOOTSTRAP_PARAM => InitParamListener::class,
26+
\Magento\Framework\App\MaintenanceMode::class => MagentoDiFactory::class,
27+
\Magento\Setup\Model\ConfigGenerator::class => MagentoDiFactory::class,
28+
\Magento\Indexer\Console\Command\IndexerReindexCommand::class => MagentoDiFactory::class,
29+
\Symfony\Component\Console\Helper\TableFactory::class => MagentoDiFactory::class,
30+
\Magento\Deploy\Console\InputValidator::class => MagentoDiFactory::class,
31+
\Magento\Framework\App\State::class => MagentoDiFactory::class,
2632
],
2733
]
2834
];

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,17 @@ class BackupCommand extends AbstractSetupCommand
6060
* Constructor
6161
*
6262
* @param ObjectManagerProvider $objectManagerProvider
63+
* @param MaintenanceMode $maintenanceMode deprecated, use $maintenanceModeEnabler instead
6364
* @param DeploymentConfig $deploymentConfig
6465
* @param MaintenanceModeEnabler $maintenanceModeEnabler
6566
*
6667
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6768
*/
6869
public function __construct(
6970
ObjectManagerProvider $objectManagerProvider,
71+
MaintenanceMode $maintenanceMode,
7072
DeploymentConfig $deploymentConfig,
71-
$maintenanceModeEnabler = null
73+
MaintenanceModeEnabler $maintenanceModeEnabler = null
7274
) {
7375
$this->objectManager = $objectManagerProvider->get();
7476
$this->backupRollbackFactory = $this->objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public function __construct(
9999
Filesystem $filesystem,
100100
DriverInterface $fileDriver,
101101
ComponentRegistrar $componentRegistrar,
102-
$file = null
102+
File $file = null
103103
) {
104104
$this->deploymentConfig = $deploymentConfig;
105105
$this->directoryList = $directoryList;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class InfoBackupsListCommand extends Command
4848
public function __construct(
4949
DirectoryList $directoryList,
5050
File $file,
51-
$tableHelperFactory = null
51+
TableFactory $tableHelperFactory = null
5252
) {
5353
$this->directoryList = $directoryList;
5454
$this->file = $file;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class InfoCurrencyListCommand extends Command
3434
* @param Lists $lists
3535
* @param TableFactory $tableHelperFactory
3636
*/
37-
public function __construct(Lists $lists, $tableHelperFactory = null)
37+
public function __construct(Lists $lists, TableFactory $tableHelperFactory = null)
3838
{
3939
$this->lists = $lists;
4040
$this->tableHelperFactory = $tableHelperFactory ?: ObjectManager::getInstance()->create(TableFactory::class);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class InfoLanguageListCommand extends Command
3434
* @param Lists $lists
3535
* @param TableFactory $tableHelperFactory
3636
*/
37-
public function __construct(Lists $lists, $tableHelperFactory = null)
37+
public function __construct(Lists $lists, TableFactory $tableHelperFactory = null)
3838
{
3939
$this->lists = $lists;
4040
$this->tableHelperFactory = $tableHelperFactory ?: ObjectManager::getInstance()->create(TableFactory::class);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class InfoTimezoneListCommand extends Command
3434
* @param Lists $lists
3535
* @param TableFactory $tableHelperFactory
3636
*/
37-
public function __construct(Lists $lists, $tableHelperFactory = null)
37+
public function __construct(Lists $lists, TableFactory $tableHelperFactory = null)
3838
{
3939
$this->lists = $lists;
4040
$this->tableHelperFactory = $tableHelperFactory ?: ObjectManager::getInstance()->create(TableFactory::class);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public function __construct(
139139
UninstallCollector $collector,
140140
ModuleUninstaller $moduleUninstaller,
141141
ModuleRegistryUninstaller $moduleRegistryUninstaller,
142-
$maintenanceModeEnabler = null
142+
MaintenanceModeEnabler $maintenanceModeEnabler = null
143143
) {
144144
parent::__construct($objectManagerProvider);
145145
$this->composer = $composer;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@ class RollbackCommand extends AbstractSetupCommand
5959
* Constructor
6060
*
6161
* @param ObjectManagerProvider $objectManagerProvider
62+
* @param MaintenanceMode $maintenanceMode deprecated, use $maintenanceModeEnabler instead
6263
* @param DeploymentConfig $deploymentConfig
6364
* @param MaintenanceModeEnabler $maintenanceModeEnabler
6465
*
6566
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6667
*/
6768
public function __construct(
6869
ObjectManagerProvider $objectManagerProvider,
70+
MaintenanceMode $maintenanceMode,
6971
DeploymentConfig $deploymentConfig,
70-
$maintenanceModeEnabler = null
72+
MaintenanceModeEnabler $maintenanceModeEnabler = null
7173
) {
7274
$this->objectManager = $objectManagerProvider->get();
7375
$this->backupRollbackFactory = $this->objectManager->get(\Magento\Framework\Setup\BackupRollbackFactory::class);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ class UpgradeCommand extends AbstractSetupCommand
7070
public function __construct(
7171
InstallerFactory $installerFactory,
7272
SearchConfigFactory $searchConfigFactory,
73-
$deploymentConfig = null,
74-
$appState = null,
75-
$cache = null
73+
DeploymentConfig $deploymentConfig = null,
74+
AppState $appState = null,
75+
CacheInterface $cache = null
7676
) {
7777
$this->installerFactory = $installerFactory;
7878
$this->searchConfigFactory = $searchConfigFactory;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Setup\Di;
9+
10+
use Interop\Container\ContainerInterface;
11+
use Laminas\ServiceManager\Factory\FactoryInterface;
12+
use Magento\Framework\App\ObjectManager;
13+
14+
/**
15+
* Instantiates the type via Magento object manager
16+
*/
17+
class MagentoDiFactory implements FactoryInterface
18+
{
19+
/**
20+
* @inheritdoc
21+
*/
22+
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
23+
{
24+
return ObjectManager::getInstance()->get($requestedName);
25+
}
26+
}

setup/src/Magento/Setup/Model/ConfigGenerator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ class ConfigGenerator
8080
public function __construct(
8181
Random $random,
8282
DeploymentConfig $deploymentConfig,
83-
$configDataFactory = null,
84-
$cryptKeyGenerator = null,
85-
$driverOptions = null
83+
ConfigDataFactory $configDataFactory = null,
84+
CryptKeyGeneratorInterface $cryptKeyGenerator = null,
85+
DriverOptions $driverOptions = null
8686
) {
8787
$this->random = $random;
8888
$this->deploymentConfig = $deploymentConfig;

setup/src/Magento/Setup/Model/ConfigOptionsList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ class ConfigOptionsList implements ConfigOptionsListInterface
7272
public function __construct(
7373
ConfigGenerator $configGenerator,
7474
DbValidator $dbValidator,
75-
$encryptionKeyValidator = null,
76-
$driverOptions = null
75+
KeyValidator $encryptionKeyValidator = null,
76+
DriverOptions $driverOptions = null
7777
) {
7878
$this->configGenerator = $configGenerator;
7979
$this->dbValidator = $dbValidator;

0 commit comments

Comments
 (0)