Skip to content

Commit

Permalink
phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
wimleers committed Jun 15, 2023
1 parent 3bc4a11 commit fbae5c8
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/App/From/SourceSite/Drupal7Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 5 additions & 1 deletion src/Command/App/From/SourceSite/Drupal7SiteInspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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']);
Expand All @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Command/App/NewFromDrupal7Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit fbae5c8

Please sign in to comment.