Skip to content

Increase phpstan #113

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions UsersCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class UsersCommands extends DrushCommands implements SiteAliasManagerAwareInterf
/**
* Display a list of Drupal users.
*
* @param array $options
* @param array<mixed> $options
* An associative array of options.
*
* @command users:list
Expand Down Expand Up @@ -80,7 +80,7 @@ public function listAll(
'no-roles' => InputOption::VALUE_REQUIRED,
'last-login' => InputOption::VALUE_REQUIRED,
],
) {
): RowsOfFields {
// Use an entityQuery to dynamically set property conditions.
$query = \Drupal::entityQuery('user')
->accessCheck(FALSE)
Expand Down Expand Up @@ -138,7 +138,7 @@ public function listAll(
*
* @throws \Exception
*/
public function validateList(CommandData $commandData) {
public function validateList(CommandData $commandData): void {
$input = $commandData->input();

$options = [
Expand Down Expand Up @@ -197,7 +197,7 @@ public function validateList(CommandData $commandData) {
* @aliases utog
* @bootstrap full
*/
public function toggle() {
public function toggle(): void {
// Get all users.
$ids = \Drupal::entityQuery('user')
->accessCheck(FALSE)
Expand Down Expand Up @@ -240,10 +240,10 @@ public function toggle() {
throw new UserAbortException();
}

if (Drush::drush($this->siteAliasManager()->getSelf(), 'user:block', [$block_list])->mustRun()) {
\Drupal::state()->set('utog_previous', $previous);
\Drupal::state()->set('utog_status', 'blocked');
}
// drush->mustRun() will throw an exception if not successful.
Drush::drush($this->siteAliasManager()->getSelf(), 'user:block', [$block_list])->mustRun();
\Drupal::state()->set('utog_previous', $previous);
\Drupal::state()->set('utog_status', 'blocked');
}
else {
if (\Drupal::configFactory()->getEditable('user.settings')->get('notify.status_activated')) {
Expand Down Expand Up @@ -271,10 +271,10 @@ public function toggle() {
throw new UserAbortException();
}

if (Drush::drush($this->siteAliasManager()->getSelf(), 'user:unblock', [$unblock_list])->mustRun()) {
\Drupal::state()->set('utog_previous', []);
\Drupal::state()->set('utog_status', 'unblocked');
}
// drush->mustRun() will throw an exception if not successful.
Drush::drush($this->siteAliasManager()->getSelf(), 'user:unblock', [$unblock_list])->mustRun();
\Drupal::state()->set('utog_previous', []);
\Drupal::state()->set('utog_status', 'unblocked');
}
}
}
Expand All @@ -285,10 +285,10 @@ public function toggle() {
* @param \Drupal\user\Entity\User $account
* A user account object.
*
* @return array
* @return array<mixed>
* An array of user information.
*/
protected function infoArray(User $account) {
protected function infoArray(User $account): array {
/** @var \Drupal\Core\Datetime\DateFormatter $date_formatter */
$date_formatter = \Drupal::service('date.formatter');

Expand Down
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 3
level: 6
scanDirectories:
- vendor/drush/drush/src-symfony-compatibility
ignoreErrors:
Expand Down
16 changes: 8 additions & 8 deletions tests/ListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function tearDown() :void {
/**
* Test all users are returned.
*/
public function testAllUsers() {
public function testAllUsers(): void {
$this->drush('users:list', []);

$output = $this->getOutput();
Expand All @@ -53,7 +53,7 @@ public function testAllUsers() {
/**
* Test role option.
*/
public function testUsersReturnedByMultipleRoles() {
public function testUsersReturnedByMultipleRoles(): void {
$this->drush('role:create', ['publisher']);
$this->drush('user:create', ['baz']);
$this->drush('user:role:add', ['publisher', 'baz']);
Expand All @@ -74,7 +74,7 @@ public function testUsersReturnedByMultipleRoles() {
/**
* Test no-role option.
*/
public function testUsersReturnedByMultipleNoRoles() {
public function testUsersReturnedByMultipleNoRoles(): void {
$this->drush('role:create', ['publisher']);
$this->drush('user:create', ['baz']);
$this->drush('user:role:add', ['publisher', 'baz']);
Expand All @@ -94,7 +94,7 @@ public function testUsersReturnedByMultipleNoRoles() {
/**
* Test status option.
*/
public function testUsersReturnedByStatus() {
public function testUsersReturnedByStatus(): void {
$this->drush(
'users:list',
[],
Expand All @@ -110,7 +110,7 @@ public function testUsersReturnedByStatus() {
/**
* Test last-login option.
*/
public function testUsersReturnedByLogin() {
public function testUsersReturnedByLogin(): void {
// Update the login time for user 1. Drush user:login does not do this.
$now = time();

Expand All @@ -134,7 +134,7 @@ public function testUsersReturnedByLogin() {
/**
* Test status and role options in combination.
*/
public function testUsersReturnedByStatusRole() {
public function testUsersReturnedByStatusRole(): void {
$this->drush('user:create', ['baz']);
$this->drush('user:block', ['baz']);
$this->drush('user:role:add', ['editor', 'baz']);
Expand All @@ -155,7 +155,7 @@ public function testUsersReturnedByStatusRole() {
/**
* Test status, role and last-login options in combination.
*/
public function testUsersReturnedByStatusRoleLogin() {
public function testUsersReturnedByStatusRoleLogin(): void {
// Update the login time for user 1. Drush user:login does not do this.
$now = time();

Expand Down Expand Up @@ -200,7 +200,7 @@ public function testUsersReturnedByStatusRoleLogin() {
/**
* Test validation.
*/
public function testValidation() {
public function testValidation(): void {
// Role 'garbage' does not exist.
$this->drush(
'users:list',
Expand Down
4 changes: 2 additions & 2 deletions tests/ToggleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function tearDown() :void {
/**
* Test users are correctly blocked.
*/
public function testUsersBlocked() {
public function testUsersBlocked(): void {
$this->drush('users:toggle', []);
$this->drush('user:information', ['foo, bar'], ['format' => 'json']);

Expand All @@ -54,7 +54,7 @@ public function testUsersBlocked() {
/**
* Test users are correctly unblocked.
*/
public function testUsersUnblocked() {
public function testUsersUnblocked(): void {
// First block, then unblock.
$this->drush('users:toggle', []);
$this->drush('users:toggle', []);
Expand Down