Skip to content

Commit

Permalink
phpstan fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Dec 16, 2019
1 parent 4a20ad8 commit 0ff31bf
Show file tree
Hide file tree
Showing 51 changed files with 148 additions and 218 deletions.
8 changes: 0 additions & 8 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
parameters:
excludes_analyse:
- %rootDir%/../../../public/main/admin/db.php
- %rootDir%/../../../public/main/extra/*
- %rootDir%/../../../public/main/cron/*
- %rootDir%/../../../public/main/inc/lib/pear/*
- %rootDir%/../../../public/main/inc/lib/nusoap/*
- %rootDir%/../../../public/main/inc/lib/search/*
- %rootDir%/../../../public/main/webservices/*
- %rootDir%/../../../src/CoreBundle/Migrations/Schema/*
- %rootDir%/../../../tests/*
level: max
4 changes: 3 additions & 1 deletion src/Command/Common/ChamiloEmailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ protected function configure(): void
}

/**
* @return int|void|null
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$configuration = $input->getOption('conf');
$this->getHelper('configuration')->readConfigurationFile($configuration);

return 0;
}
}
15 changes: 0 additions & 15 deletions src/Command/Common/ChamiloUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@

namespace Chash\Command\Common;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ChamiloUserCommand extends DatabaseCommand
{
protected function configure(): void
{
parent::configure();
}

/**
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
parent::execute($input, $output);
}
}
7 changes: 4 additions & 3 deletions src/Command/Common/CommonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ public function getRootSys()
}

/**
* @return string
* @return null|string
*/
public function getCourseSysPath()
public function getCourseSysPath(): ?string
{
if (is_dir($this->getRootSys().'courses')) {
return $this->getRootSys().'courses';
Expand Down Expand Up @@ -636,7 +636,7 @@ public function setRootSysDependingConfigurationPath($path)
* @param string $path
* @param object $output Output handler to print info messages
*
* @return bool
* @return bool|int
*/
public function writeConfiguration($version, $path, $output)
{
Expand Down Expand Up @@ -1241,6 +1241,7 @@ public function copyConfigFilesToNewLocation(OutputInterface $output)

/**
* @param $path
* @param bool|null|string|string[] $path
*/
public function removeUnUsedFiles(OutputInterface $output, $path)
{
Expand Down
9 changes: 4 additions & 5 deletions src/Command/Common/DatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ protected function configure(): void
);
}

/**
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$configurationFile = $input->getOption('conf');
Expand Down Expand Up @@ -103,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
'<comment>Try</comment> <info>prefix:command --conf=/var/www/chamilo/config/configuration.php</info>'
);

return false;
return 0;
}
}
}
Expand Down Expand Up @@ -135,5 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// Setting doctrine connection
$this->setDatabaseSettings($databaseSettings);
$this->setDoctrineSettings($this->getHelperSet());

return 0;
}
}
7 changes: 3 additions & 4 deletions src/Command/Common/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ protected function configure(): void
);
}

/**
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$configuration = $input->getOption('conf');
$this->getHelper('configuration')->readConfigurationFile($configuration);

return 0;
}
}
6 changes: 4 additions & 2 deletions src/Command/Database/DropDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ protected function configure(): void
}

/**
* @return int|void|null
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);

Expand Down Expand Up @@ -62,5 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$output->writeln("<comment>Can't established connection with the database. Probably it was already deleted.</comment>");
}

return 0;
}
}
7 changes: 2 additions & 5 deletions src/Command/Database/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ protected function configure(): void
->setDescription('Outputs a dump of the database');
}

/**
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$_configuration = $this->getConfigurationArray();
$dump = 'mysqldump -h '.$_configuration['db_host'].' -u '.$_configuration['db_user'].' -p'.$_configuration['db_password'].' '.$_configuration['main_database'];
system($dump);

return null;
return 0;
}
}
7 changes: 3 additions & 4 deletions src/Command/Database/FullBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ protected function configure(): void
);
}

/**
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);

Expand Down Expand Up @@ -107,5 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(
'<comment>End Chamilo backup. File can be found here: '.realpath($resultPath).' </comment>'
);

return 0;
}
}
5 changes: 2 additions & 3 deletions src/Command/Database/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ protected function configure(): void
);
}

/**
* @see Console\Command\Command
*/
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
{
$conn = $this->getHelper('db')->getConnection();
Expand Down Expand Up @@ -117,5 +114,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
}
}
}

