Skip to content

Commit

Permalink
Add param type hints and return type declarations using Rector on var…
Browse files Browse the repository at this point in the history
…ious directories (#4959)

* Add param type hints and return type declarations using Rector on various directories

* Fixes

* Fix?
  • Loading branch information
weitzman committed Dec 30, 2021
1 parent 9aaf7ce commit c71be05
Show file tree
Hide file tree
Showing 54 changed files with 408 additions and 619 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"drupal/core-recommended": "^9",
"drupal/semver_example": "2.2.0",
"phpunit/phpunit": ">=7.5.20",
"rector/rector": "^0.11.58",
"rector/rector": "^0.12",
"squizlabs/php_codesniffer": "^2.7 || ^3",
"vlucas/phpdotenv": "^2.4",
"yoast/phpunit-polyfills": "^0.2.0"
Expand Down Expand Up @@ -111,7 +111,7 @@
"api": "php $HOME/bin/doctum.phar --ansi --ignore-parse-errors update doctum-config.php",
"doctum-install": "mkdir -p $HOME/bin && curl --output $HOME/bin/doctum.phar https://doctum.long-term.support/releases/latest/doctum.phar && chmod +x $HOME/bin/doctum.phar",
"mk:docs": "./drush --uri=dev -v mk:docs",
"rector": "rector process src/Boot src/Preflight src/Runtime src/SiteAlias src/Symfony src/Config",
"rector": "rector process src/Boot src/Command src/Sql src/Preflight src/Psysh src/Runtime src/SiteAlias src/Symfony src/Utils src/Config",
"sut": "./drush --uri=dev",
"sut:si": "./drush --uri=dev site:install testing --sites-subdir=dev --db-url=${UNISH_DB_URL:-mysql://root:password@mariadb}/unish_dev -v",
"phpunit": "php -d sendmail_path='true' vendor/bin/phpunit --colors=always --configuration tests",
Expand Down
35 changes: 17 additions & 18 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 7 additions & 13 deletions src/Boot/BaseBoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public function __construct()
register_shutdown_function([$this, 'terminate']);
}

public function findUri($root, $uri)
public function findUri($root, $uri): string
{
return 'default';
}

public function getUri()
public function getUri(): string
{
return $this->uri;
}
Expand All @@ -32,18 +32,12 @@ public function setUri($uri)
$this->uri = $uri;
}

/**
* @return int
*/
public function getPhase()
public function getPhase(): int
{
return $this->phase;
}

/**
* @param int $phase
*/
public function setPhase($phase)
public function setPhase(int $phase)
{
$this->phase = $phase;
}
Expand All @@ -65,14 +59,14 @@ public function reportCommandError($command)
// No longer used.
}

public function bootstrapPhases()
public function bootstrapPhases(): array
{
return [
DRUSH_BOOTSTRAP_DRUSH => 'bootstrapDrush',
];
}

public function bootstrapPhaseMap()
public function bootstrapPhaseMap(): array
{
return [
'none' => DRUSH_BOOTSTRAP_DRUSH,
Expand Down Expand Up @@ -103,7 +97,7 @@ public function bootstrapDrush()
{
}

protected function hasRegisteredSymfonyCommand($application, $name)
protected function hasRegisteredSymfonyCommand($application, $name): bool
{
try {
$application->get($name);
Expand Down
6 changes: 3 additions & 3 deletions src/Boot/Boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function findUri($root, $uri);
*
* @param string $uri Site to bootstrap
*/
public function setUri($uri);
public function setUri(string $uri);

/**
* This function determines if the specified path points to
Expand All @@ -44,7 +44,7 @@ public function validRoot($path);
* @return string|NULL
* The version string for the current version of the software, e.g. 8.1.3
*/
public function getVersion($root);
public function getVersion(string $root);

/**
* Returns an array that determines what bootstrap phases
Expand All @@ -64,7 +64,7 @@ public function bootstrapPhases();
* strings (e.g. "full") to the corresponding bootstrap
* phase index constant (e.g. DRUSH_BOOTSTRAP_DRUPAL_FULL).
*/
public function bootstrapPhaseMap();
public function bootstrapPhaseMap(): array;

/**
* Convert from a phase shorthand or constant to a phase index.
Expand Down
2 changes: 1 addition & 1 deletion src/Boot/BootstrapHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(BootstrapManager $bootstrapManager)
$this->bootstrapManager = $bootstrapManager;
}

public function initialize(InputInterface $input, AnnotationData $annotationData)
public function initialize(InputInterface $input, AnnotationData $annotationData): void
{
// Get the @bootstrap annotation/attribute. If there isn't one, then assume NONE.
$phase_long = $annotationData->get('bootstrap', 'none');
Expand Down

0 comments on commit c71be05

Please sign in to comment.