Skip to content

Commit

Permalink
Fix some phpstan level 7 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 23, 2024
1 parent 49bd7d3 commit 2c970e2
Show file tree
Hide file tree
Showing 224 changed files with 1,668 additions and 975 deletions.
268 changes: 264 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ parameters:
count: 1
path: src/Command/Integration/IntegrationCommandBase.php

-
message: "#^Cannot call method set\\(\\) on Platformsh\\\\ConsoleForm\\\\Field\\\\Field\\|false\\.$#"
count: 1
path: src/Command/Organization/OrganizationCreateCommand.php

-
message: "#^Call to an undefined method GuzzleHttp\\\\ClientInterface\\:\\:get\\(\\)\\.$#"
count: 1
Expand All @@ -70,6 +75,11 @@ parameters:
count: 3
path: src/Command/Resources/ResourcesSizeListCommand.php

-
message: "#^Parameter \\#1 \\$items of method Platformsh\\\\Cli\\\\Service\\\\QuestionHelper\\:\\:choose\\(\\) expects array\\<string, string\\>, array\\<int, string\\> given\\.$#"
count: 1
path: src/Command/SshKey/SshKeyDeleteCommand.php

-
message: "#^Call to an undefined method GuzzleHttp\\\\ClientInterface\\:\\:post\\(\\)\\.$#"
count: 1
Expand Down Expand Up @@ -106,20 +116,240 @@ parameters:
path: src/Command/WinkyCommand.php

-
message: "#^Negated boolean expression is always true\\.$#"
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:describeApplication\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:describeCommand\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:describeInputArgument\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:describeInputDefinition\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:describeInputOption\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:getCommandData\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:getInputArgumentData\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:getInputDefinitionData\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:getInputOptionData\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:writeData\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomJsonDescriptor\\:\\:writeData\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Parameter \\#1 \\$content of method Symfony\\\\Component\\\\Console\\\\Descriptor\\\\Descriptor\\:\\:write\\(\\) expects string, string\\|false given\\.$#"
count: 1
path: src/Console/CustomJsonDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomMarkdownDescriptor\\:\\:describeApplication\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomMarkdownDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomMarkdownDescriptor\\:\\:describeCommand\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomMarkdownDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomMarkdownDescriptor\\:\\:describeInputArgument\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomMarkdownDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomMarkdownDescriptor\\:\\:describeInputOption\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomMarkdownDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomTextDescriptor\\:\\:describeApplication\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomTextDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomTextDescriptor\\:\\:describeCommand\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomTextDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomTextDescriptor\\:\\:describeInputOption\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomTextDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomTextDescriptor\\:\\:formatAliases\\(\\) has parameter \\$aliases with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomTextDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomTextDescriptor\\:\\:getColumnWidth\\(\\) has parameter \\$commands with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomTextDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomTextDescriptor\\:\\:getColumnWidth\\(\\) should return int but returns float\\|int\\<35, max\\>\\.$#"
count: 1
path: src/Console/CustomTextDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Console\\\\CustomTextDescriptor\\:\\:writeText\\(\\) has parameter \\$options with no value type specified in iterable type array\\.$#"
count: 1
path: src/Console/CustomTextDescriptor.php

-
message: "#^Method Platformsh\\\\Cli\\\\CredentialHelper\\\\SessionStorage\\:\\:load\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
path: src/CredentialHelper/SessionStorage.php

-
message: "#^Method Platformsh\\\\Cli\\\\CredentialHelper\\\\SessionStorage\\:\\:save\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
path: src/CredentialHelper/SessionStorage.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\ConnectionFailedException\\:\\:\\$code has no type specified\\.$#"
count: 1
path: src/Local/LocalProject.php
path: src/Exception/ConnectionFailedException.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\ConnectionFailedException\\:\\:\\$message has no type specified\\.$#"
count: 1
path: src/Exception/ConnectionFailedException.php