return 0;
}
}
6 changes: 4 additions & 2 deletions src/Command/Database/RestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ protected function configure(): void
}

/**
* @return int|void|null
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$dumpPath = $input->getArgument('file');
Expand All @@ -48,5 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$output->writeln('<comment>File is not a valid SQL file: '.$dumpPath.' </comment>');
}

return 0;
}
}
7 changes: 3 additions & 4 deletions src/Command/Database/RunSQLCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ protected function configure(): void
$this->setHelp('Prompts a SQL cli');
}

/**
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$output->writeln('Starting Chamilo SQL cli');
Expand Down Expand Up @@ -60,5 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
// Inside execute function
//$output->getFormatter()->setStyle('fcbarcelona', new OutputFormatterStyle('red', 'blue', array('blink', 'bold', 'underscore')));
//$output->writeln('<fcbarcelona>Messi for the win</fcbarcelona>');

return 0;
}
}
6 changes: 4 additions & 2 deletions src/Command/Database/SQLCountCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ protected function configure(): void
/**
* @todo use doctrine
*
* @return int|void|null
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$table = $input->getArgument('table');
Expand All @@ -52,5 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
"<comment>Table '$table' does not exists in the database: ".$_configuration['main_database']
);
}

return 0;
}
}
7 changes: 3 additions & 4 deletions src/Command/Database/ShowConnInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ protected function configure(): void
->setDescription('Shows database connection credentials for the current Chamilo install');
}

/**
* @return int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);

Expand All @@ -45,5 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln("DB:\t".$_configuration['main_database']);
$output->writeln('Connection string (add password manually for increased security:');
$output->writeln('mysql -h '.$_configuration['db_host'].' -u '.$_configuration['db_user'].' -p '.$_configuration['main_database']."\n");

return 0;
}
}
7 changes: 2 additions & 5 deletions src/Command/Email/SendEmailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ protected function configure(): void
);
}

/**
* @return void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$mailLib = $this->getHelper('configuration')->getLibFile('mail.lib.inc.php');
Expand Down Expand Up @@ -135,6 +132,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

return null;
return 0;
}
}
6 changes: 4 additions & 2 deletions src/Command/Files/CleanConfigFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ protected function configure(): void
}

/**
* @return int|void|null
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$this->writeCommandHeader($output, 'Cleaning config files.');
Expand All @@ -39,5 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$files = $this->getConfigurationHelper()->getConfigFiles();
$this->removeFiles($files, $output);

return 0;
}
}
7 changes: 3 additions & 4 deletions src/Command/Files/CleanCoursesFilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ protected function configure(): void
->setDescription('Cleans the courses directory');
}

/**
* @return bool|int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$this->writeCommandHeader($output, 'Cleaning folders in courses directory.');
Expand All @@ -40,5 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$files = $this->getConfigurationHelper()->getCoursesFiles();
$this->removeFiles($files, $output);

return 0;
}
}
7 changes: 3 additions & 4 deletions src/Command/Files/CleanDeletedDocumentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ protected function configure(): void
;
}

/**
* @return bool|int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$category = $input->getOption('category');
Expand Down Expand Up @@ -123,5 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
$this->removeFiles($files, $output);

return 0;
}
}
7 changes: 3 additions & 4 deletions src/Command/Files/CleanTempFolderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ protected function configure(): void
->setDescription('Cleans the temp directory.');
}

/**
* @return bool|int|void|null
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
$this->writeCommandHeader($output, 'Cleaning temp files.');
Expand All @@ -38,5 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$files = $this->getConfigurationHelper()->getTempFiles();
$this->removeFiles($files, $output);

return 0;
}
}
Loading

0 comments on commit 0ff31bf

Please sign in to comment.