diff --git a/phpstan.neon b/phpstan.neon index 8b17dd9..714bc68 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -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 \ No newline at end of file diff --git a/src/Command/Common/ChamiloEmailCommand.php b/src/Command/Common/ChamiloEmailCommand.php index 85e711b..51f7fbd 100644 --- a/src/Command/Common/ChamiloEmailCommand.php +++ b/src/Command/Common/ChamiloEmailCommand.php @@ -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; } } diff --git a/src/Command/Common/ChamiloUserCommand.php b/src/Command/Common/ChamiloUserCommand.php index ec0b3ef..b14c5e5 100644 --- a/src/Command/Common/ChamiloUserCommand.php +++ b/src/Command/Common/ChamiloUserCommand.php @@ -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); - } } diff --git a/src/Command/Common/CommonCommand.php b/src/Command/Common/CommonCommand.php index c895199..0c02710 100644 --- a/src/Command/Common/CommonCommand.php +++ b/src/Command/Common/CommonCommand.php @@ -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'; @@ -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) { @@ -1241,6 +1241,7 @@ public function copyConfigFilesToNewLocation(OutputInterface $output) /** * @param $path + * @param bool|null|string|string[] $path */ public function removeUnUsedFiles(OutputInterface $output, $path) { diff --git a/src/Command/Common/DatabaseCommand.php b/src/Command/Common/DatabaseCommand.php index 691fc0b..1882dd3 100644 --- a/src/Command/Common/DatabaseCommand.php +++ b/src/Command/Common/DatabaseCommand.php @@ -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'); @@ -103,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output) 'Try prefix:command --conf=/var/www/chamilo/config/configuration.php' ); - return false; + return 0; } } } @@ -135,5 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // Setting doctrine connection $this->setDatabaseSettings($databaseSettings); $this->setDoctrineSettings($this->getHelperSet()); + + return 0; } } diff --git a/src/Command/Common/InfoCommand.php b/src/Command/Common/InfoCommand.php index 93827d0..3ed2ad8 100644 --- a/src/Command/Common/InfoCommand.php +++ b/src/Command/Common/InfoCommand.php @@ -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; } } diff --git a/src/Command/Database/DropDatabaseCommand.php b/src/Command/Database/DropDatabaseCommand.php index 27e49a4..d4bc08f 100644 --- a/src/Command/Database/DropDatabaseCommand.php +++ b/src/Command/Database/DropDatabaseCommand.php @@ -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); @@ -62,5 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln("Can't established connection with the database. Probably it was already deleted."); } + + return 0; } } diff --git a/src/Command/Database/DumpCommand.php b/src/Command/Database/DumpCommand.php index 0c2b98b..0c15744 100644 --- a/src/Command/Database/DumpCommand.php +++ b/src/Command/Database/DumpCommand.php @@ -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; } } diff --git a/src/Command/Database/FullBackupCommand.php b/src/Command/Database/FullBackupCommand.php index b699efa..95ef104 100644 --- a/src/Command/Database/FullBackupCommand.php +++ b/src/Command/Database/FullBackupCommand.php @@ -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); @@ -107,5 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln( 'End Chamilo backup. File can be found here: '.realpath($resultPath).' ' ); + + return 0; } } diff --git a/src/Command/Database/ImportCommand.php b/src/Command/Database/ImportCommand.php index 379a7fe..38c8d10 100644 --- a/src/Command/Database/ImportCommand.php +++ b/src/Command/Database/ImportCommand.php @@ -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(); @@ -117,5 +114,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O } } } + + return 0; } } diff --git a/src/Command/Database/RestoreCommand.php b/src/Command/Database/RestoreCommand.php index 29d4b51..2070700 100644 --- a/src/Command/Database/RestoreCommand.php +++ b/src/Command/Database/RestoreCommand.php @@ -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'); @@ -48,5 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('File is not a valid SQL file: '.$dumpPath.' '); } + + return 0; } } diff --git a/src/Command/Database/RunSQLCommand.php b/src/Command/Database/RunSQLCommand.php index 468a874..4754286 100644 --- a/src/Command/Database/RunSQLCommand.php +++ b/src/Command/Database/RunSQLCommand.php @@ -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'); @@ -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('Messi for the win'); + + return 0; } } diff --git a/src/Command/Database/SQLCountCommand.php b/src/Command/Database/SQLCountCommand.php index b723679..eb548d8 100644 --- a/src/Command/Database/SQLCountCommand.php +++ b/src/Command/Database/SQLCountCommand.php @@ -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'); @@ -52,5 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output) "Table '$table' does not exists in the database: ".$_configuration['main_database'] ); } + + return 0; } } diff --git a/src/Command/Database/ShowConnInfoCommand.php b/src/Command/Database/ShowConnInfoCommand.php index 0f080a7..64dbd67 100644 --- a/src/Command/Database/ShowConnInfoCommand.php +++ b/src/Command/Database/ShowConnInfoCommand.php @@ -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); @@ -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; } } diff --git a/src/Command/Email/SendEmailCommand.php b/src/Command/Email/SendEmailCommand.php index 0f8a7d2..2a139d1 100644 --- a/src/Command/Email/SendEmailCommand.php +++ b/src/Command/Email/SendEmailCommand.php @@ -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'); @@ -135,6 +132,6 @@ protected function execute(InputInterface $input, OutputInterface $output) } } - return null; + return 0; } } diff --git a/src/Command/Files/CleanConfigFilesCommand.php b/src/Command/Files/CleanConfigFilesCommand.php index 10ef6a4..1c231ea 100644 --- a/src/Command/Files/CleanConfigFilesCommand.php +++ b/src/Command/Files/CleanConfigFilesCommand.php @@ -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.'); @@ -39,5 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $files = $this->getConfigurationHelper()->getConfigFiles(); $this->removeFiles($files, $output); + + return 0; } } diff --git a/src/Command/Files/CleanCoursesFilesCommand.php b/src/Command/Files/CleanCoursesFilesCommand.php index 9f73c45..37f6421 100644 --- a/src/Command/Files/CleanCoursesFilesCommand.php +++ b/src/Command/Files/CleanCoursesFilesCommand.php @@ -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.'); @@ -40,5 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $files = $this->getConfigurationHelper()->getCoursesFiles(); $this->removeFiles($files, $output); + + return 0; } } diff --git a/src/Command/Files/CleanDeletedDocumentsCommand.php b/src/Command/Files/CleanDeletedDocumentsCommand.php index 76fef92..5177876 100644 --- a/src/Command/Files/CleanDeletedDocumentsCommand.php +++ b/src/Command/Files/CleanDeletedDocumentsCommand.php @@ -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'); @@ -123,5 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } } $this->removeFiles($files, $output); + + return 0; } } diff --git a/src/Command/Files/CleanTempFolderCommand.php b/src/Command/Files/CleanTempFolderCommand.php index ac5d812..1305c74 100644 --- a/src/Command/Files/CleanTempFolderCommand.php +++ b/src/Command/Files/CleanTempFolderCommand.php @@ -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.'); @@ -38,5 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } $files = $this->getConfigurationHelper()->getTempFiles(); $this->removeFiles($files, $output); + + return 0; } } diff --git a/src/Command/Files/ConvertVideosCommand.php b/src/Command/Files/ConvertVideosCommand.php index 06e665f..745b96c 100644 --- a/src/Command/Files/ConvertVideosCommand.php +++ b/src/Command/Files/ConvertVideosCommand.php @@ -59,10 +59,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); @@ -176,5 +173,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $output->writeln('Total size of old videos combined: '.round($sizeOrig / (1024 * 1024)).'M'); $output->writeln('Total size of all new videos combined: '.round($sizeNew / (1024 * 1024)).'M'); //$this->removeFiles($files, $output); + + return 0; } } diff --git a/src/Command/Files/DeleteCoursesCommand.php b/src/Command/Files/DeleteCoursesCommand.php index b56f972..2fcac0e 100644 --- a/src/Command/Files/DeleteCoursesCommand.php +++ b/src/Command/Files/DeleteCoursesCommand.php @@ -67,9 +67,9 @@ protected function configure(): void } /** - * @return bool|int|void|null + * @return void */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): void { parent::execute($input, $output); @@ -267,9 +267,9 @@ protected function execute(InputInterface $input, OutputInterface $output) * @param string $courseCode * @param int $urlId * - * @return bool + * @return void */ - private function unlinkCourse($input, OutputInterface $output, $courseCode, $urlId) + private function unlinkCourse(InputInterface $input, OutputInterface $output, $courseCode, $urlId): void { /* Check tables: * session, session_rel_course, session_rel_course_rel_user @@ -341,12 +341,12 @@ private function unlinkCourse($input, OutputInterface $output, $courseCode, $url * This operation follows the "unlink course" operation so that it just * completes it, but only in case the course is used only once. * - * @param object Output interface - * @param string Course code + * @param object Output interface + * @param string Course code * * @return bool */ - private function deleteCourse($input, OutputInterface $output, $courseCode) + private function deleteCourse(InputInterface $input, OutputInterface $output, $courseCode) { $connection = $this->getConnection($input); $sql = "SELECT id, directory FROM course WHERE code = '$courseCode'"; @@ -466,6 +466,6 @@ private function deleteCourse($input, OutputInterface $output, $courseCode) 'Deleted course '.$courseCode.' reference in course table.' ); - return true; + return 0; } } diff --git a/src/Command/Files/DeleteMultiUrlCommand.php b/src/Command/Files/DeleteMultiUrlCommand.php index d58c1ef..36b396b 100644 --- a/src/Command/Files/DeleteMultiUrlCommand.php +++ b/src/Command/Files/DeleteMultiUrlCommand.php @@ -62,9 +62,9 @@ protected function configure(): void } /** - * @return bool|int|void|null + * @return void */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): void { parent::execute($input, $output); @@ -266,9 +266,9 @@ protected function execute(InputInterface $input, OutputInterface $output) * @param string $courseCode * @param int $urlId * - * @return bool + * @return void */ - private function unlinkCourse($input, OutputInterface $output, $courseCode, $urlId) + private function unlinkCourse(InputInterface $input, OutputInterface $output, $courseCode, $urlId): void { /* Check tables: * session, session_rel_course, session_rel_course_rel_user @@ -343,12 +343,12 @@ private function unlinkCourse($input, OutputInterface $output, $courseCode, $url * This operation follows the "unlink course" operation so that it just * completes it, but only in case the course is used only once. * - * @param object Output interface - * @param string Course code + * @param object Output interface + * @param string Course code * * @return bool */ - private function deleteCourse($input, OutputInterface $output, $courseCode) + private function deleteCourse(InputInterface $input, OutputInterface $output, $courseCode) { $connection = $this->getConnection($input); $sql = "SELECT id, directory FROM course WHERE code = '$courseCode'"; @@ -470,14 +470,14 @@ private function deleteCourse($input, OutputInterface $output, $courseCode) * super-admins. Other roles should only be able to disable a user, * which removes access to the platform but doesn't delete anything. * - * @param object Output interface - * @param int User ID + * @param object Output interface + * @param int User ID * * @return bool * * @todo Use UserManager::delete_user() instead */ - private function deleteUser($input, OutputInterface $output, $userId) + private function deleteUser(InputInterface $input, OutputInterface $output, $userId) { // No validation of permissions or variables is done because Chash is // only for sysadmins anyway @@ -573,6 +573,6 @@ private function deleteUser($input, OutputInterface $output, $userId) //event_system(LOG_USER_DELETE, LOG_USER_OBJECT, $user_info, api_get_utc_datetime(), $user_id_manager, null, $user_info); $output->writeln('Removed user '.$userId); - return true; + return 0; } } diff --git a/src/Command/Files/GenerateTempFileStructureCommand.php b/src/Command/Files/GenerateTempFileStructureCommand.php index d6ed1c9..c64a4ce 100644 --- a/src/Command/Files/GenerateTempFileStructureCommand.php +++ b/src/Command/Files/GenerateTempFileStructureCommand.php @@ -17,9 +17,9 @@ class GenerateTempFileStructureCommand extends DatabaseCommand * @param array $files * @param $permission * - * @return int + * @return int|null */ - public function createFolders(OutputInterface $output, $files, $permission) + public function createFolders(OutputInterface $output, $files, int $permission): ?int { $dryRun = $this->getConfigurationHelper()->getDryRun(); @@ -58,9 +58,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, 'Generating temp folders.'); @@ -68,5 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // Data folders $files = $this->getConfigurationHelper()->getTempFolderList(); $this->createFolders($output, $files, 0777); + + return 0; } } diff --git a/src/Command/Files/MailConfCommand.php b/src/Command/Files/MailConfCommand.php index ca00210..9a5568c 100644 --- a/src/Command/Files/MailConfCommand.php +++ b/src/Command/Files/MailConfCommand.php @@ -21,7 +21,7 @@ protected function configure(): void } /** - * @return int|void|null + * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { @@ -54,5 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('Nothing to print'); } + + return 0; } } diff --git a/src/Command/Files/ReplaceURLCommand.php b/src/Command/Files/ReplaceURLCommand.php index f67b488..cdccf4b 100644 --- a/src/Command/Files/ReplaceURLCommand.php +++ b/src/Command/Files/ReplaceURLCommand.php @@ -32,10 +32,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); $search = $input->getArgument('search'); @@ -146,6 +143,8 @@ protected function execute(InputInterface $input, OutputInterface $output) 'No results found.' ); } + + return 0; } /** diff --git a/src/Command/Files/SetPermissionsAfterInstallCommand.php b/src/Command/Files/SetPermissionsAfterInstallCommand.php index 21a41df..99a7f37 100644 --- a/src/Command/Files/SetPermissionsAfterInstallCommand.php +++ b/src/Command/Files/SetPermissionsAfterInstallCommand.php @@ -19,17 +19,20 @@ class SetPermissionsAfterInstallCommand extends DatabaseCommand * @param $user * @param $group * @param bool $listFiles + * @param int|null $permission + * @param bool|null|string|string[] $user + * @param bool|null|string|string[] $group * - * @return int + * @return int|null */ public function setPermissions( OutputInterface $output, $files, - $permission, + ?int $permission, $user, $group, $listFiles = true - ) { + ): ?int { $dryRun = $this->getConfigurationHelper()->getDryRun(); if (empty($files)) { @@ -102,10 +105,7 @@ protected function configure(): void ->addOption('linux-group', null, InputOption::VALUE_OPTIONAL, 'group', 'www-data'); } - /** - * @return 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, 'Setting permissions ...'); @@ -140,5 +140,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->writeCommandHeader($output, 'Temp files...'); $files = $this->getConfigurationHelper()->getTempFolders(); $this->setPermissions($output, $files, 0777, $linuxUser, $linuxGroup, false); + + return 0; } } diff --git a/src/Command/Files/ShowDiskUsageCommand.php b/src/Command/Files/ShowDiskUsageCommand.php index 4f85d36..0153c1c 100644 --- a/src/Command/Files/ShowDiskUsageCommand.php +++ b/src/Command/Files/ShowDiskUsageCommand.php @@ -58,9 +58,9 @@ protected function configure(): void } /** - * @return bool|int|void|null + * @return void */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { parent::execute($input, $output); @@ -317,5 +317,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ->setPadType(STR_PAD_RIGHT); } $table->render($output); + + return 0; } } diff --git a/src/Command/Files/UpdateDirectoryMaxSizeCommand.php b/src/Command/Files/UpdateDirectoryMaxSizeCommand.php index 8a3ca44..a052949 100644 --- a/src/Command/Files/UpdateDirectoryMaxSizeCommand.php +++ b/src/Command/Files/UpdateDirectoryMaxSizeCommand.php @@ -36,10 +36,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); $conn = $this->getConnection($input); @@ -146,5 +143,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $output->writeln('The connection does not seem to be a valid PDO connection'); } + + return 0; } } diff --git a/src/Command/Info/GetInstancesCommand.php b/src/Command/Info/GetInstancesCommand.php index 7da8f34..56a9bec 100644 --- a/src/Command/Info/GetInstancesCommand.php +++ b/src/Command/Info/GetInstancesCommand.php @@ -87,10 +87,7 @@ protected function configure(): void ; } - /** - * @return int|void|null - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $path = $input->getArgument('path'); $folderInsidePath = $input->getArgument('folder'); @@ -129,6 +126,6 @@ protected function execute(InputInterface $input, OutputInterface $output) $table->render(); - return null; + return 0; } } diff --git a/src/Command/Info/WhichCommand.php b/src/Command/Info/WhichCommand.php index 8132381..235cfb0 100644 --- a/src/Command/Info/WhichCommand.php +++ b/src/Command/Info/WhichCommand.php @@ -101,10 +101,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/Installation/InstallCommand.php b/src/Command/Installation/InstallCommand.php index 2eb3846..fc77e58 100644 --- a/src/Command/Installation/InstallCommand.php +++ b/src/Command/Installation/InstallCommand.php @@ -257,7 +257,7 @@ public function installLegacy(InputInterface $input, OutputInterface $output) /** * Install Chamilo. * - * @return bool + * @return false|int|null */ public function install(InputInterface $input, OutputInterface $output) { @@ -610,7 +610,7 @@ public function getVersionToInstall($version) * * @return bool */ - public function processInstallation($databaseSettings, $version, $output) + public function processInstallation($databaseSettings, $version, OutputInterface $output) { $sqlFolder = $this->getInstallationPath($version); $databaseMap = $this->getDatabaseMap(); @@ -950,9 +950,9 @@ protected function configure(): void /** * Executes a command via CLI. * - * @return int|void|null + * @return false|int|null */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { // Setting configuration helper. $this->getApplication()->getHelperSet()->set( @@ -1021,6 +1021,8 @@ protected function execute(InputInterface $input, OutputInterface $output) } else { $this->install($input, $output); } + + return 0; } /** @@ -1029,7 +1031,7 @@ protected function execute(InputInterface $input, OutputInterface $output) * * @throws \Exception */ - private function importSQLFile($file, $output) + private function importSQLFile(string $file, OutputInterface $output) { $command = $this->getApplication()->find('dbal:import'); diff --git a/src/Command/Installation/StatusCommand.php b/src/Command/Installation/StatusCommand.php index 1e20765..4054dff 100644 --- a/src/Command/Installation/StatusCommand.php +++ b/src/Command/Installation/StatusCommand.php @@ -27,12 +27,7 @@ protected function configure(): void ; } - /** - * Executes a command via CLI. - * - * @return int|void|null - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { parent::execute($input, $output); $connection = $this->getConnection($input); @@ -114,5 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output) /*$output->writeln("Please check carefully your Chamilo installation. "); $output->writeln("The configuration.php file and the 'chamilo_database_version' setting are not synced.");*/ } + + return 0; } } diff --git a/src/Command/Installation/UpgradeCommand.php b/src/Command/Installation/UpgradeCommand.php index 92971bc..422e264 100644 --- a/src/Command/Installation/UpgradeCommand.php +++ b/src/Command/Installation/UpgradeCommand.php @@ -254,7 +254,7 @@ public function getMigrationTypes() * * @return bool */ - public function processQueryList($courseList, $output, $path, $version, $dryRun, $type) + public function processQueryList($courseList, $output, string $path, string $version, bool $dryRun, string $type) { $databases = $this->getDatabaseList($output, $courseList, $path, $version, $type); $this->setConnections($version, $path, $databases); @@ -341,7 +341,7 @@ public function processQueryList($courseList, $output, $path, $version, $dryRun, * @param OutputInterface $output * @param string type */ - public function fillQueryList($sqlFilePath, $output, $type) + public function fillQueryList($sqlFilePath, $output, string $type) { $output->writeln(sprintf("Processing file type: $type '%s'... ", $sqlFilePath)); $sections = $this->getSections(); @@ -582,9 +582,9 @@ public function getSQLContents($file, $section, $output) * @param OutputInterface $output * @param string $dryRun * - * @return int + * @return int|null */ - public function createCourseTables($output, $dryRun) + public function createCourseTables($output, $dryRun): ?int { if ($dryRun) { $output->writeln('Creating c_* tables but dry-run is on. 0 table created.'); diff --git a/src/Command/Installation/UpgradeDatabaseCommand.php b/src/Command/Installation/UpgradeDatabaseCommand.php index 7205883..7c3159f 100644 --- a/src/Command/Installation/UpgradeDatabaseCommand.php +++ b/src/Command/Installation/UpgradeDatabaseCommand.php @@ -493,9 +493,9 @@ public function getSQLContents($file, $section, $output) * @param OutputInterface $output * @param string $dryRun * - * @return int + * @return int|null */ - public function createCourseTables($output, $dryRun) + public function createCourseTables($output, $dryRun): ?int { if ($dryRun) { $output->writeln('Creating c_* tables but dry-run is on. 0 table created.'); diff --git a/src/Command/Installation/WipeCommand.php b/src/Command/Installation/WipeCommand.php index 6bfdb4f..2f15748 100644 --- a/src/Command/Installation/WipeCommand.php +++ b/src/Command/Installation/WipeCommand.php @@ -22,12 +22,7 @@ protected function configure(): void ->addArgument('path', InputArgument::OPTIONAL, 'The path to the Chamilo folder'); } - /** - * Executes a command via CLI. - * - * @return int|void|null - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { // Arguments $path = $input->getArgument('path'); @@ -92,5 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output) ]; $input = new ArrayInput($arguments); $command->run($input, $output); + + return 0; } } diff --git a/src/Command/Translation/AddSubLanguageCommand.php b/src/Command/Translation/AddSubLanguageCommand.php index 08017ef..0dcfbc8 100644 --- a/src/Command/Translation/AddSubLanguageCommand.php +++ b/src/Command/Translation/AddSubLanguageCommand.php @@ -37,7 +37,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); $_configuration = $this->getConfigurationArray(); diff --git a/src/Command/Translation/DisableLanguageCommand.php b/src/Command/Translation/DisableLanguageCommand.php index 5ba08a3..e7409a9 100644 --- a/src/Command/Translation/DisableLanguageCommand.php +++ b/src/Command/Translation/DisableLanguageCommand.php @@ -29,10 +29,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/Translation/EnableLanguageCommand.php b/src/Command/Translation/EnableLanguageCommand.php index 82fb97d..2b854d1 100644 --- a/src/Command/Translation/EnableLanguageCommand.php +++ b/src/Command/Translation/EnableLanguageCommand.php @@ -30,10 +30,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/Translation/ExportLanguageCommand.php b/src/Command/Translation/ExportLanguageCommand.php index d06b0d1..2e26e72 100644 --- a/src/Command/Translation/ExportLanguageCommand.php +++ b/src/Command/Translation/ExportLanguageCommand.php @@ -31,10 +31,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); diff --git a/src/Command/Translation/ImportLanguageCommand.php b/src/Command/Translation/ImportLanguageCommand.php index c605bf3..0ff9181 100644 --- a/src/Command/Translation/ImportLanguageCommand.php +++ b/src/Command/Translation/ImportLanguageCommand.php @@ -26,10 +26,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); $helper = $this->getHelperSet()->get('question'); diff --git a/src/Command/Translation/ListLanguagesCommand.php b/src/Command/Translation/ListLanguagesCommand.php index 8425115..3629ee6 100644 --- a/src/Command/Translation/ListLanguagesCommand.php +++ b/src/Command/Translation/ListLanguagesCommand.php @@ -34,10 +34,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/Translation/PlatformLanguageCommand.php b/src/Command/Translation/PlatformLanguageCommand.php index 07c33fb..3ce4d1b 100644 --- a/src/Command/Translation/PlatformLanguageCommand.php +++ b/src/Command/Translation/PlatformLanguageCommand.php @@ -36,10 +36,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/Translation/TermsPackageCommand.php b/src/Command/Translation/TermsPackageCommand.php index 345b4e5..b692805 100644 --- a/src/Command/Translation/TermsPackageCommand.php +++ b/src/Command/Translation/TermsPackageCommand.php @@ -64,10 +64,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); diff --git a/src/Command/User/AddUserCommand.php b/src/Command/User/AddUserCommand.php index e2a8b93..306cddb 100644 --- a/src/Command/User/AddUserCommand.php +++ b/src/Command/User/AddUserCommand.php @@ -61,10 +61,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); $conn = $this->getConnection($input); diff --git a/src/Command/User/ChangePassCommand.php b/src/Command/User/ChangePassCommand.php index 0d08127..35db8c3 100644 --- a/src/Command/User/ChangePassCommand.php +++ b/src/Command/User/ChangePassCommand.php @@ -36,10 +36,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/User/DisableAdminsCommand.php b/src/Command/User/DisableAdminsCommand.php index d1983a0..8e743f0 100644 --- a/src/Command/User/DisableAdminsCommand.php +++ b/src/Command/User/DisableAdminsCommand.php @@ -22,10 +22,7 @@ protected function configure(): void ->setDescription('Changes all the admin users to teachers on the main portal (possible short term crack defense)'); } - /** - * @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->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/User/MakeAdminCommand.php b/src/Command/User/MakeAdminCommand.php index 87af65d..e69c028 100644 --- a/src/Command/User/MakeAdminCommand.php +++ b/src/Command/User/MakeAdminCommand.php @@ -30,7 +30,7 @@ protected function configure(): void ); } - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { parent::execute($input, $output); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/User/ResetLoginCommand.php b/src/Command/User/ResetLoginCommand.php index 11b6a21..fb2fd7e 100644 --- a/src/Command/User/ResetLoginCommand.php +++ b/src/Command/User/ResetLoginCommand.php @@ -33,10 +33,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/User/SetLanguageCommand.php b/src/Command/User/SetLanguageCommand.php index b70a618..71369da 100644 --- a/src/Command/User/SetLanguageCommand.php +++ b/src/Command/User/SetLanguageCommand.php @@ -35,10 +35,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); $_configuration = $this->getHelper('configuration')->getConfiguration(); diff --git a/src/Command/User/UsersPerUrlAccessCommand.php b/src/Command/User/UsersPerUrlAccessCommand.php index 9edcbf0..23644e2 100644 --- a/src/Command/User/UsersPerUrlAccessCommand.php +++ b/src/Command/User/UsersPerUrlAccessCommand.php @@ -24,10 +24,7 @@ protected function configure(): void ->setDescription('Show the accesses users have, per URL, in multi-URL configurations'); } - /** - * @return int|void|null - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { parent::execute($input, $output); $conn = $this->getConnection($input); diff --git a/src/Helpers/ConfigurationHelper.php b/src/Helpers/ConfigurationHelper.php index c78a48c..72de92e 100644 --- a/src/Helpers/ConfigurationHelper.php +++ b/src/Helpers/ConfigurationHelper.php @@ -49,6 +49,7 @@ public function getDryRun() /** * @param $dryRun + * @param bool|null|string|string[] $dryRun */ public function setDryRun($dryRun) { @@ -229,7 +230,7 @@ public function getConfiguration($path = null) * * @param string $configurationFile * - * @return string + * @return false|null|string */ public function getSysPathFromConfigurationFile($configurationFile) { @@ -313,7 +314,7 @@ public function readConfigurationFile($configurationFile = null) * * @param $configuration */ - public function setConfiguration($configuration) + public function setConfiguration(array $configuration) { $this->configuration = $configuration; } @@ -463,9 +464,9 @@ public function getSysFiles() } /** - * @return Finder + * @return Finder|null */ - public function getDataFolders() + public function getDataFolders(): ?Finder { $finder = new Finder(); $sysPath = $this->getSysPath(); @@ -571,7 +572,7 @@ public function getTempFiles() /** * Lists the lib folder. * - * @return Finder + * @return false|string */ public function getLibFolder() { @@ -632,7 +633,7 @@ public function getLibFile($fileName) * * @param $sysPath */ - public function setSysPath($sysPath) + public function setSysPath(string $sysPath) { $this->sysPath = $sysPath; }