-
message: "#^Method Platformsh\\\\Cli\\\\Exception\\\\DependencyMissingException\\:\\:__construct\\(\\) has parameter \\$message with no type specified\\.$#"
count: 1
path: src/Exception/DependencyMissingException.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\InvalidConfigException\\:\\:\\$code has no type specified\\.$#"
count: 1
path: src/Exception/InvalidConfigException.php

-
message: "#^Method Platformsh\\\\Cli\\\\Exception\\\\LoginRequiredException\\:\\:__construct\\(\\) has parameter \\$message with no type specified\\.$#"
count: 1
path: src/Exception/LoginRequiredException.php

-
message: "#^Method Platformsh\\\\Cli\\\\Exception\\\\LoginRequiredException\\:\\:__construct\\(\\) has parameter \\$previous with no type specified\\.$#"
count: 1
path: src/Exception/LoginRequiredException.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\LoginRequiredException\\:\\:\\$code has no type specified\\.$#"
count: 1
path: src/Exception/LoginRequiredException.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\LoginRequiredException\\:\\:\\$message has no type specified\\.$#"
count: 1
path: src/Exception/LoginRequiredException.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\PermissionDeniedException\\:\\:\\$code has no type specified\\.$#"
count: 1
path: src/Exception/PermissionDeniedException.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\PermissionDeniedException\\:\\:\\$message has no type specified\\.$#"
count: 1
path: src/Exception/PermissionDeniedException.php

-
message: "#^Property Platformsh\\\\Cli\\\\Exception\\\\ProjectNotFoundException\\:\\:\\$code has no type specified\\.$#"
count: 1
path: src/Exception/ProjectNotFoundException.php

-
message: "#^Method Platformsh\\\\Cli\\\\Exception\\\\RootNotFoundException\\:\\:__construct\\(\\) has parameter \\$code with no type specified\\.$#"
count: 1
path: src/Exception/RootNotFoundException.php

-
message: "#^Method Platformsh\\\\Cli\\\\Exception\\\\RootNotFoundException\\:\\:__construct\\(\\) has parameter \\$message with no type specified\\.$#"
count: 1
path: src/Exception/RootNotFoundException.php

-
message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\\\Error\\|PhpParser\\\\Node\\\\Expr\\\\Variable\\:\\:\\$name\\.$#"
count: 3
path: src/Rector/DependencyInjection.php

-
message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\|PhpParser\\\\Node\\\\Identifier\\:\\:\\$name\\.$#"
count: 2
path: src/Rector/InjectCommandServicesRector.php

-
message: "#^Parameter \\#2 \\$callable of method Rector\\\\Rector\\\\AbstractRector\\:\\:traverseNodesWithCallable\\(\\) expects callable\\(PhpParser\\\\Node\\)\\: \\(array\\<PhpParser\\\\Node\\>\\|int\\|PhpParser\\\\Node\\|null\\), Closure\\(PhpParser\\\\NodeAbstract\\)\\: \\(PhpParser\\\\Node\\\\Expr\\\\Assign\\|null\\) given\\.$#"
count: 1
path: src/Rector/InjectCommandServicesRector.php

-
message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\|PhpParser\\\\Node\\\\Identifier\\:\\:\\$name\\.$#"
count: 1
path: src/Rector/NewServicesRector.php

-
message: "#^Parameter \\#2 \\$callable of method Rector\\\\Rector\\\\AbstractRector\\:\\:traverseNodesWithCallable\\(\\) expects callable\\(PhpParser\\\\Node\\)\\: \\(array\\<PhpParser\\\\Node\\>\\|int\\|PhpParser\\\\Node\\|null\\), Closure\\(PhpParser\\\\NodeAbstract\\)\\: \\(PhpParser\\\\Node\\\\Expr\\\\MethodCall\\|null\\) given\\.$#"
count: 1
path: src/Rector/NewServicesRector.php

-
message: "#^Property PhpParser\\\\Node\\\\Expr\\\\MethodCall\\:\\:\\$args \\(array\\<PhpParser\\\\Node\\\\Arg\\|PhpParser\\\\Node\\\\VariadicPlaceholder\\>\\) does not accept array\\<PhpParser\\\\Node\\\\Arg\\>\\|string\\.$#"
count: 1
path: src/Rector/NewServicesRector.php

