Skip to content

Commit 0ff31bf

Browse files
committed
phpstan fixes
1 parent 4a20ad8 commit 0ff31bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+148
-218
lines changed

phpstan.neon

-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
11
parameters:
22
excludes_analyse:
3-
- %rootDir%/../../../public/main/admin/db.php
4-
- %rootDir%/../../../public/main/extra/*
5-
- %rootDir%/../../../public/main/cron/*
6-
- %rootDir%/../../../public/main/inc/lib/pear/*
7-
- %rootDir%/../../../public/main/inc/lib/nusoap/*
8-
- %rootDir%/../../../public/main/inc/lib/search/*
9-
- %rootDir%/../../../public/main/webservices/*
10-
- %rootDir%/../../../src/CoreBundle/Migrations/Schema/*
113
- %rootDir%/../../../tests/*
124
level: max

src/Command/Common/ChamiloEmailCommand.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ protected function configure(): void
2424
}
2525

2626
/**
27-
* @return int|void|null
27+
* @return int
2828
*/
2929
protected function execute(InputInterface $input, OutputInterface $output)
3030
{
3131
$configuration = $input->getOption('conf');
3232
$this->getHelper('configuration')->readConfigurationFile($configuration);
33+
34+
return 0;
3335
}
3436
}

src/Command/Common/ChamiloUserCommand.php

-15
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22

33
namespace Chash\Command\Common;
44

5-
use Symfony\Component\Console\Input\InputInterface;
6-
use Symfony\Component\Console\Output\OutputInterface;
7-
85
class ChamiloUserCommand extends DatabaseCommand
96
{
10-
protected function configure(): void
11-
{
12-
parent::configure();
13-
}
14-
15-
/**
16-
* @return int|void|null
17-
*/
18-
protected function execute(InputInterface $input, OutputInterface $output)
19-
{
20-
parent::execute($input, $output);
21-
}
227
}

src/Command/Common/CommonCommand.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ public function getRootSys()
151151
}
152152

153153
/**
154-
* @return string
154+
* @return null|string
155155
*/
156-
public function getCourseSysPath()
156+
public function getCourseSysPath(): ?string
157157
{
158158
if (is_dir($this->getRootSys().'courses')) {
159159
return $this->getRootSys().'courses';
@@ -636,7 +636,7 @@ public function setRootSysDependingConfigurationPath($path)
636636
* @param string $path
637637
* @param object $output Output handler to print info messages
638638
*
639-
* @return bool
639+
* @return bool|int
640640
*/
641641
public function writeConfiguration($version, $path, $output)
642642
{
@@ -1241,6 +1241,7 @@ public function copyConfigFilesToNewLocation(OutputInterface $output)
12411241

12421242
/**
12431243
* @param $path
1244+
* @param bool|null|string|string[] $path
12441245
*/
12451246
public function removeUnUsedFiles(OutputInterface $output, $path)
12461247
{

src/Command/Common/DatabaseCommand.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ protected function configure(): void
5555
);
5656
}
5757

58-
/**
59-
* @return int|void|null
60-
*/
61-
protected function execute(InputInterface $input, OutputInterface $output)
58+
protected function execute(InputInterface $input, OutputInterface $output): int
6259
{
6360
$io = new SymfonyStyle($input, $output);
6461
$configurationFile = $input->getOption('conf');
@@ -103,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
103100
'<comment>Try</comment> <info>prefix:command --conf=/var/www/chamilo/config/configuration.php</info>'
104101
);
105102

106-
return false;
103+
return 0;
107104
}
108105
}
109106
}
@@ -135,5 +132,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
135132
// Setting doctrine connection
136133
$this->setDatabaseSettings($databaseSettings);
137134
$this->setDoctrineSettings($this->getHelperSet());
135+
136+
return 0;
138137
}
139138
}

src/Command/Common/InfoCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ protected function configure(): void
2020
);
2121
}
2222

