From 67f4308cd007849c27f064f115a12333b1c55818 Mon Sep 17 00:00:00 2001 From: Anton Medvedev Date: Sun, 13 Oct 2024 21:27:43 +0200 Subject: [PATCH] Fix phpstan errors --- composer.json | 2 +- phpstan.neon | 4 ++++ src/Command/BlackjackCommand.php | 1 + src/Command/SshCommand.php | 3 ++- src/Executor/Master.php | 4 ++-- src/Utility/Rsync.php | 2 +- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 9be8bb2f4..d71fdc09b 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ "test:e2e": "pest --config tests/e2e/phpunit-e2e.xml", "check": "php-cs-fixer check", "fix": "php-cs-fixer fix", - "phpstan": "phpstan analyse -c phpstan.neon", + "phpstan": "phpstan analyse -c phpstan.neon --memory-limit 1G", "phpstan:baseline": "@phpstan --generate-baseline tests/phpstan-baseline.neon" }, "bin": [ diff --git a/phpstan.neon b/phpstan.neon index 99d3c05a4..59b6bd393 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -13,3 +13,7 @@ parameters: - "#^Constant DEPLOYER_BIN not found\\.$#" - "#CpanelPhp#" - "#AMQPMessage#" + + excludePaths: + - src/Command/BlackjackCommand.php + - src/Component/PharUpdate/* diff --git a/src/Command/BlackjackCommand.php b/src/Command/BlackjackCommand.php index eba45166f..dbbeb33d7 100644 --- a/src/Command/BlackjackCommand.php +++ b/src/Command/BlackjackCommand.php @@ -18,6 +18,7 @@ use function Deployer\Support\array_flatten; +// @phpstan-ignore class BlackjackCommand extends Command { use CommandCommon; diff --git a/src/Command/SshCommand.php b/src/Command/SshCommand.php index 37b2cf8c2..9001d3420 100644 --- a/src/Command/SshCommand.php +++ b/src/Command/SshCommand.php @@ -10,13 +10,13 @@ namespace Deployer\Command; -use Deployer\Component\Ssh\Client; use Deployer\Deployer; use Deployer\Host\Localhost; use Deployer\Task\Context; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Completion\CompletionInput; use Symfony\Component\Console\Completion\CompletionSuggestions; +use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -73,6 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if (count($hostsAliases) === 1) { $host = $this->deployer->hosts->get($hostsAliases[0]); } else { + /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $question = new ChoiceQuestion( 'Select host:', diff --git a/src/Executor/Master.php b/src/Executor/Master.php index 8318cc882..489c0f8fd 100644 --- a/src/Executor/Master.php +++ b/src/Executor/Master.php @@ -26,7 +26,7 @@ function spinner(string $message = ''): string { - $frame = FRAMES[(int) ((new \DateTime())->format('u') / 1e5) % count(FRAMES)]; + $frame = FRAMES[(int)((int)(new \DateTime())->format('u') / 1e5) % count(FRAMES)]; return " $frame $message\r"; } @@ -76,7 +76,7 @@ public function __construct( */ public function run(array $tasks, array $hosts, ?Planner $plan = null): int { - $globalLimit = (int) $this->input->getOption('limit') ?: count($hosts); + $globalLimit = (int)$this->input->getOption('limit') ?: count($hosts); foreach ($tasks as $task) { if (!$plan) { diff --git a/src/Utility/Rsync.php b/src/Utility/Rsync.php index a1f85249c..e24538d38 100644 --- a/src/Utility/Rsync.php +++ b/src/Utility/Rsync.php @@ -56,7 +56,7 @@ public function call(Host $host, $source, string $destination, array $config = [ ]; $config = array_merge($defaults, $config); - $options = $config['options'] ?? []; + $options = $config['options']; $flags = $config['flags']; $displayStats = $config['display_stats'] || in_array('--stats', $options, true);