-
message: "#^Property Platformsh\\\\Cli\\\\Rector\\\\NewServicesRector\\:\\:\\$transforms type has no value type specified in iterable type array\\.$#"
count: 1
path: src/Rector/NewServicesRector.php

-
message: "#^Access to an undefined property PhpParser\\\\Node\\\\Arg\\|PhpParser\\\\Node\\\\VariadicPlaceholder\\:\\:\\$value\\.$#"
count: 3
path: src/Rector/UseSelectorServiceRector.php

-
message: "#^Access to an undefined property PhpParser\\\\Node\\\\Expr\\|PhpParser\\\\Node\\\\Identifier\\:\\:\\$name\\.$#"
count: 6
path: src/Rector/UseSelectorServiceRector.php

-
message: "#^Parameter \\#2 \\$callable of method Rector\\\\Rector\\\\AbstractRector\\:\\:traverseNodesWithCallable\\(\\) expects callable\\(PhpParser\\\\Node\\)\\: \\(array\\<PhpParser\\\\Node\\>\\|int\\|PhpParser\\\\Node\\|null\\), Closure\\(PhpParser\\\\NodeAbstract\\)\\: \\(PhpParser\\\\Node\\\\Expr\\\\Assign\\|PhpParser\\\\Node\\\\Expr\\\\MethodCall\\|null\\) given\\.$#"
count: 1
Expand All @@ -130,6 +360,31 @@ parameters:
count: 1
path: src/Service/ActivityMonitor.php

-
message: "#^Method Platformsh\\\\Cli\\\\Service\\\\Api\\:\\:checkCanCreate\\(\\) should return array\\{can_create\\: bool, message\\: string, required_action\\: array\\{action\\: string, type\\: string\\}\\|null\\} but returns array\\.$#"
count: 1
path: src/Service/Api.php

-
message: "#^Method Platformsh\\\\Cli\\\\Service\\\\Api\\:\\:checkUserVerification\\(\\) should return array\\{state\\: bool, type\\: string\\} but returns array\\.$#"
count: 1
path: src/Service/Api.php

-
message: "#^Method Platformsh\\\\Cli\\\\Service\\\\Api\\:\\:getMyAccount\\(\\) should return array\\{id\\: string, username\\: string, email\\: string, first_name\\: string, last_name\\: string, display_name\\: string, phone_number_verified\\: bool\\} but returns non\\-empty\\-array\\.$#"
count: 1
path: src/Service/Api.php

-
message: "#^Method Platformsh\\\\Cli\\\\Service\\\\Filesystem\\:\\:remove\\(\\) has parameter \\$files with no value type specified in iterable type iterable\\.$#"
count: 1
path: src/Service/Filesystem.php

-
message: "#^Method Platformsh\\\\Cli\\\\Service\\\\Filesystem\\:\\:unprotect\\(\\) has parameter \\$files with no value type specified in iterable type iterable\\.$#"
count: 1
path: src/Service/Filesystem.php

-
message: "#^Call to an undefined method GuzzleHttp\\\\ClientInterface\\:\\:head\\(\\)\\.$#"
count: 1
Expand All @@ -141,6 +396,11 @@ parameters:
path: tests/Command/User/UserAddCommandTest.php

-
message: "#^Property Platformsh\\\\Cli\\\\Tests\\\\Command\\\\User\\\\UserAddCommandTest\\:\\:\\$mockTypes is never read, only written\\.$#"
message: "#^Property Platformsh\\\\Cli\\\\Tests\\\\Local\\\\LocalBuildTest\\:\\:\\$localBuild \\(Platformsh\\\\Cli\\\\Local\\\\LocalBuild\\|null\\) does not accept object\\.$#"
count: 1
path: tests/Command/User/UserAddCommandTest.php
path: tests/Local/LocalBuildTest.php