23-
/**
24-
* @return int|void|null
25-
*/
26-
protected function execute(InputInterface $input, OutputInterface $output)
23+
protected function execute(InputInterface $input, OutputInterface $output): int
2724
{
2825
$configuration = $input->getOption('conf');
2926
$this->getHelper('configuration')->readConfigurationFile($configuration);
27+
28+
return 0;
3029
}
3130
}

src/Command/Database/DropDatabaseCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ protected function configure(): void
2121
}
2222

2323
/**
24-
* @return int|void|null
24+
* @return void
2525
*/
26-
protected function execute(InputInterface $input, OutputInterface $output)
26+
protected function execute(InputInterface $input, OutputInterface $output): int
2727
{
2828
parent::execute($input, $output);
2929

@@ -62,5 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6262
} else {
6363
$output->writeln("<comment>Can't established connection with the database. Probably it was already deleted.</comment>");
6464
}
65+
66+
return 0;
6567
}
6668
}

src/Command/Database/DumpCommand.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ protected function configure(): void
2323
->setDescription('Outputs a dump of the database');
2424
}
2525

26-
/**
27-
* @return int|void|null
28-
*/
29-
protected function execute(InputInterface $input, OutputInterface $output)
26+
protected function execute(InputInterface $input, OutputInterface $output): int
3027
{
3128
parent::execute($input, $output);
3229
$_configuration = $this->getConfigurationArray();
3330
$dump = 'mysqldump -h '.$_configuration['db_host'].' -u '.$_configuration['db_user'].' -p'.$_configuration['db_password'].' '.$_configuration['main_database'];
3431
system($dump);
3532

36-
return null;
33+
return 0;
3734
}
3835
}

src/Command/Database/FullBackupCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ protected function configure(): void
4848
);
4949
}
5050

51-
/**
52-
* @return int|void|null
53-
*/
54-
protected function execute(InputInterface $input, OutputInterface $output)
51+
protected function execute(InputInterface $input, OutputInterface $output): int
5552
{
5653
parent::execute($input, $output);
5754

@@ -107,5 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
107104
$output->writeln(
108105
'<comment>End Chamilo backup. File can be found here: '.realpath($resultPath).' </comment>'
109106
);
107+
108+
return 0;
110109
}
111110
}

src/Command/Database/ImportCommand.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ protected function configure(): void
5858
);
5959
}
6060

61-
/**
62-
* @see Console\Command\Command
63-
*/
6461
protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
6562
{
6663
$conn = $this->getHelper('db')->getConnection();
@@ -117,5 +114,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
117114
}
118115
}
119116
}
117+
118+
return 0;
120119
}
121120
}

src/Command/Database/RestoreCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ protected function configure(): void
3232
}
3333

3434
/**
35-
* @return int|void|null
35+
* @return void
3636
*/
37-
protected function execute(InputInterface $input, OutputInterface $output)
37+
protected function execute(InputInterface $input, OutputInterface $output): int
3838
{
3939
parent::execute($input, $output);
4040
$dumpPath = $input->getArgument('file');
@@ -48,5 +48,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4848
} else {
4949
$output->writeln('<comment>File is not a valid SQL file: '.$dumpPath.' </comment>');
5050
}
51+
52+
return 0;
5153
}
5254
}

src/Command/Database/RunSQLCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ protected function configure(): void
2424
$this->setHelp('Prompts a SQL cli');
2525
}
2626

27-
/**
28-
* @return int|void|null
29-
*/
30-
protected function execute(InputInterface $input, OutputInterface $output)
27+
protected function execute(InputInterface $input, OutputInterface $output): int
3128
{
3229
parent::execute($input, $output);
3330
$output->writeln('Starting Chamilo SQL cli');
@@ -60,5 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6057
// Inside execute function
6158
//$output->getFormatter()->setStyle('fcbarcelona', new OutputFormatterStyle('red', 'blue', array('blink', 'bold', 'underscore')));
6259
//$output->writeln('<fcbarcelona>Messi for the win</fcbarcelona>');
60+
61+
return 0;
6362
}
6463
}

