From fde69ade6b0296e6702968378c28dbae1e72897f Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 13 Mar 2019 19:46:06 +0200 Subject: [PATCH] Fixed some phpstan level 2 issues in Grav\Console --- composer.json | 2 +- system/src/Grav/Common/Grav.php | 5 ++ system/src/Grav/Console/Cli/BackupCommand.php | 8 +--- system/src/Grav/Console/Cli/CacheCommand.php | 6 --- system/src/Grav/Console/Cli/CleanCommand.php | 9 +--- .../src/Grav/Console/Cli/ComposerCommand.php | 23 ---------- .../src/Grav/Console/Cli/InstallCommand.php | 25 +++------- .../src/Grav/Console/Cli/LogViewerCommand.php | 4 -- .../Grav/Console/Cli/NewProjectCommand.php | 7 --- .../src/Grav/Console/Cli/SandboxCommand.php | 44 ++---------------- .../src/Grav/Console/Cli/SchedulerCommand.php | 3 -- .../src/Grav/Console/Cli/SecurityCommand.php | 8 +--- system/src/Grav/Console/ConsoleTrait.php | 5 +- .../Grav/Console/Gpm/DirectInstallCommand.php | 6 +-- system/src/Grav/Console/Gpm/IndexCommand.php | 33 +++++-------- system/src/Grav/Console/Gpm/InfoCommand.php | 10 ++-- .../src/Grav/Console/Gpm/InstallCommand.php | 44 +++++++++--------- .../Grav/Console/Gpm/SelfupgradeCommand.php | 46 +++++++------------ .../src/Grav/Console/Gpm/UninstallCommand.php | 45 ++++++++---------- system/src/Grav/Console/Gpm/UpdateCommand.php | 45 ++++++------------ .../src/Grav/Console/Gpm/VersionCommand.php | 7 +-- .../Psr7/Traits/UriDecorationTrait.php | 14 +++--- tests/phpstan/phpstan.neon | 9 ++++ 23 files changed, 126 insertions(+), 282 deletions(-) diff --git a/composer.json b/composer.json index da3c4f783..2cd2fa360 100644 --- a/composer.json +++ b/composer.json @@ -89,7 +89,7 @@ }, "scripts": { "post-create-project-cmd": "bin/grav install", - "phpstan": "vendor/bin/phpstan analyse -l 1 -c ./tests/phpstan/phpstan.neon system/src --memory-limit=256M", + "phpstan": "vendor/bin/phpstan analyse -l 2 -c ./tests/phpstan/phpstan.neon system/src --memory-limit=256M", "test": "vendor/bin/codecept run unit", "test-windows": "vendor\\bin\\codecept run unit" }, diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index ba85f1eff..d4b2e8759 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -38,6 +38,11 @@ use Psr\Http\Message\ServerRequestInterface; use RocketTheme\Toolbox\Event\Event; use RocketTheme\Toolbox\Event\EventDispatcher; +/** + * Grav container is the heart of Grav. + * + * @package Grav\Common + */ class Grav extends Container { /** diff --git a/system/src/Grav/Console/Cli/BackupCommand.php b/system/src/Grav/Console/Cli/BackupCommand.php index b78211389..4476da48a 100644 --- a/system/src/Grav/Console/Cli/BackupCommand.php +++ b/system/src/Grav/Console/Cli/BackupCommand.php @@ -25,9 +25,6 @@ class BackupCommand extends ConsoleCommand /** @var ProgressBar $progress */ protected $progress; - /** - * - */ protected function configure() { $this @@ -44,9 +41,6 @@ class BackupCommand extends ConsoleCommand $this->source = getcwd(); } - /** - * @return int|null|void - */ protected function serve() { $this->progress = new ProgressBar($this->output); @@ -96,7 +90,7 @@ class BackupCommand extends ConsoleCommand } /** - * @param $args + * @param array $args */ public function outputProgress($args) { diff --git a/system/src/Grav/Console/Cli/CacheCommand.php b/system/src/Grav/Console/Cli/CacheCommand.php index b80482b11..59c48c1a2 100644 --- a/system/src/Grav/Console/Cli/CacheCommand.php +++ b/system/src/Grav/Console/Cli/CacheCommand.php @@ -15,9 +15,6 @@ use Symfony\Component\Console\Input\InputOption; class CacheCommand extends ConsoleCommand { - /** - * - */ protected function configure() { $this @@ -34,9 +31,6 @@ class CacheCommand extends ConsoleCommand ->setHelp('The cache command allows you to interact with Grav cache'); } - /** - * @return int|null|void - */ protected function serve() { $this->cleanPaths(); diff --git a/system/src/Grav/Console/Cli/CleanCommand.php b/system/src/Grav/Console/Cli/CleanCommand.php index 8db4a4fbb..4dd2b84cb 100644 --- a/system/src/Grav/Console/Cli/CleanCommand.php +++ b/system/src/Grav/Console/Cli/CleanCommand.php @@ -23,9 +23,7 @@ class CleanCommand extends Command /* @var OutputInterface $output */ protected $output; - /** - * @var array - */ + /** @var array */ protected $paths_to_remove = [ 'codeception.yml', 'tests/', @@ -250,9 +248,6 @@ class CleanCommand extends Command 'vendor/willdurand/negotiation/tests', ]; - /** - * - */ protected function configure() { $this @@ -264,8 +259,6 @@ class CleanCommand extends Command /** * @param InputInterface $input * @param OutputInterface $output - * - * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { diff --git a/system/src/Grav/Console/Cli/ComposerCommand.php b/system/src/Grav/Console/Cli/ComposerCommand.php index 1cd211b7d..ffb4e998c 100644 --- a/system/src/Grav/Console/Cli/ComposerCommand.php +++ b/system/src/Grav/Console/Cli/ComposerCommand.php @@ -14,26 +14,6 @@ use Symfony\Component\Console\Input\InputOption; class ComposerCommand extends ConsoleCommand { - /** - * @var - */ - protected $config; - /** - * @var - */ - protected $local_config; - /** - * @var - */ - protected $destination; - /** - * @var - */ - protected $user_path; - - /** - * - */ protected function configure() { $this @@ -54,9 +34,6 @@ class ComposerCommand extends ConsoleCommand ->setHelp('The composer command updates the composer vendor dependencies needed by Grav'); } - /** - * @return int|null|void - */ protected function serve() { $action = $this->input->getOption('install') ? 'install' : ($this->input->getOption('update') ? 'update' : 'install'); diff --git a/system/src/Grav/Console/Cli/InstallCommand.php b/system/src/Grav/Console/Cli/InstallCommand.php index 388173ea8..05f281e78 100644 --- a/system/src/Grav/Console/Cli/InstallCommand.php +++ b/system/src/Grav/Console/Cli/InstallCommand.php @@ -16,26 +16,18 @@ use Symfony\Component\Console\Input\InputOption; class InstallCommand extends ConsoleCommand { - /** - * @var - */ + /** @var array */ protected $config; - /** - * @var - */ + + /** @var array */ protected $local_config; - /** - * @var - */ + + /** @var string */ protected $destination; - /** - * @var - */ + + /** @var string */ protected $user_path; - /** - * - */ protected function configure() { $this @@ -55,9 +47,6 @@ class InstallCommand extends ConsoleCommand ->setHelp('The install command installs the dependencies needed by Grav. Optionally can create symbolic links'); } - /** - * @return int|null|void - */ protected function serve() { $dependencies_file = '.dependencies'; diff --git a/system/src/Grav/Console/Cli/LogViewerCommand.php b/system/src/Grav/Console/Cli/LogViewerCommand.php index 77c9e96dd..f9e93a3ec 100644 --- a/system/src/Grav/Console/Cli/LogViewerCommand.php +++ b/system/src/Grav/Console/Cli/LogViewerCommand.php @@ -9,7 +9,6 @@ namespace Grav\Console\Cli; - use Grav\Common\Grav; use Grav\Common\Helpers\LogViewer; use Grav\Common\Utils; @@ -39,9 +38,6 @@ class LogViewerCommand extends ConsoleCommand ->setHelp("Display the last few entries of Grav log"); } - /** - * @return int|null|void - */ protected function serve() { $grav = Grav::instance(); diff --git a/system/src/Grav/Console/Cli/NewProjectCommand.php b/system/src/Grav/Console/Cli/NewProjectCommand.php index 9901afd34..90583f0e1 100644 --- a/system/src/Grav/Console/Cli/NewProjectCommand.php +++ b/system/src/Grav/Console/Cli/NewProjectCommand.php @@ -16,9 +16,6 @@ use Symfony\Component\Console\Input\InputOption; class NewProjectCommand extends ConsoleCommand { - /** - * - */ protected function configure() { $this @@ -39,9 +36,6 @@ class NewProjectCommand extends ConsoleCommand ->setHelp("The new-project command is a combination of the `setup` and `install` commands.\nCreates a new Grav instance and performs the installation of all the required dependencies."); } - /** - * @return int|null|void - */ protected function serve() { $sandboxCommand = $this->getApplication()->find('sandbox'); @@ -61,6 +55,5 @@ class NewProjectCommand extends ConsoleCommand $sandboxCommand->run($sandboxArguments, $this->output); $installCommand->run($installArguments, $this->output); - } } diff --git a/system/src/Grav/Console/Cli/SandboxCommand.php b/system/src/Grav/Console/Cli/SandboxCommand.php index 2786b9268..f96141287 100644 --- a/system/src/Grav/Console/Cli/SandboxCommand.php +++ b/system/src/Grav/Console/Cli/SandboxCommand.php @@ -16,9 +16,7 @@ use Symfony\Component\Console\Input\InputOption; class SandboxCommand extends ConsoleCommand { - /** - * @var array - */ + /** @var array */ protected $directories = [ '/assets', '/backup', @@ -34,9 +32,7 @@ class SandboxCommand extends ConsoleCommand '/user/themes', ]; - /** - * @var array - */ + /** @var array */ protected $files = [ '/.dependencies', '/.htaccess', @@ -44,9 +40,7 @@ class SandboxCommand extends ConsoleCommand '/user/config/system.yaml', ]; - /** - * @var array - */ + /** @var array */ protected $mappings = [ '/.gitignore' => '/.gitignore', '/.editorconfig' => '/.editorconfig', @@ -62,18 +56,12 @@ class SandboxCommand extends ConsoleCommand '/webserver-configs' => '/webserver-configs', ]; - /** - * @var string - */ - + /** @var string */ protected $default_file = "---\ntitle: HomePage\n---\n# HomePage\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque porttitor eu felis sed ornare. Sed a mauris venenatis, pulvinar velit vel, dictum enim. Phasellus ac rutrum velit. Nunc lorem purus, hendrerit sit amet augue aliquet, iaculis ultricies nisl. Suspendisse tincidunt euismod risus, quis feugiat arcu tincidunt eget. Nulla eros mi, commodo vel ipsum vel, aliquet congue odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Pellentesque velit orci, laoreet at adipiscing eu, interdum quis nibh. Nunc a accumsan purus."; protected $source; protected $destination; - /** - * - */ protected function configure() { $this @@ -94,9 +82,6 @@ class SandboxCommand extends ConsoleCommand $this->source = getcwd(); } - /** - * @return int|null|void - */ protected function serve() { $this->destination = $this->input->getArgument('destination'); @@ -123,9 +108,6 @@ class SandboxCommand extends ConsoleCommand $this->perms(); } - /** - * - */ private function createDirectories() { $this->output->writeln(''); @@ -149,9 +131,6 @@ class SandboxCommand extends ConsoleCommand } } - /** - * - */ private function copy() { $this->output->writeln(''); @@ -171,9 +150,6 @@ class SandboxCommand extends ConsoleCommand } } - /** - * - */ private function symlink() { $this->output->writeln(''); @@ -199,9 +175,6 @@ class SandboxCommand extends ConsoleCommand } } - /** - * - */ private function initFiles() { $this->check(); @@ -231,9 +204,6 @@ class SandboxCommand extends ConsoleCommand } } - /** - * - */ private function pages() { $this->output->writeln(''); @@ -251,9 +221,6 @@ class SandboxCommand extends ConsoleCommand } } - /** - * - */ private function perms() { $this->output->writeln(''); @@ -271,9 +238,6 @@ class SandboxCommand extends ConsoleCommand $this->output->writeln(""); } - /** - * - */ private function check() { $success = true; diff --git a/system/src/Grav/Console/Cli/SchedulerCommand.php b/system/src/Grav/Console/Cli/SchedulerCommand.php index 9ff93e201..eaf45cdd5 100644 --- a/system/src/Grav/Console/Cli/SchedulerCommand.php +++ b/system/src/Grav/Console/Cli/SchedulerCommand.php @@ -47,9 +47,6 @@ class SchedulerCommand extends ConsoleCommand ->setHelp("Running without any options will force the Scheduler to run through it's jobs and process them"); } - /** - * @return int|null|void - */ protected function serve() { // error_reporting(1); diff --git a/system/src/Grav/Console/Cli/SecurityCommand.php b/system/src/Grav/Console/Cli/SecurityCommand.php index 070b14d3e..7f7308653 100644 --- a/system/src/Grav/Console/Cli/SecurityCommand.php +++ b/system/src/Grav/Console/Cli/SecurityCommand.php @@ -22,9 +22,6 @@ class SecurityCommand extends ConsoleCommand protected $source; - /** - * - */ protected function configure() { $this @@ -35,9 +32,6 @@ class SecurityCommand extends ConsoleCommand $this->source = getcwd(); } - /** - * @return int|null|void - */ protected function serve() { /** @var Grav $grav */ @@ -87,7 +81,7 @@ class SecurityCommand extends ConsoleCommand } /** - * @param $args + * @param array $args */ public function outputProgress($args) { diff --git a/system/src/Grav/Console/ConsoleTrait.php b/system/src/Grav/Console/ConsoleTrait.php index c50a30a51..d3e2633c7 100644 --- a/system/src/Grav/Console/ConsoleTrait.php +++ b/system/src/Grav/Console/ConsoleTrait.php @@ -22,9 +22,6 @@ use Symfony\Component\Console\Output\OutputInterface; trait ConsoleTrait { - /** - * @var - */ protected $argv; /* @var InputInterface $output */ @@ -62,7 +59,7 @@ trait ConsoleTrait } /** - * @param $path + * @param string $path */ public function isGravInstance($path) { diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php index 1554fe53a..bd2765162 100644 --- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php +++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php @@ -22,12 +22,12 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; class DirectInstallCommand extends ConsoleCommand { + /** @var string */ protected $all_yes; + + /** @var string */ protected $destination; - /** - * - */ protected function configure() { $this diff --git a/system/src/Grav/Console/Gpm/IndexCommand.php b/system/src/Grav/Console/Gpm/IndexCommand.php index fdefec7cf..06d662bd9 100644 --- a/system/src/Grav/Console/Gpm/IndexCommand.php +++ b/system/src/Grav/Console/Gpm/IndexCommand.php @@ -9,7 +9,9 @@ namespace Grav\Console\Gpm; +use Grav\Common\GPM\Remote\Package; use Grav\Common\GPM\GPM; +use Grav\Common\GPM\Remote\Packages; use Grav\Common\Utils; use Grav\Console\ConsoleCommand; use League\CLImate\CLImate; @@ -17,28 +19,18 @@ use Symfony\Component\Console\Input\InputOption; class IndexCommand extends ConsoleCommand { - /** - * @var - */ + /** @var array */ protected $data; - /** - * @var - */ + + /** @var GPM */ protected $gpm; - /** - * @var - */ + /** @var array */ protected $options; - /** - * @var array - */ + /** @var array */ protected $sortKeys = ['name', 'slug', 'author', 'date']; - /** - * - */ protected function configure() { $this @@ -97,9 +89,6 @@ class IndexCommand extends ConsoleCommand ; } - /** - * @return int|null|void - */ protected function serve() { $this->options = $this->input->getOptions(); @@ -158,7 +147,7 @@ class IndexCommand extends ConsoleCommand } /** - * @param $package + * @param Package $package * * @return string */ @@ -184,7 +173,7 @@ class IndexCommand extends ConsoleCommand } /** - * @param $package + * @param Package $package * * @return string */ @@ -199,7 +188,7 @@ class IndexCommand extends ConsoleCommand } /** - * @param $data + * @param array $data * * @return mixed */ @@ -255,7 +244,7 @@ class IndexCommand extends ConsoleCommand } /** - * @param $packages + * @param Packages $packages */ public function sort($packages) { diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php index 64a5bd967..ee8958405 100644 --- a/system/src/Grav/Console/Gpm/InfoCommand.php +++ b/system/src/Grav/Console/Gpm/InfoCommand.php @@ -17,15 +17,13 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; class InfoCommand extends ConsoleCommand { - /** - * @var - */ + /** @var array */ protected $data; - /** - * @var - */ + + /** @var GPM */ protected $gpm; + /** @var string */ protected $all_yes; /** diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index 021404cb5..840ee5b2e 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -14,7 +14,7 @@ use Grav\Common\GPM\GPM; use Grav\Common\GPM\Installer; use Grav\Common\GPM\Licenses; use Grav\Common\GPM\Response; -use Grav\Common\GPM\Remote\Package as Package; +use Grav\Common\GPM\Remote\Package; use Grav\Common\Grav; use Grav\Common\Utils; use Grav\Console\ConsoleCommand; @@ -26,22 +26,22 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; class InstallCommand extends ConsoleCommand { - /** @var */ + /** @var array */ protected $data; /** @var GPM */ protected $gpm; - /** @var */ + /** @var string */ protected $destination; - /** @var */ + /** @var string */ protected $file; - /** @var */ + /** @var string */ protected $tmp; - /** @var */ + /** @var array */ protected $local_config; /** @var bool */ @@ -50,11 +50,9 @@ class InstallCommand extends ConsoleCommand /** @var array */ protected $demo_processing = []; + /** @var string */ protected $all_yes; - /** - * - */ protected function configure() { $this @@ -90,9 +88,9 @@ class InstallCommand extends ConsoleCommand /** * Allows to set the GPM object, used for testing the class * - * @param $gpm + * @param GPM $gpm */ - public function setGpm($gpm) + public function setGpm(GPM $gpm) { $this->gpm = $gpm; } @@ -232,7 +230,7 @@ class InstallCommand extends ConsoleCommand /** * If the package is updated from an older major release, show warning and ask confirmation * - * @param $package + * @param Package $package */ public function askConfirmationIfMajorVersionUpdated($package) { @@ -320,8 +318,8 @@ class InstallCommand extends ConsoleCommand } /** - * @param $package - * @param bool $is_update True if the package is an update + * @param Package $package + * @param bool $is_update True if the package is an update */ private function processPackage($package, $is_update = false) { @@ -346,7 +344,7 @@ class InstallCommand extends ConsoleCommand /** * Add package to the queue to process the demo content, if demo content exists * - * @param $package + * @param Package $package */ private function processDemo($package) { @@ -359,7 +357,7 @@ class InstallCommand extends ConsoleCommand /** * Prompt to install the demo content of a package * - * @param $package + * @param Package $package */ private function installDemoContent($package) { @@ -415,7 +413,7 @@ class InstallCommand extends ConsoleCommand } /** - * @param $package + * @param Package $package * * @return array|bool */ @@ -433,7 +431,7 @@ class InstallCommand extends ConsoleCommand } /** - * @param $package + * @param Package $package * * @return bool|string */ @@ -462,7 +460,7 @@ class InstallCommand extends ConsoleCommand } /** - * @param $package + * @param Package $package */ private function processSymlink($package) { @@ -506,8 +504,8 @@ class InstallCommand extends ConsoleCommand } /** - * @param $package - * @param bool $is_update + * @param Package $package + * @param bool $is_update * * @return bool */ @@ -603,7 +601,7 @@ class InstallCommand extends ConsoleCommand } /** - * @param $package + * @param Package $package * * @return bool */ @@ -682,7 +680,7 @@ class InstallCommand extends ConsoleCommand } /** - * @param $progress + * @param array $progress */ public function progress($progress) { diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index 33b771baa..1562f4b66 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -12,6 +12,7 @@ namespace Grav\Console\Gpm; use Grav\Common\Cache; use Grav\Common\Filesystem\Folder; use Grav\Common\GPM\Installer; +use Grav\Common\GPM\Remote\Package; use Grav\Common\GPM\Response; use Grav\Common\GPM\Upgrader; use Grav\Common\Grav; @@ -22,41 +23,29 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; class SelfupgradeCommand extends ConsoleCommand { - /** - * @var - */ + /** @var array */ protected $data; - /** - * @var - */ + protected $extensions; - /** - * @var - */ + protected $updatable; - /** - * @var - */ + + /** @var string */ protected $file; - /** - * @var array - */ + + /** @var array */ protected $types = ['plugins', 'themes']; - /** - * @var - */ + + /** @var string */ private $tmp; - /** - * @var - */ + private $upgrader; + /** @var string */ protected $all_yes; + protected $overwrite; - /** - * - */ protected function configure() { $this @@ -84,9 +73,6 @@ class SelfupgradeCommand extends ConsoleCommand ->setHelp('The update command updates Grav itself when a new version is available'); } - /** - * @return int|null|void - */ protected function serve() { $this->upgrader = new Upgrader($this->input->getOption('force')); @@ -191,7 +177,7 @@ class SelfupgradeCommand extends ConsoleCommand } /** - * @param $package + * @param Package $package * * @return string */ @@ -248,7 +234,7 @@ class SelfupgradeCommand extends ConsoleCommand } /** - * @param $progress + * @param array $progress */ public function progress($progress) { @@ -258,7 +244,7 @@ class SelfupgradeCommand extends ConsoleCommand } /** - * @param $size + * @param int|float $size * @param int $precision * * @return string diff --git a/system/src/Grav/Console/Gpm/UninstallCommand.php b/system/src/Grav/Console/Gpm/UninstallCommand.php index 561420924..99fc81ab0 100644 --- a/system/src/Grav/Console/Gpm/UninstallCommand.php +++ b/system/src/Grav/Console/Gpm/UninstallCommand.php @@ -11,6 +11,7 @@ namespace Grav\Console\Gpm; use Grav\Common\GPM\GPM; use Grav\Common\GPM\Installer; +use Grav\Common\GPM\Remote\Package; use Grav\Common\Grav; use Grav\Console\ConsoleCommand; use Symfony\Component\Console\Input\InputArgument; @@ -19,34 +20,27 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; class UninstallCommand extends ConsoleCommand { - /** - * @var - */ + /** @var array */ protected $data; /** @var GPM */ protected $gpm; - /** - * @var - */ + /** @var string */ protected $destination; - /** - * @var - */ + + /** @var string */ protected $file; - /** - * @var - */ + + /** @var string */ protected $tmp; - protected $dependencies= []; + /** @var array */ + protected $dependencies = []; + /** @var string */ protected $all_yes; - /** - * - */ protected function configure() { $this @@ -66,9 +60,6 @@ class UninstallCommand extends ConsoleCommand ->setHelp('The uninstall command allows to uninstall plugins and themes'); } - /** - * @return int|null|void - */ protected function serve() { $this->gpm = new GPM(); @@ -78,16 +69,18 @@ class UninstallCommand extends ConsoleCommand $packages = array_map('strtolower', $this->input->getArgument('package')); $this->data = ['total' => 0, 'not_found' => []]; + $total = 0; foreach ($packages as $package) { $plugin = $this->gpm->getInstalledPlugin($package); $theme = $this->gpm->getInstalledTheme($package); if ($plugin || $theme) { $this->data[strtolower($package)] = $plugin ?: $theme; - $this->data['total']++; + $total++; } else { $this->data['not_found'][] = $package; } } + $this->data['total'] = $total; $this->output->writeln(''); @@ -131,8 +124,8 @@ class UninstallCommand extends ConsoleCommand /** - * @param $slug - * @param $package + * @param string $slug + * @param Package $package * * @return bool */ @@ -247,8 +240,8 @@ class UninstallCommand extends ConsoleCommand } /** - * @param $slug - * @param $package + * @param string $slug + * @param Package $package * * @return bool */ @@ -289,8 +282,8 @@ class UninstallCommand extends ConsoleCommand /** * Check if package exists * - * @param $slug - * @param $package + * @param string $slug + * @param Package $package * @return int */ private function packageExists($slug, $package) diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php index 2187fede3..d8ea735d7 100644 --- a/system/src/Grav/Console/Gpm/UpdateCommand.php +++ b/system/src/Grav/Console/Gpm/UpdateCommand.php @@ -20,47 +20,33 @@ use Symfony\Component\Console\Question\ConfirmationQuestion; class UpdateCommand extends ConsoleCommand { - /** - * @var - */ + /** @var array */ protected $data; - /** - * @var - */ + protected $extensions; - /** - * @var - */ + protected $updatable; - /** - * @var - */ + + /** @var string */ protected $destination; - /** - * @var - */ + + /** @var string */ protected $file; - /** - * @var array - */ + + /** @var array */ protected $types = ['plugins', 'themes']; - /** - * @var GPM $gpm - */ + + /** @var GPM */ protected $gpm; + /** @var string */ protected $all_yes; protected $overwrite; - /** - * @var Upgrader - */ + /** @var Upgrader */ protected $upgrader; - /** - * - */ protected function configure() { $this @@ -111,9 +97,6 @@ class UpdateCommand extends ConsoleCommand ->setHelp('The update command updates plugins and themes when a new version is available'); } - /** - * @return int|null|void - */ protected function serve() { $this->upgrader = new Upgrader($this->input->getOption('force')); @@ -234,7 +217,7 @@ class UpdateCommand extends ConsoleCommand } /** - * @param $only_packages + * @param array $only_packages * * @return array */ diff --git a/system/src/Grav/Console/Gpm/VersionCommand.php b/system/src/Grav/Console/Gpm/VersionCommand.php index df70e4675..becc3274c 100644 --- a/system/src/Grav/Console/Gpm/VersionCommand.php +++ b/system/src/Grav/Console/Gpm/VersionCommand.php @@ -18,14 +18,9 @@ use Symfony\Component\Console\Input\InputOption; class VersionCommand extends ConsoleCommand { - /** - * @var GPM - */ + /** @var GPM */ protected $gpm; - /** - * - */ protected function configure() { $this diff --git a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php index 83097d550..9e7946a2a 100644 --- a/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php +++ b/system/src/Grav/Framework/Psr7/Traits/UriDecorationTrait.php @@ -65,7 +65,7 @@ trait UriDecorationTrait public function withScheme($scheme): UriInterface { - /** @var UriInterface $new */ + /** @var UriInterface|UriDecorationTrait $new */ $new = clone $this; $new->uri = $this->uri->withScheme($scheme); @@ -74,7 +74,7 @@ trait UriDecorationTrait public function withUserInfo($user, $password = null): UriInterface { - /** @var UriInterface $new */ + /** @var UriInterface|UriDecorationTrait $new */ $new = clone $this; $new->uri = $this->uri->withUserInfo($user, $password); @@ -83,7 +83,7 @@ trait UriDecorationTrait public function withHost($host): UriInterface { - /** @var UriInterface $new */ + /** @var UriInterface|UriDecorationTrait $new */ $new = clone $this; $new->uri = $this->uri->withHost($host); @@ -92,7 +92,7 @@ trait UriDecorationTrait public function withPort($port): UriInterface { - /** @var UriInterface $new */ + /** @var UriInterface|UriDecorationTrait $new */ $new = clone $this; $new->uri = $this->uri->withPort($port); @@ -101,7 +101,7 @@ trait UriDecorationTrait public function withPath($path): UriInterface { - /** @var UriInterface $new */ + /** @var UriInterface|UriDecorationTrait $new */ $new = clone $this; $new->uri = $this->uri->withPath($path); @@ -110,7 +110,7 @@ trait UriDecorationTrait public function withQuery($query): UriInterface { - /** @var UriInterface $new */ + /** @var UriInterface|UriDecorationTrait $new */ $new = clone $this; $new->uri = $this->uri->withQuery($query); @@ -119,7 +119,7 @@ trait UriDecorationTrait public function withFragment($fragment): UriInterface { - /** @var UriInterface $new */ + /** @var UriInterface|UriDecorationTrait $new */ $new = clone $this; $new->uri = $this->uri->withFragment($fragment); diff --git a/tests/phpstan/phpstan.neon b/tests/phpstan/phpstan.neon index f6883aa13..753425b85 100644 --- a/tests/phpstan/phpstan.neon +++ b/tests/phpstan/phpstan.neon @@ -8,6 +8,15 @@ parameters: excludes_analyse: - system/src/Grav/Common/Errors/Resources/layout.html.php reportUnmatchedIgnoredErrors: false + universalObjectCratesClasses: + - Grav\Common\Config\Config + - Grav\Common\Config\Languages + - Grav\Common\Config\Setup + - Grav\Common\Data\Data + - Grav\Common\GPM\Common\Package + - Grav\Common\GPM\Local\Package + - Grav\Common\GPM\Remote\Package + - Grav\Common\Session ignoreErrors: # Errors that needs some more thinking (design...)