-
message: "#^Property Platformsh\\\\Cli\\\\Tests\\\\Service\\\\SshTest\\:\\:\\$ssh \\(Platformsh\\\\Cli\\\\Service\\\\Ssh\\|null\\) does not accept object\\.$#"
count: 1
path: tests/Service/SshTest.php
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
parameters:
level: 5
level: 7
paths:
- src
- tests
Expand Down
6 changes: 2 additions & 4 deletions src/Command/Activity/ActivityCancelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 1;
}
$choices = [];
$questionHelper = $this->questionHelper;
$formatter = $this->propertyFormatter;
$byId = [];
$this->api->sortResources($activities, 'created_at');
foreach ($activities as $activity) {
$byId[$activity->id] = $activity;
$choices[$activity->id] = \sprintf(
'%s: %s (%s)',
$formatter->formatDate($activity->created_at),
$this->propertyFormatter->formatDate($activity->created_at),
ActivityMonitor::getFormattedDescription($activity),
ActivityMonitor::formatState($activity->state)
);
}
$id = $questionHelper->choose($choices, 'Enter a number to choose an activity to cancel:', key($choices), true);
$id = $this->questionHelper->choose($choices, 'Enter a number to choose an activity to cancel:', (string) key($choices));
$activity = $byId[$id];
}

Expand Down
4 changes: 4 additions & 0 deletions src/Command/Activity/ActivityListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Platformsh\Cli\Service\ActivityMonitor;
use Platformsh\Cli\Service\PropertyFormatter;
use Platformsh\Cli\Service\Table;
use Platformsh\Client\Model\Activity;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -183,6 +184,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

/**
* @param Activity[] $activities
*/
private function suggestExclusions(array $activities): void
{
$counts = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Activity/ActivityLogCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($timestamps && $input->hasOption('date-fmt') && $input->getOption('date-fmt') !== null) {
$timestamps = $input->getOption('date-fmt');
} elseif ($timestamps) {
$timestamps = $this->config->getWithDefault('application.date_format', 'c');
$timestamps = $this->config->getStr('application.date_format');
}
if ($refresh > 0 && !$this->runningViaMulti && !$activity->isComplete() && $activity->state !== Activity::STATE_CANCELLED) {
$this->activityMonitor->waitAndLog($activity, $refresh, $timestamps, false, $output);
Expand Down
2 changes: 1 addition & 1 deletion src/Command/App/AppConfigGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$prefix = $this->config->getStr('service.env_prefix');
if (getenv($prefix . 'APPLICATION') && !LocalHost::conflictsWithCommandLineOptions($input, $prefix)) {
$this->io->debug('Reading application config from environment variable ' . $prefix . 'APPLICATION');
$decoded = json_decode(base64_decode(getenv($prefix . 'APPLICATION'), true), true);
$decoded = json_decode((string) base64_decode(getenv($prefix . 'APPLICATION'), true), true);
if (!is_array($decoded)) {
throw new \RuntimeException('Failed to decode: ' . $prefix . 'APPLICATION');
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/App/AppListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$rows = [];
foreach ($apps as $app) {
$row = [$app->name, $this->propertyFormatter->format($app->type, 'service_type'), 'disk' => $app->disk, $app->size];
$row = [$app->name, $this->propertyFormatter->format($app->type, 'service_type'), 'disk' => (string) $app->disk, $app->size];
if ($showLocalPath) {
$row['path'] = $getLocalPath($app->name);
}
Expand Down Expand Up @@ -137,7 +137,7 @@ private function recommendOtherCommands(EnvironmentDeployment $deployment): void
);
}
if ($info = $deployment->getProperty('project_info', false)) {
if (!empty($info['settings']['sizing_api_enabled']) && $this->config->get('api.sizing') && $this->config->isCommandEnabled('resources:set')) {
if (!empty($info['settings']['sizing_api_enabled']) && $this->config->getBool('api.sizing') && $this->config->isCommandEnabled('resources:set')) {
$lines[] = sprintf(
"To configure resources, run: <info>%s resources:set</info>",
$executable
Expand Down
Loading

0 comments on commit 2c970e2

Please sign in to comment.