src/Command/Database/SQLCountCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ protected function configure(): void
3030
/**
3131
* @todo use doctrine
3232
*
33-
* @return int|void|null
33+
* @return void
3434
*/
35-
protected function execute(InputInterface $input, OutputInterface $output)
35+
protected function execute(InputInterface $input, OutputInterface $output): int
3636
{
3737
parent::execute($input, $output);
3838
$table = $input->getArgument('table');
@@ -52,5 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5252
"<comment>Table '$table' does not exists in the database: ".$_configuration['main_database']
5353
);
5454
}
55+
56+
return 0;
5557
}
5658
}

src/Command/Database/ShowConnInfoCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ protected function configure(): void
2121
->setDescription('Shows database connection credentials for the current Chamilo install');
2222
}
2323

24-
/**
25-
* @return int|void|null
26-
*/
27-
protected function execute(InputInterface $input, OutputInterface $output)
24+
protected function execute(InputInterface $input, OutputInterface $output): int
2825
{
2926
parent::execute($input, $output);
3027

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

src/Command/Email/SendEmailCommand.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@ protected function configure(): void
6363
);
6464
}
6565

66-
/**
67-
* @return void|null
68-
*/
69-
protected function execute(InputInterface $input, OutputInterface $output)
66+
protected function execute(InputInterface $input, OutputInterface $output): int
7067
{
7168
parent::execute($input, $output);
7269
$mailLib = $this->getHelper('configuration')->getLibFile('mail.lib.inc.php');
@@ -135,6 +132,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
135132
}
136133
}
137134

138-
return null;
135+
return 0;
139136
}
140137
}

src/Command/Files/CleanConfigFilesCommand.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ protected function configure(): void
2222
}
2323

2424
/**
25-
* @return int|void|null
25+
* @return void
2626
*/
27-
protected function execute(InputInterface $input, OutputInterface $output)
27+
protected function execute(InputInterface $input, OutputInterface $output): int
2828
{
2929
parent::execute($input, $output);
3030
$this->writeCommandHeader($output, 'Cleaning config files.');
@@ -39,5 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
3939
}
4040
$files = $this->getConfigurationHelper()->getConfigFiles();
4141
$this->removeFiles($files, $output);
42+
43+
return 0;
4244
}
4345
}

src/Command/Files/CleanCoursesFilesCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@ protected function configure(): void
2222
->setDescription('Cleans the courses directory');
2323
}
2424

25-
/**
26-
* @return bool|int|void|null
27-
*/
28-
protected function execute(InputInterface $input, OutputInterface $output)
25+
protected function execute(InputInterface $input, OutputInterface $output): int
2926
{
3027
parent::execute($input, $output);
3128
$this->writeCommandHeader($output, 'Cleaning folders in courses directory.');
@@ -40,5 +37,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4037
}
4138
$files = $this->getConfigurationHelper()->getCoursesFiles();
4239
$this->removeFiles($files, $output);
40+
41+
return 0;
4342
}
4443
}

src/Command/Files/CleanDeletedDocumentsCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ protected function configure(): void
4848
;
4949
}
5050

51-
/**
52-
* @return bool|int|void|null
53-
*/
54-
protected function execute(InputInterface $input, OutputInterface $output)
51+
protected function execute(InputInterface $input, OutputInterface $output): int
5552
{
5653
parent::execute($input, $output);
5754
$category = $input->getOption('category');
@@ -123,5 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
123120
}
124121
}
125122
$this->removeFiles($files, $output);
123+
124+
return 0;
126125
}
127126
}

src/Command/Files/CleanTempFolderCommand.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ protected function configure(): void
2121
->setDescription('Cleans the temp directory.');
2222
}
2323

24-
/**
25-
* @return bool|int|void|null
26-
*/
27-
protected function execute(InputInterface $input, OutputInterface $output)
24+
protected function execute(InputInterface $input, OutputInterface $output): int
2825
{
2926
parent::execute($input, $output);
3027
$this->writeCommandHeader($output, 'Cleaning temp files.');
@@ -38,5 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
3835
}
3936
$files = $this->getConfigurationHelper()->getTempFiles();
4037
$this->removeFiles($files, $output);
38+
39+
return 0;
4140
}
4241
}

0 commit comments

Comments
 (0)