diff --git a/src/Command/App/From/Recommendation/AbandonmentRecommendation.php b/src/Command/App/From/Recommendation/AbandonmentRecommendation.php index a8916e058..a2b907516 100644 --- a/src/Command/App/From/Recommendation/AbandonmentRecommendation.php +++ b/src/Command/App/From/Recommendation/AbandonmentRecommendation.php @@ -82,7 +82,7 @@ public static function createFromDefinition(mixed $definition): RecommendationIn // than to fail to create one at all. return new NoRecommendation(); } - return new static(Closure::fromCallable(function (ExtensionInterface $extension) use ($validated): bool { + return new AbandonmentRecommendation(Closure::fromCallable(function (ExtensionInterface $extension) use ($validated): bool { return $extension->getName() === $validated['replaces']['name']; }), $validated); } diff --git a/src/Command/App/From/Recommendation/DefinedRecommendation.php b/src/Command/App/From/Recommendation/DefinedRecommendation.php index 6369ad812..0abcd74aa 100644 --- a/src/Command/App/From/Recommendation/DefinedRecommendation.php +++ b/src/Command/App/From/Recommendation/DefinedRecommendation.php @@ -163,7 +163,7 @@ public static function createFromDefinition(mixed $definition): RecommendationIn if ($validated['universal']) { return new UniversalRecommendation($package_name, $version_constraint, $install, $vetted, $note, $patches); } - return new static(Closure::fromCallable(function (ExtensionInterface $extension) use ($validated): bool { + return new DefinedRecommendation(Closure::fromCallable(function (ExtensionInterface $extension) use ($validated): bool { return $extension->getName() === $validated['replaces']['name']; }), $package_name, $version_constraint, $install, $vetted, $note, $patches); } diff --git a/src/Command/App/From/Recommendation/UniversalRecommendation.php b/src/Command/App/From/Recommendation/UniversalRecommendation.php index 1cfae76a2..cb1760cc4 100644 --- a/src/Command/App/From/Recommendation/UniversalRecommendation.php +++ b/src/Command/App/From/Recommendation/UniversalRecommendation.php @@ -17,7 +17,7 @@ final class UniversalRecommendation extends DefinedRecommendation { */ protected function __construct(string $package_name, string $version_constraint, array $install, bool $vetted, string $note, array $patches = []) { parent::__construct(Closure::fromCallable(function (): void { - throw new LogicException(sprintf('It is nonsensical to call the applies() method on a % class instance.', __FUNCTION__, __CLASS__)); + throw new LogicException(sprintf('It is nonsensical to call the applies() method on a % class instance.', __CLASS__)); }), $package_name, $version_constraint, $install, $vetted, $note, $patches); } diff --git a/src/Command/App/From/SourceSite/Drupal7Extension.php b/src/Command/App/From/SourceSite/Drupal7Extension.php index 26d1cd811..4c323f648 100644 --- a/src/Command/App/From/SourceSite/Drupal7Extension.php +++ b/src/Command/App/From/SourceSite/Drupal7Extension.php @@ -56,7 +56,7 @@ protected function __construct(string $type, string $name, bool $enabled, string $this->type = $type; $this->name = $name; $this->enabled = $enabled; - $this->humanName = $human_name ?? $name; + $this->humanName = !empty($human_name) ? $human_name : $name; $this->version = $version; } diff --git a/src/Command/App/From/SourceSite/Drupal7SiteInspector.php b/src/Command/App/From/SourceSite/Drupal7SiteInspector.php index 71e2b677e..2b12c7360 100644 --- a/src/Command/App/From/SourceSite/Drupal7SiteInspector.php +++ b/src/Command/App/From/SourceSite/Drupal7SiteInspector.php @@ -17,7 +17,7 @@ final class Drupal7SiteInspector extends SiteInspectorBase { /** * The host name to use in order to resolve the appropriate settings.php. */ - public readonly string $uri; + public string $uri; /** * Drupal7SiteInspector constructor. @@ -40,6 +40,7 @@ public function __construct(string $drupal_root, string $uri = 'default') { */ protected function readExtensions(): array { $this->bootstrap(); + // @phpstan-ignore-next-line $enabled = system_list('module_enabled'); // Special case to remove 'standard' from the module's list. unset($enabled['standard']); @@ -60,11 +61,13 @@ protected function readExtensions(): array { public function getPublicFilePath(): string { $this->bootstrap(); // @see https://git.drupalcode.org/project/drupal/-/blob/7.x/includes/stream_wrappers.inc#L919 + // @phpstan-ignore-next-line return variable_get('file_public_path', conf_path() . '/files'); } public function getPrivateFilePath(): ?string { $this->bootstrap(); + // @phpstan-ignore-next-line return variable_get('file_private_path', NULL); } @@ -92,6 +95,7 @@ protected function bootstrap(): void { $_SERVER['SCRIPT_FILENAME'] = DRUPAL_ROOT . '/index.php'; // phpcs:enable SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; + // @phpstan-ignore-next-line drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES); chdir($previous_directory); $bootstrapped = TRUE; diff --git a/src/Command/App/NewFromDrupal7Command.php b/src/Command/App/NewFromDrupal7Command.php index 6cbb1b99a..09e1cf8bb 100644 --- a/src/Command/App/NewFromDrupal7Command.php +++ b/src/Command/App/NewFromDrupal7Command.php @@ -119,6 +119,7 @@ private static function getSiteUri(InputInterface $input, string $drupal_root): // @see https://git.drupalcode.org/project/drupal/-/blob/7.x/includes/bootstrap.inc#L563 include $sites_location; + // @phpstan-ignore-next-line if (!empty($sites)) { // If the URI corresponds to a configuration in sites.php, then ensure // that the identified directory also has a settings.php file. If it diff --git a/tests/phpunit/src/Commands/App/From/ExportedDrupal7ExtensionsInspector.php b/tests/phpunit/src/Commands/App/From/ExportedDrupal7ExtensionsInspector.php index 80d5dd169..0ab5c6bee 100644 --- a/tests/phpunit/src/Commands/App/From/ExportedDrupal7ExtensionsInspector.php +++ b/tests/phpunit/src/Commands/App/From/ExportedDrupal7ExtensionsInspector.php @@ -8,7 +8,7 @@ use Acquia\Cli\Command\App\From\SourceSite\Drupal7Extension; use Acquia\Cli\Command\App\From\SourceSite\SiteInspectorBase; -class ExportedDrupal7ExtensionsInspector extends SiteInspectorBase { +final class ExportedDrupal7ExtensionsInspector extends SiteInspectorBase { use JsonResourceParserTrait; diff --git a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php index 4f2344c0c..f4773dca6 100644 --- a/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php +++ b/tests/phpunit/src/Commands/App/NewFromDrupal7CommandTest.php @@ -85,7 +85,7 @@ public function testNewFromDrupal7Command(string $extensions_json, string $expec try { $inspector = ExportedDrupal7ExtensionsInspector::createFromResource($extensions_resource); } - catch (JsonException $e) { + catch (\JsonException $e) { $this->fail("$extensions_json contains malformed JSON."); return; }