Skip to content
Snippets Groups Projects
Commit 2ec02afe authored by Lucas Hedding's avatar Lucas Hedding Committed by Adam G-H
Browse files

Issue #3380571 by heddn: Convert protected members of final classes to private

parent d9220bf4
No related branches found
No related tags found
No related merge requests found
Showing
with 41 additions and 46 deletions
......@@ -29,7 +29,7 @@ final class BatchProcessor {
* @return \Drupal\automatic_updates_extensions\ExtensionUpdateStage
* The update stage service.
*/
protected static function getStage(): ExtensionUpdateStage {
private static function getStage(): ExtensionUpdateStage {
return \Drupal::service('automatic_updates_extensions.update_stage');
}
......@@ -45,7 +45,7 @@ final class BatchProcessor {
* The caught exception, which will always be re-thrown once its messages
* have been recorded.
*/
protected static function handleException(\Throwable $error, array &$context): void {
private static function handleException(\Throwable $error, array &$context): void {
$context['results']['errors'][] = $error->getMessage();
throw $error;
}
......@@ -206,7 +206,7 @@ final class BatchProcessor {
* @param array $results
* The batch results.
*/
protected static function handleBatchError(array $results): void {
private static function handleBatchError(array $results): void {
if (isset($results['errors'])) {
foreach ($results['errors'] as $error) {
\Drupal::messenger()->addError($error);
......
......@@ -164,7 +164,7 @@ final class UpdaterForm extends UpdateFormBase {
* @return mixed[][]
* The form's actions elements.
*/
protected function actions(FormStateInterface $form_state): array {
private function actions(FormStateInterface $form_state): array {
$actions = ['#type' => 'actions'];
if (!$this->stage->isAvailable()) {
// If the form has been submitted do not display this error message
......
......@@ -57,7 +57,7 @@ final class UpdateReleaseValidator implements EventSubscriberInterface {
* TRUE if the given version of the project is supported, otherwise FALSE.
* given version is not supported will return FALSE.
*/
protected function isSupportedRelease(string $name, string $semantic_version): bool {
private function isSupportedRelease(string $name, string $semantic_version): bool {
$supported_releases = (new ProjectInfo($name))->getInstallableReleases();
if (!$supported_releases) {
return FALSE;
......
......@@ -37,8 +37,8 @@ final class CollectPathsToExcludeEvent extends StageEvent implements PathListInt
*/
public function __construct(
StageBase $stage,
protected PathLocator $pathLocator,
protected PathFactoryInterface $pathFactory
private readonly PathLocator $pathLocator,
private readonly PathFactoryInterface $pathFactory
) {
parent::__construct($stage);
$this->pathList = new PathList();
......
......@@ -16,7 +16,7 @@ final class PreApplyEvent extends PreOperationStageEvent {
*
* @var string[]
*/
protected array $excludedPaths = [];
private array $excludedPaths = [];
/**
* Returns the paths to exclude from the current operation.
......
......@@ -16,7 +16,7 @@ final class PreCreateEvent extends PreOperationStageEvent {
*
* @var string[]
*/
protected array $excludedPaths = [];
private array $excludedPaths = [];
/**
* Returns the paths to exclude from the current operation.
......
......@@ -81,7 +81,7 @@ final class ProcessFactory implements ProcessFactoryInterface {
* @see php_sapi_name()
* @see https://www.php.net/manual/en/reserved.constants.php
*/
protected static function getPhpDirectory(): string {
private static function getPhpDirectory(): string {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'cli-server') {
return dirname(PHP_BINARY);
}
......
......@@ -85,7 +85,7 @@ final class DuplicateInfoFileValidator implements EventSubscriberInterface {
* @return int[]
* Array of count of info.yml files in the directory keyed by file name.
*/
protected function findInfoFiles(string $dir): array {
private function findInfoFiles(string $dir): array {
// Use the official extension discovery mechanism, but tweak it, because by
// default it resolves duplicates.
// @see \Drupal\Core\Extension\ExtensionDiscovery::process()
......
......@@ -20,7 +20,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class EnvironmentSupportValidator implements EventSubscriberInterface {
use BaseRequirementValidatorTrait {
getSubscribedEvents as protected getSubscribedEventsFromTrait;
getSubscribedEvents as private getSubscribedEventsFromTrait;
}
use StringTranslationTrait;
......
......@@ -32,7 +32,7 @@ final class LockFileValidator implements EventSubscriberInterface {
*
* @var string
*/
protected const STATE_KEY = 'package_manager.lock_hash';
private const STATE_KEY = 'package_manager.lock_hash';
/**
* Constructs a LockFileValidator object.
......
......@@ -48,7 +48,7 @@ final class MultisiteValidator implements EventSubscriberInterface {
* @return bool
* TRUE if the current site is part of a multisite, otherwise FALSE.
*/
protected function isMultisite(): bool {
private function isMultisite(): bool {
$web_root = $this->pathLocator->getWebRoot();
if ($web_root) {
$web_root .= '/';
......
......@@ -21,7 +21,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
final class StageNotInActiveValidator implements EventSubscriberInterface {
use BaseRequirementValidatorTrait {
getSubscribedEvents as protected getSubscribedEventsFromTrait;
getSubscribedEvents as private getSubscribedEventsFromTrait;
}
use StringTranslationTrait;
......
......@@ -53,7 +53,7 @@ final class SupportedReleaseValidator implements EventSubscriberInterface {
* TRUE if the given version of the project is supported, otherwise FALSE.
* given version is not supported will return FALSE.
*/
protected function isSupportedRelease(string $name, string $semantic_version): bool {
private function isSupportedRelease(string $name, string $semantic_version): bool {
$supported_releases = (new ProjectInfo($name))->getInstallableReleases();
if (!$supported_releases) {
return FALSE;
......
......@@ -24,7 +24,7 @@ trait ComposerStagerExceptionTrait {
/**
* Throws the exception if set.
*/
protected function throwExceptionIfSet(): void {
private function throwExceptionIfSet(): void {
if ($exception = $this->state->get(static::class . '-exception')) {
throw $exception;
}
......
......@@ -20,7 +20,7 @@ trait LoggingDecoratorTrait {
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
private $state;
/**
* Returns the arguments from every invocation of the main class method.
......@@ -38,7 +38,7 @@ trait LoggingDecoratorTrait {
* @param mixed ...$arguments
* The arguments that the main class method was called with.
*/
protected function saveInvocationArguments(...$arguments): void {
private function saveInvocationArguments(...$arguments): void {
$invocations = $this->getInvocationArguments();
$invocations[] = $arguments;
$this->state->set(static::class . ' arguments', $invocations);
......
......@@ -67,7 +67,7 @@ final class PackageManagerFixtureCreator {
* @return string
* The Composer command output.
*/
protected static function runComposerCommand(array $command): string {
private static function runComposerCommand(array $command): string {
array_unshift($command, 'composer');
$command[] = "--working-dir=" . static::FIXTURE_PATH;
$process = new Process($command);
......@@ -86,7 +86,7 @@ final class PackageManagerFixtureCreator {
* @param string[] $files_to_keep
* The files to not delete.
*/
protected static function removeAllExcept(string $directory, array $files_to_keep): void {
private static function removeAllExcept(string $directory, array $files_to_keep): void {
if (!is_dir($directory)) {
throw new \LogicException("Expected directory $directory");
}
......@@ -103,8 +103,8 @@ final class PackageManagerFixtureCreator {
/**
* Runs `composer install`.
*/
protected static function doComposerInstall(): void {
static::runComposerCommand(['install']);
private static function doComposerInstall(): void {
self::runComposerCommand(['install']);
}
}
......@@ -45,7 +45,7 @@ final class BatchProcessor {
* @return \Drupal\automatic_updates\UpdateStage
* The update stage service.
*/
protected static function getStage(): UpdateStage {
private static function getStage(): UpdateStage {
return \Drupal::service('automatic_updates.update_stage');
}
......@@ -55,7 +55,7 @@ final class BatchProcessor {
* @param string $error_message
* The error message.
*/
protected static function storeErrorMessage(string $error_message): void {
private static function storeErrorMessage(string $error_message): void {
// TRICKY: We need to store error messages in the session because the batch
// context becomes a dangling reference when static variables are globally
// reset by drupal_flush_all_caches(), which is called during the post-apply
......@@ -222,7 +222,7 @@ final class BatchProcessor {
*
* @see ::storeErrorMessage()
*/
protected static function displayStoredErrorMessages(): void {
private static function displayStoredErrorMessages(): void {
/** @var \Symfony\Component\HttpFoundation\Session\SessionInterface $session */
$session = \Drupal::service('session');
$errors = $session->get(self::ERROR_MESSAGES_SESSION_KEY);
......
......@@ -10,7 +10,6 @@ use Drupal\package_manager\ComposerInspector;
use Drupal\package_manager\Exception\StageFailureMarkerException;
use Drupal\package_manager\ValidationResult;
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Extension\ModuleExtensionList;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\RendererInterface;
......@@ -36,8 +35,6 @@ final class UpdateReady extends UpdateFormBase {
* The update stage service.
* @param \Drupal\Core\State\StateInterface $state
* The state service.
* @param \Drupal\Core\Extension\ModuleExtensionList $moduleList
* The module list service.
* @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $eventDispatcher
......@@ -46,12 +43,11 @@ final class UpdateReady extends UpdateFormBase {
* The Composer inspector service.
*/
public function __construct(
protected UpdateStage $stage,
protected StateInterface $state,
protected ModuleExtensionList $moduleList,
protected RendererInterface $renderer,
protected EventDispatcherInterface $eventDispatcher,
private ComposerInspector $composerInspector
private readonly UpdateStage $stage,
private readonly StateInterface $state,
private readonly RendererInterface $renderer,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly ComposerInspector $composerInspector
) {}
/**
......@@ -68,7 +64,6 @@ final class UpdateReady extends UpdateFormBase {
return new static(
$container->get('automatic_updates.update_stage'),
$container->get('state'),
$container->get('extension.list.module'),
$container->get('renderer'),
$container->get('event_dispatcher'),
$container->get('package_manager.composer_inspector')
......
......@@ -55,13 +55,13 @@ final class UpdaterForm extends UpdateFormBase {
* The module handler service.
*/
public function __construct(
protected StateInterface $state,
protected UpdateStage $stage,
protected EventDispatcherInterface $eventDispatcher,
protected ReleaseChooser $releaseChooser,
protected RendererInterface $renderer,
protected FailureMarker $failureMarker,
protected ModuleHandlerInterface $moduleHandler,
private readonly StateInterface $state,
private readonly UpdateStage $stage,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly ReleaseChooser $releaseChooser,
private readonly RendererInterface $renderer,
private readonly FailureMarker $failureMarker,
private readonly ModuleHandlerInterface $moduleHandler,
) {}
/**
......
......@@ -27,7 +27,7 @@ final class ReleaseChooser {
*
* @var \Drupal\package_manager\ProjectInfo
*/
protected $projectInfo;
private readonly ProjectInfo $projectInfo;
/**
* Constructs an ReleaseChooser object.
......@@ -49,7 +49,7 @@ final class ReleaseChooser {
* The releases that are installable by the given update stage, according to
* the version validator service.
*/
protected function getInstallableReleases(UpdateStage $stage): array {
private function getInstallableReleases(UpdateStage $stage): array {
$filter = function (string $version) use ($stage): bool {
return empty($this->versionPolicyValidator->validateVersion($stage, $version));
};
......@@ -97,7 +97,7 @@ final class ReleaseChooser {
* @return string
* The installed version of Drupal core.
*/
protected function getInstalledVersion(): string {
private function getInstalledVersion(): string {
return $this->projectInfo->getInstalledVersion();
}
......
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