Skip to content
Snippets Groups Projects
Commit 68d32b2e authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3321474 by phenaproxima, tedbow: Adopt PHP 8.1-only capabilities such...

Issue #3321474 by phenaproxima, tedbow: Adopt PHP 8.1-only capabilities such as constructor property promotion + drop BC layers
parent 4e350a4c
No related branches found
No related tags found
No related merge requests found
Showing
with 33 additions and 1027 deletions
......@@ -33,36 +33,3 @@ automatic_updates.cron.post_apply:
_controller: 'automatic_updates.cron_updater:handlePostApply'
requirements:
_access_system_cron: 'TRUE'
# These routes are deprecated and will be removed in the next major version of
# Automatic Updates. They redirect to existing routes from the core Update
# module, which are overridden by Automatic Updates.
# @see \Drupal\automatic_updates\Routing\RouteSubscriber::alterRoutes()
automatic_updates.report_update:
path: '/admin/reports/updates/automatic-update'
defaults:
_controller: '\Drupal\automatic_updates\Controller\UpdateController::redirectDeprecatedRoute'
requirements:
_access: 'TRUE'
automatic_updates.module_update:
path: '/admin/modules/automatic-update'
defaults:
_controller: '\Drupal\automatic_updates\Controller\UpdateController::redirectDeprecatedRoute'
requirements:
_access: 'TRUE'
automatic_updates.theme_update:
path: '/admin/theme/automatic-update'
defaults:
_controller: '\Drupal\automatic_updates\Controller\UpdateController::redirectDeprecatedRoute'
requirements:
_access: 'TRUE'
automatic_updates.update_readiness:
path: '/admin/automatic_updates/readiness'
defaults:
_controller: '\Drupal\automatic_updates\Controller\StatusCheckController::runReadiness'
_title: 'Update readiness checking'
requirements:
_permission: 'administer software updates'
options:
_maintenance_access: TRUE
_automatic_updates_status_messages: skip
......@@ -20,15 +20,9 @@ services:
- '@config.factory'
- '@plugin.manager.mail'
- '@language_manager'
automatic_updates.readiness_validation_manager:
class: Drupal\automatic_updates\Validation\ReadinessValidationManager
arguments:
- '@automatic_updates.status_checker'
deprecated: The "%service_id%" service is deprecated in automatic_updates:8.x-2.5 and is removed from automatic_updates:3.0.0. Use the automatic_updates.status_checker service instead. See https://www.drupal.org/node/3316086.
automatic_updates.updater:
class: Drupal\automatic_updates\Updater
arguments:
- '@config.factory'
- '@package_manager.path_locator'
- '@package_manager.beginner'
- '@package_manager.stager'
......@@ -45,7 +39,6 @@ services:
class: Drupal\automatic_updates\CronUpdater
arguments:
- '@automatic_updates.release_chooser'
- '@logger.factory'
- '@plugin.manager.mail'
- '@automatic_updates.status_check_mailer'
- '@state'
......@@ -64,14 +57,10 @@ services:
- ['setLogger', ['@logger.channel.automatic_updates']]
automatic_updates.requested_update_validator:
class: Drupal\automatic_updates\Validator\RequestedUpdateValidator
arguments:
- '@string_translation'
tags:
- { name: event_subscriber }
automatic_updates.staged_projects_validator:
class: Drupal\automatic_updates\Validator\StagedProjectsValidator
arguments:
- '@string_translation'
tags:
- { name: event_subscriber }
automatic_updates.release_chooser:
......@@ -85,7 +74,6 @@ services:
- '@module_handler'
- '@state'
- '@datetime.time'
- '@string_translation'
- '@automatic_updates.cron_updater'
- '@lock'
tags:
......@@ -94,7 +82,6 @@ services:
class: Drupal\automatic_updates\Validator\StagedDatabaseUpdateValidator
arguments:
- '@package_manager.validator.staged_database_updates'
- '@string_translation'
tags:
- { name: event_subscriber }
automatic_updates.validator.version_policy:
......
......@@ -2,7 +2,6 @@ services:
automatic_updates_extensions.updater:
class: Drupal\automatic_updates_extensions\ExtensionUpdater
arguments:
- '@config.factory'
- '@package_manager.path_locator'
- '@package_manager.beginner'
- '@package_manager.stager'
......
......@@ -5,24 +5,12 @@ declare(strict_types = 1);
namespace Drupal\automatic_updates_extensions;
use Drupal\automatic_updates\Exception\UpdateException;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TempStore\SharedTempStoreFactory;
use Drupal\package_manager\Exception\ApplyFailedException;
use Drupal\package_manager\FailureMarker;
use Drupal\package_manager\LegacyVersionUtility;
use Drupal\package_manager\Event\StageEvent;
use Drupal\package_manager\Exception\StageValidationException;
use Drupal\package_manager\PathLocator;
use Drupal\package_manager\Stage;
use Drupal\package_manager\UnusedConfigFactory;
use PhpTuf\ComposerStager\Domain\Core\Beginner\BeginnerInterface;
use PhpTuf\ComposerStager\Domain\Core\Committer\CommitterInterface;
use PhpTuf\ComposerStager\Domain\Core\Stager\StagerInterface;
use PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
/**
* Defines a service to perform updates for modules and themes.
......@@ -33,15 +21,6 @@ use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
*/
class ExtensionUpdater extends Stage {
/**
* {@inheritdoc}
*
* @todo Remove this in https://www.drupal.org/i/3303167
*/
public function __construct(ConfigFactoryInterface $config_factory, PathLocator $path_locator, BeginnerInterface $beginner, StagerInterface $stager, CommitterInterface $committer, FileSystemInterface $file_system, EventDispatcherInterface $event_dispatcher, SharedTempStoreFactory $temp_store_factory, TimeInterface $time, PathFactoryInterface $path_factory = NULL, FailureMarker $failure_marker = NULL) {
parent::__construct(new UnusedConfigFactory(), $path_locator, $beginner, $stager, $committer, $file_system, $event_dispatcher, $temp_store_factory, $time, $path_factory, $failure_marker);
}
/**
* Begins the update.
*
......
......@@ -120,7 +120,7 @@ final class UpdateReady extends UpdateFormBase {
try {
$this->updater->claim($stage_id);
}
catch (StageOwnershipException $e) {
catch (StageOwnershipException) {
$this->messenger()->addError($this->t('Cannot continue the update because another Composer operation is currently in progress.'));
return $form;
}
......
......@@ -7,7 +7,6 @@ namespace Drupal\Tests\automatic_updates_extensions\Kernel;
use Drupal\automatic_updates\Exception\UpdateException;
use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\package_manager\UnusedConfigFactory;
use Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase;
use Drupal\Tests\package_manager\Kernel\TestStageTrait;
use Drupal\Tests\package_manager\Kernel\TestStageValidationException;
......@@ -112,8 +111,6 @@ abstract class AutomaticUpdatesExtensionsKernelTestBase extends AutomaticUpdates
*/
protected function createExtensionUpdater(): TestExtensionUpdater {
return new TestExtensionUpdater(
// @todo Remove this in https://www.drupal.org/i/3303167
new UnusedConfigFactory(),
$this->container->get('package_manager.path_locator'),
$this->container->get('package_manager.beginner'),
$this->container->get('package_manager.stager'),
......
......@@ -14,12 +14,12 @@ services:
public: false
Drupal\package_manager\ExecutableFinder:
arguments:
$config_factory: '@config.factory'
$configFactory: '@config.factory'
autowire: true
public: false
Drupal\package_manager\FileSyncerFactory:
arguments:
$config_factory: '@config.factory'
$configFactory: '@config.factory'
autowire: true
public: false
PhpTuf\ComposerStager\Infrastructure\Service\Finder\ExecutableFinderInterface:
......@@ -70,7 +70,6 @@ services:
arguments:
- '@PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface'
- '@module_handler'
- '@string_translation'
- '@PhpTuf\ComposerStager\Domain\Service\Precondition\ComposerIsAvailableInterface'
- '@PhpTuf\ComposerStager\Infrastructure\Factory\Path\PathFactoryInterface'
tags:
......@@ -79,7 +78,6 @@ services:
class: Drupal\package_manager\Validator\DiskSpaceValidator
arguments:
- '@package_manager.path_locator'
- '@string_translation'
tags:
- { name: event_subscriber }
package_manager.validator.pending_updates:
......@@ -87,7 +85,6 @@ services:
arguments:
- '%app.root%'
- '@update.post_update_registry'
- '@string_translation'
tags:
- { name: event_subscriber }
package_manager.validator.lock_file:
......@@ -95,20 +92,17 @@ services:
arguments:
- '@state'
- '@package_manager.path_locator'
- '@string_translation'
tags:
- { name: event_subscriber }
package_manager.validator.file_system:
class: Drupal\package_manager\Validator\WritableFileSystemValidator
arguments:
- '@package_manager.path_locator'
- '@string_translation'
tags:
- { name: event_subscriber }
package_manager.validator.composer_settings:
class: Drupal\package_manager\Validator\ComposerSettingsValidator
arguments:
- '@string_translation'
- '@package_manager.composer_inspector'
- '@package_manager.path_locator'
tags:
......@@ -124,7 +118,6 @@ services:
class: Drupal\package_manager\Validator\MultisiteValidator
arguments:
- '@package_manager.path_locator'
- '@string_translation'
tags:
- { name: event_subscriber }
package_manager.validator.symlink:
......@@ -160,7 +153,6 @@ services:
class: Drupal\package_manager\Validator\ComposerJsonExistsValidator
arguments:
- '@package_manager.path_locator'
- '@string_translation'
tags:
- { name: event_subscriber }
package_manager.test_site_excluder:
......@@ -179,7 +171,7 @@ services:
class: Drupal\package_manager\PathExcluder\SiteFilesExcluder
arguments:
$path_locator: '@package_manager.path_locator'
$stream_wrapper_manager: '@stream_wrapper_manager'
$streamWrapperManager: '@stream_wrapper_manager'
tags:
- { name: event_subscriber }
autowire: true
......@@ -226,8 +218,6 @@ services:
lazy: true
package_manager.validator.settings:
class: Drupal\package_manager\Validator\SettingsValidator
arguments:
- '@string_translation'
tags:
- { name: event_subscriber }
package_manager.validator.composer_plugins:
......
......@@ -18,13 +18,6 @@ use PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface;
*/
final class ComposerInspector {
/**
* The Composer runner service from Composer Stager.
*
* @var \PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface
*/
protected ComposerRunnerInterface $runner;
/**
* The JSON process output callback.
*
......@@ -38,8 +31,7 @@ final class ComposerInspector {
* @param \PhpTuf\ComposerStager\Domain\Service\ProcessRunner\ComposerRunnerInterface $runner
* The Composer runner service from Composer Stager.
*/
public function __construct(ComposerRunnerInterface $runner) {
$this->runner = $runner;
public function __construct(private ComposerRunnerInterface $runner) {
$this->jsonCallback = new JsonProcessOutputCallback();
}
......
......@@ -334,7 +334,7 @@ class ComposerUtility {
try {
$version_parser->parseConstraints($version);
}
catch (\UnexpectedValueException $e) {
catch (\UnexpectedValueException) {
return FALSE;
}
......
......@@ -16,30 +16,6 @@ trait ExcludedPathsTrait {
*/
protected $excludedPaths = [];
/**
* Adds a path to exclude from the current operation.
*
* If called on an instance of \Drupal\package_manager\Event\PreCreateEvent,
* excluded paths will not be copied into the stage directory when the stage
* is created. If called on an instance of
* \Drupal\package_manager\Event\PreApplyEvent, excluded paths will not be
* deleted from the active directory when staged changes are applied. So,
* to ensure that a given path is never staged, but also preserved in the
* active directory, it should be passed to this method on both PreCreateEvent
* and PreApplyEvent. See
* \Drupal\package_manager\EventSubscriber\ExcludedPathsSubscriber for an
* example.
*
* @param string $path
* The path to exclude, relative to the project root.
*
* @see \Drupal\package_manager\PathExcluder\SiteConfigurationExcluder
*/
public function excludePath(string $path): void {
@trigger_error(__METHOD__ . '() is deprecated in automatic_updates:8.x-2.5 and removed in automatic_updates:3.0.0. Use ' . CollectIgnoredPathsEvent::class . ' instead. See https://www.drupal.org/node/3317862.', E_USER_DEPRECATED);
$this->excludedPaths[] = $path;
}
/**
* Returns the paths to exclude from the current operation.
*
......
......@@ -19,13 +19,12 @@ class PreApplyEvent extends PreOperationStageEvent {
* @param \Drupal\package_manager\Stage $stage
* The stage which fired this event.
* @param string[] $ignored_paths
* The list of ignored paths.
* The list of ignored paths. These will not be copied from the stage
* directory to the active directory, nor be deleted from the active
* directory if they exist, when the stage directory is copied back into
* the active directory.
*/
public function __construct(Stage $stage, array $ignored_paths = NULL) {
if ($ignored_paths === NULL) {
@trigger_error('Calling ' . __METHOD__ . '() without the $ignored_paths argument is deprecated in automatic_updates:8.x-2.5 and will be removed in automatic_updates:3.0.0. See https://www.drupal.org/node/3317862.', E_USER_DEPRECATED);
$ignored_paths = [];
}
public function __construct(Stage $stage, array $ignored_paths) {
parent::__construct($stage);
$this->excludedPaths = $ignored_paths;
}
......
......@@ -19,13 +19,10 @@ class PreCreateEvent extends PreOperationStageEvent {
* @param \Drupal\package_manager\Stage $stage
* The stage which fired this event.
* @param string[] $ignored_paths
* The list of ignored paths.
* The list of ignored paths. These will not be copied into the stage
* directory when it is created.
*/
public function __construct(Stage $stage, array $ignored_paths = NULL) {
if ($ignored_paths === NULL) {
@trigger_error('Calling ' . __METHOD__ . '() without the $ignored_paths argument is deprecated in automatic_updates:8.x-2.5 and will be removed in automatic_updates:3.0.0. See https://www.drupal.org/node/3317862.', E_USER_DEPRECATED);
$ignored_paths = [];
}
public function __construct(Stage $stage, array $ignored_paths) {
parent::__construct($stage);
$this->excludedPaths = $ignored_paths;
}
......
......@@ -12,21 +12,13 @@ use Symfony\Contracts\EventDispatcher\Event;
*/
abstract class StageEvent extends Event {
/**
* The stage which fired this event.
*
* @var \Drupal\package_manager\Stage
*/
protected $stage;
/**
* Constructs a StageEvent object.
*
* @param \Drupal\package_manager\Stage $stage
* The stage which fired this event.
*/
public function __construct(Stage $stage) {
$this->stage = $stage;
public function __construct(protected readonly Stage $stage) {
}
/**
......
......@@ -26,11 +26,7 @@ class StatusCheckEvent extends PreOperationStageEvent {
* @param string[] $ignored_paths
* The list of ignored paths.
*/
public function __construct(Stage $stage, array $ignored_paths = NULL) {
if ($ignored_paths === NULL) {
@trigger_error('Calling ' . __METHOD__ . '() without the $ignored_paths argument is deprecated in automatic_updates:8.x-2.5 and will be removed in automatic_updates:3.0.0. See https://www.drupal.org/node/3317862.', E_USER_DEPRECATED);
$ignored_paths = [];
}
public function __construct(Stage $stage, array $ignored_paths) {
parent::__construct($stage);
$this->excludedPaths = $ignored_paths;
}
......
......@@ -19,20 +19,12 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class UpdateDataSubscriber implements EventSubscriberInterface {
/**
* The update manager service.
* Constructs an UpdateDataSubscriber object.
*
* @var \Drupal\update\UpdateManagerInterface
*/
protected $updateManager;
/**
* Constructs an UpdateRefreshSubscriber object.
*
* @param \Drupal\update\UpdateManagerInterface $update_manager
* @param \Drupal\update\UpdateManagerInterface $updateManager
* The update manager service.
*/
public function __construct(UpdateManagerInterface $update_manager) {
$this->updateManager = $update_manager;
public function __construct(protected UpdateManagerInterface $updateManager) {
}
/**
......
......@@ -26,24 +26,16 @@ final class ExecutableFinder implements ExecutableFinderInterface {
*/
private $decorated;
/**
* The config factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
private $configFactory;
/**
* Constructs an ExecutableFinder object.
*
* @param \Symfony\Component\Process\ExecutableFinder $symfony_executable_finder
* The Symfony executable finder.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config factory service.
*/
public function __construct(SymfonyExecutableFinder $symfony_executable_finder, ConfigFactoryInterface $config_factory) {
public function __construct(SymfonyExecutableFinder $symfony_executable_finder, private ConfigFactoryInterface $configFactory) {
$this->decorated = new StagerExecutableFinder($symfony_executable_finder);
$this->configFactory = $config_factory;
}
/**
......
......@@ -19,21 +19,13 @@ use Drupal\package_manager\Exception\ApplyFailedException;
*/
final class FailureMarker {
/**
* The path locator service.
*
* @var \Drupal\package_manager\PathLocator
*/
protected $pathLocator;
/**
* Constructs a FailureMarker object.
*
* @param \Drupal\package_manager\PathLocator $pathLocator
* The path locator service.
*/
public function __construct(PathLocator $pathLocator) {
$this->pathLocator = $pathLocator;
public function __construct(private PathLocator $pathLocator) {
}
/**
......
......@@ -26,46 +26,27 @@ final class FileSyncerFactory {
*
* @var \PhpTuf\ComposerStager\Infrastructure\Factory\FileSyncer\FileSyncerFactory
*/
protected $decorated;
/**
* The PHP file syncer service.
*
* @var \PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\PhpFileSyncer
*/
protected $phpFileSyncer;
/**
* The rsync file syncer service.
*
* @var \PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\RsyncFileSyncer
*/
protected $rsyncFileSyncer;
/**
* The config factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
private $decorated;
/**
* Constructs a FileCopierFactory object.
*
* @param \Symfony\Component\Process\ExecutableFinder $executable_finder
* The Symfony executable finder.
* @param \PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\PhpFileSyncer $php_file_syncer
* @param \PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\PhpFileSyncer $phpFileSyncer
* The PHP file syncer service.
* @param \PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\RsyncFileSyncer $rsync_file_syncer
* @param \PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\RsyncFileSyncer $rsyncFileSyncer
* The rsync file syncer service.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config factory service.
*/
public function __construct(ExecutableFinder $executable_finder, PhpFileSyncer $php_file_syncer, RsyncFileSyncer $rsync_file_syncer, ConfigFactoryInterface $config_factory) {
$this->decorated = new StagerFileSyncerFactory($executable_finder, $php_file_syncer, $rsync_file_syncer);
$this->phpFileSyncer = $php_file_syncer;
$this->rsyncFileSyncer = $rsync_file_syncer;
$this->configFactory = $config_factory;
public function __construct(
ExecutableFinder $executable_finder,
private PhpFileSyncer $phpFileSyncer,
private RsyncFileSyncer $rsyncFileSyncer,
private ConfigFactoryInterface $configFactory,
) {
$this->decorated = new StagerFileSyncerFactory($executable_finder, $phpFileSyncer, $rsyncFileSyncer);
}
/**
......
......@@ -28,8 +28,6 @@ final class PackageManagerUninstallValidator implements ModuleUninstallValidator
*/
public function validate($module) {
$stage = new Stage(
// @todo Remove this in https://www.drupal.org/i/3303167
new UnusedConfigFactory(),
$this->container->get('package_manager.path_locator'),
$this->container->get('package_manager.beginner'),
$this->container->get('package_manager.stager'),
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment