Skip to content

Commit dd8248e

Browse files
committed
ecs fixes
1 parent 97aa1df commit dd8248e

Some content is hidden

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

52 files changed

+604
-549
lines changed

src/Command/Chash/SelfUpdateCommand.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
7373

7474
$zippy = Zippy::load();
7575
$archive = $zippy->open($tempFile);
76+
7677
try {
7778
$archive->extract($folderPath);
7879
} catch (\Alchemy\Zippy\Exception\RunTimeException $e) {
79-
$output->writeln("<comment>Chash update failed during unzip.");
80+
$output->writeln('<comment>Chash update failed during unzip.');
8081
$output->writeln($e->getMessage());
8182

8283
return 0;

src/Command/Chash/SetupCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
5050
$version = $input->getArgument('version');
5151
$chamiloRoot = $input->getArgument('chamilo_root');
5252

53-
if ($version == '111') {
53+
if ('111' == $version) {
5454
$file = $chamiloRoot.'app/config/migrations.yml';
5555

5656
require_once $chamiloRoot.'app/Migrations/AbstractMigrationChamilo.php';
@@ -60,7 +60,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
6060
return 1;
6161
}
6262

63-
if ($version == '110') {
63+
if ('110' == $version) {
6464
$file = $chamiloRoot.'app/config/migrations110.yml';
6565

6666
$this->migrationFile = $file;

src/Command/Common/ChamiloEmailCommand.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
/**
1111
* Class CommonChamiloUserCommand.
12-
*
13-
* @package Chash\Command\User
1412
*/
1513
class ChamiloEmailCommand extends Command
1614
{

src/Command/Common/CommonCommand.php

+43-35
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public function getInstallationFolder()
185185
*/
186186
public function getInstallationPath($version)
187187
{
188-
if ($version === 'master') {
188+
if ('master' === $version) {
189189
$version = $this->getLatestVersion();
190190
}
191191

@@ -619,7 +619,7 @@ public function setRootSysDependingConfigurationPath($path)
619619
{
620620
$configurationPath = $this->getConfigurationHelper()->getNewConfigurationPath($path);
621621

622-
if ($configurationPath == false) {
622+
if (false == $configurationPath) {
623623
// Seems an old installation!
624624
$configurationPath = $this->getConfigurationHelper()->getConfigurationPath($path);
625625
$this->setRootSys(realpath($configurationPath.'/../../../').'/');
@@ -640,12 +640,12 @@ public function setRootSysDependingConfigurationPath($path)
640640
*/
641641
public function writeConfiguration($version, $path, $output)
642642
{
643-
$output->writeln("");
644-
$output->writeln("<comment>Starting the writeConfiguration process.</comment>");
643+
$output->writeln('');
644+
$output->writeln('<comment>Starting the writeConfiguration process.</comment>');
645645
$portalSettings = $this->getPortalSettings();
646646
$databaseSettings = $this->getDatabaseSettings();
647647
$configurationPath = $this->getConfigurationHelper()->getConfigurationPath($path);
648-
$output->writeln("<comment>Recovered all info. Reviewing.</comment>");
648+
$output->writeln('<comment>Recovered all info. Reviewing.</comment>');
649649

650650
// Creates a YML File
651651
$configuration = [];
@@ -672,10 +672,10 @@ public function writeConfiguration($version, $path, $output)
672672

673673
// Version settings
674674
$configuration['system_version'] = $version;
675-
$output->writeln("<comment>Data reviewed. Checking where to write to...</comment>");
675+
$output->writeln('<comment>Data reviewed. Checking where to write to...</comment>');
676676

677677
if (file_exists($this->getRootSys().'config/parameters.yml.dist')) {
678-
$output->writeln("<comment>parameters.yml.dist file found.</comment>");
678+
$output->writeln('<comment>parameters.yml.dist file found.</comment>');
679679

680680
$file = $this->getRootSys().'config/parameters.yml';
681681
if (!file_exists($file)) {
@@ -697,7 +697,7 @@ public function writeConfiguration($version, $path, $output)
697697
}
698698
} else {
699699
// Try the old one
700-
$output->writeln("<comment>Looking for main/install/configuration.dist.php.</comment>");
700+
$output->writeln('<comment>Looking for main/install/configuration.dist.php.</comment>');
701701

702702
$contents = file_get_contents($this->getRootSys().'main/install/configuration.dist.php');
703703

@@ -710,18 +710,18 @@ public function writeConfiguration($version, $path, $output)
710710
$config['{DATABASE_DRIVER}'] = $configuration['driver'];
711711

712712
$config['{COURSE_TABLE_PREFIX}'] = '';
713-
$config['{DATABASE_GLUE}'] = "`.`"; // keeping for backward compatibility
713+
$config['{DATABASE_GLUE}'] = '`.`'; // keeping for backward compatibility
714714
$config['{DATABASE_PREFIX}'] = '';
715715
$config['{DATABASE_STATS}'] = $configuration['main_database'];
716716
$config['{DATABASE_SCORM}'] = $configuration['main_database'];
717717
$config['{DATABASE_PERSONAL}'] = $configuration['main_database'];
718718
$config['TRACKING_ENABLED'] = "'true'";
719-
$config['SINGLE_DATABASE'] = "false";
719+
$config['SINGLE_DATABASE'] = 'false';
720720

721721
$config['{ROOT_WEB}'] = $portalSettings['site_url'];
722722
$config['{ROOT_SYS}'] = $this->getRootSys();
723723

724-
$config['{URL_APPEND_PATH}'] = "";
724+
$config['{URL_APPEND_PATH}'] = '';
725725
$config['{SECURITY_KEY}'] = $configuration['security_key'];
726726
$config['{ENCRYPT_PASSWORD}'] = $configuration['password_encryption'];
727727

@@ -734,10 +734,10 @@ public function writeConfiguration($version, $path, $output)
734734
}
735735

736736
$newConfigurationFile = $configurationPath.'configuration.php';
737-
$output->writeln(sprintf("<comment>Writing config to %s</comment>", $newConfigurationFile));
737+
$output->writeln(sprintf('<comment>Writing config to %s</comment>', $newConfigurationFile));
738738

739739
$result = file_put_contents($newConfigurationFile, $contents);
740-
$output->writeln("<comment>Config file written.</comment>");
740+
$output->writeln('<comment>Config file written.</comment>');
741741
}
742742

743743
return $result;
@@ -789,9 +789,9 @@ public function updateConfiguration(OutputInterface $output, $dryRun, $newValues
789789
$configurationPath = $this->getConfigurationPath();
790790
$newConfigurationFile = $configurationPath.'configuration.php';
791791

792-
if ($dryRun == false) {
792+
if (false == $dryRun) {
793793
if (version_compare($newValues['system_version'], '1.10', '>=') ||
794-
($newValues['system_version'] == '1.10.x' || $newValues['system_version'] == '1.11.x')
794+
('1.10.x' == $newValues['system_version'] || '1.11.x' == $newValues['system_version'])
795795
) {
796796
$configurationPath = $_configuration['root_sys'].'app/config/';
797797
$newConfigurationFile = $configurationPath.'configuration.php';
@@ -919,6 +919,7 @@ public function removeFiles($files, OutputInterface $output)
919919
}
920920

921921
$fs = new Filesystem();
922+
922923
try {
923924
if ($dryRun) {
924925
$output->writeln('<comment>Files to be removed (--dry-run is on).</comment>');
@@ -969,20 +970,24 @@ public function getPackage(OutputInterface $output, $version, $updateInstallatio
969970

970971
// Download the chamilo package from from github:
971972
if (empty($updateInstallation)) {
972-
$updateInstallation = "https://github.com/chamilo/chamilo-lms/archive/v".$version.".zip";
973+
$updateInstallation = 'https://github.com/chamilo/chamilo-lms/archive/v'.$version.'.zip';
973974

974975
switch ($version) {
975976
case 'master':
976-
$updateInstallation = "https://github.com/chamilo/chamilo-lms/archive/master.zip";
977+
$updateInstallation = 'https://github.com/chamilo/chamilo-lms/archive/master.zip';
978+
977979
break;
978980
case '1.9.x':
979-
$updateInstallation = "https://github.com/chamilo/chamilo-lms/archive/1.9.x.zip";
981+
$updateInstallation = 'https://github.com/chamilo/chamilo-lms/archive/1.9.x.zip';
982+
980983
break;
981984
case '1.10.x':
982-
$updateInstallation = "https://github.com/chamilo/chamilo-lms/archive/1.10.x.zip";
985+
$updateInstallation = 'https://github.com/chamilo/chamilo-lms/archive/1.10.x.zip';
986+
983987
break;
984988
case '1.11.x':
985-
$updateInstallation = "https://github.com/chamilo/chamilo-lms/archive/1.11.x.zip";
989+
$updateInstallation = 'https://github.com/chamilo/chamilo-lms/archive/1.11.x.zip';
990+
986991
break;
987992
}
988993
}
@@ -998,7 +1003,7 @@ public function getPackage(OutputInterface $output, $version, $updateInstallatio
9981003
}
9991004

10001005
// Download file?
1001-
if (strpos($updateInstallation, 'http') === false) {
1006+
if (false === strpos($updateInstallation, 'http')) {
10021007
if (!file_exists($updateInstallation)) {
10031008
$output->writeln("<comment>File does not exists: $updateInstallation</comment>");
10041009

@@ -1012,14 +1017,14 @@ public function getPackage(OutputInterface $output, $version, $updateInstallatio
10121017
$output->writeln("<comment>Executing</comment> <info>wget -O $updateInstallationLocalName '$updateInstallation'</info>");
10131018
$output->writeln('');
10141019

1015-
$execute = "wget -O ".$updateInstallationLocalName." '$updateInstallation'\n";
1020+
$execute = 'wget -O '.$updateInstallationLocalName." '$updateInstallation'\n";
10161021

10171022
$systemOutput = shell_exec($execute);
10181023

10191024
$systemOutput = str_replace("\n", "\n\t", $systemOutput);
10201025
$output->writeln($systemOutput);
10211026
} else {
1022-
$output->writeln("<comment>Seems that the chamilo v".$version." has been already downloaded. File location:</comment> <info>$updateInstallationLocalName</info>");
1027+
$output->writeln('<comment>Seems that the chamilo v'.$version." has been already downloaded. File location:</comment> <info>$updateInstallationLocalName</info>");
10231028
}
10241029

10251030
$updateInstallation = $updateInstallationLocalName;
@@ -1044,7 +1049,7 @@ public function getPackage(OutputInterface $output, $version, $updateInstallatio
10441049
// Load from cache
10451050
$chamiloPath = $folderPath.'/chamilo-lms-CHAMILO_'.$versionTag.'_STABLE/main/inc/global.inc.php';
10461051
if (file_exists($chamiloPath)) {
1047-
$output->writeln("<comment>Files have been already extracted here: </comment><info>".$folderPath.'/chamilo-lms-CHAMILO_'.$versionTag.'_STABLE/'."</info>");
1052+
$output->writeln('<comment>Files have been already extracted here: </comment><info>'.$folderPath.'/chamilo-lms-CHAMILO_'.$versionTag.'_STABLE/'.'</info>');
10481053

10491054
return $folderPath.'/chamilo-lms-CHAMILO_'.$versionTag.'_STABLE/';
10501055
}
@@ -1061,12 +1066,13 @@ public function getPackage(OutputInterface $output, $version, $updateInstallatio
10611066
/** @var \SplFileInfo $file */
10621067
foreach ($files as $file) {
10631068
$chamiloLocationPath = $file->getRealPath();
1069+
10641070
break;
10651071
}
10661072
}
10671073

10681074
if (empty($chamiloLocationPath)) {
1069-
$output->writeln("<error>Chamilo folder structure not found in package.</error>");
1075+
$output->writeln('<error>Chamilo folder structure not found in package.</error>');
10701076

10711077
return 0;
10721078
}
@@ -1121,20 +1127,20 @@ public function copyPackageIntoSystem(
11211127
}
11221128

11231129
if (empty($chamiloLocationPath)) {
1124-
$output->writeln("<error>The chamiloLocationPath variable is empty<error>");
1130+
$output->writeln('<error>The chamiloLocationPath variable is empty<error>');
11251131

11261132
return 0;
11271133
}
11281134

1129-
$output->writeln("<comment>Copying files from </comment><info>$chamiloLocationPath</info><comment> to </comment><info>".$destinationPath."</info>");
1135+
$output->writeln("<comment>Copying files from </comment><info>$chamiloLocationPath</info><comment> to </comment><info>".$destinationPath.'</info>');
11301136

11311137
if (empty($destinationPath)) {
1132-
$output->writeln("<error>The root path was not set.<error>");
1138+
$output->writeln('<error>The root path was not set.<error>');
11331139

11341140
return 0;
11351141
} else {
11361142
$fileSystem->mirror($chamiloLocationPath, $destinationPath, null, ['override' => true]);
1137-
$output->writeln("<comment>Copy finished.<comment>");
1143+
$output->writeln('<comment>Copy finished.<comment>');
11381144

11391145
return 1;
11401146
}
@@ -1207,13 +1213,13 @@ public function copyConfigFilesToNewLocation(OutputInterface $output)
12071213
$configFile = str_replace('dist.', '', $file);
12081214

12091215
if (file_exists($confDir.$configFile)) {
1210-
$output->writeln("<comment> Moving file from: </comment>".$confDir.$configFile);
1211-
$output->writeln("<comment> to: </comment>".$configurationPath.$configFile);
1216+
$output->writeln('<comment> Moving file from: </comment>'.$confDir.$configFile);
1217+
$output->writeln('<comment> to: </comment>'.$configurationPath.$configFile);
12121218
if (!file_exists($configurationPath.$configFile)) {
12131219
$fs->copy($confDir.$configFile, $configurationPath.$configFile);
12141220
}
12151221
} else {
1216-
$output->writeln("<comment> File not found: </comment>".$confDir.$configFile);
1222+
$output->writeln('<comment> File not found: </comment>'.$confDir.$configFile);
12171223
}
12181224
}
12191225

@@ -1473,12 +1479,12 @@ protected function setConnections($version, $path, $databaseList)
14731479
foreach ($dbList as &$dbInfo) {
14741480
$params = $this->getDatabaseSettings();
14751481

1476-
if (isset($_configuration['single_database']) && $_configuration['single_database'] == true) {
1482+
if (isset($_configuration['single_database']) && true == $_configuration['single_database']) {
14771483
$em = \Doctrine\ORM\EntityManager::create($params, $config);
14781484
} else {
1479-
if ($section == 'course') {
1485+
if ('course' == $section) {
14801486
if (version_compare($version, '10', '<=')) {
1481-
if (strpos($dbInfo['database'], '_chamilo_course_') === false) {
1487+
if (false === strpos($dbInfo['database'], '_chamilo_course_')) {
14821488
//$params['dbname'] = $params['dbname'];
14831489
} else {
14841490
$params['dbname'] = str_replace('_chamilo_course_', '', $dbInfo['database']);
@@ -1490,9 +1496,11 @@ protected function setConnections($version, $path, $databaseList)
14901496
switch ($dbInfo['database']) {
14911497
case 'statistics_database':
14921498
$databaseName = isset($_configuration['statistics_database']) ? $_configuration['statistics_database'] : $databaseName;
1499+
14931500
break;
14941501
case 'user_personal_database':
14951502
$databaseName = isset($_configuration['user_personal_database']) ? $_configuration['user_personal_database'] : $databaseName;
1503+
14961504
break;
14971505
}
14981506
$params['dbname'] = $databaseName;

src/Command/Database/DumpCommand.php

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*
1212
* Returns a dump of the database (caller should use an output redirect of some
1313
* kind to store to a file.
14-
*
15-
* @package Chash\Command\Database
1614
*/
1715
class DumpCommand extends DatabaseCommand
1816
{

src/Command/Database/ImportCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
6565
{
6666
$conn = $this->getHelper('db')->getConnection();
6767

68-
if (($fileNames = $input->getArgument('file')) !== null) {
68+
if (null !== ($fileNames = $input->getArgument('file'))) {
6969
foreach ((array) $fileNames as $fileName) {
7070
if (!file_exists($fileName)) {
7171
throw new \InvalidArgumentException(sprintf("SQL file '<info>%s</info>' does not exist.", $fileName));
@@ -89,7 +89,7 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O
8989
$stmt->fetch();
9090
$stmt->closeCursor();
9191

92-
$lines++;
92+
++$lines;
9393
} while ($stmt->nextRowset());
9494

9595
$output->write(sprintf('%d statements executed!', $lines).PHP_EOL);

src/Command/Database/RunSQLCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
3939
$proc_status = proc_get_status($process);
4040
$exit_code = proc_close($process);
4141

42-
return $proc_status["running"] ? $exit_code : $proc_status["exitcode"];
42+
return $proc_status['running'] ? $exit_code : $proc_status['exitcode'];
4343

4444
/*$output->writeln('<comment>Starting Chamilo process</comment>');
4545
$output->writeln('<info>Chamilo process ended succesfully</info>');

src/Command/Database/ShowConnInfoCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
3838
}
3939
$_configuration = $this->getConfigurationArray();
4040

41-
$output->writeln("Database connection details:");
41+
$output->writeln('Database connection details:');
4242
$output->writeln("Host:\t".$_configuration['db_host']);
4343
$output->writeln("User:\t".$_configuration['db_user']);
4444
$output->writeln("Pass:\t".$_configuration['db_password']);
4545
$output->writeln("DB:\t".$_configuration['main_database']);
46-
$output->writeln("Connection string (add password manually for increased security:");
47-
$output->writeln("mysql -h ".$_configuration['db_host']." -u ".$_configuration['db_user']." -p ".$_configuration['main_database']."\n");
46+
$output->writeln('Connection string (add password manually for increased security:');
47+
$output->writeln('mysql -h '.$_configuration['db_host'].' -u '.$_configuration['db_user'].' -p '.$_configuration['main_database']."\n");
4848
}
4949
}

src/Command/Email/SendEmailCommand.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
8484
$userTable = $_configuration['main_database'].'.user';
8585
$adminTable = $_configuration['main_database'].'.admin';
8686

87-
require_once "SendEmailCommand.php";
88-
require_once "SendEmailCommand.php";
89-
require_once "SendEmailCommand.php";
87+
require_once 'SendEmailCommand.php';
88+
require_once 'SendEmailCommand.php';
89+
require_once 'SendEmailCommand.php';
9090

9191
$recipient_name = $input->getArgument('recipient-name');
9292
$recipient_email = $input->getArgument('recipient-email');
@@ -99,12 +99,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
9999
if ($conn instanceof \Doctrine\DBAL\Connection) {
100100
$sql = "SELECT email, CONCAT(lastname, firstname) as name FROM $userTable u "
101101
."LEFT JOIN $adminTable a ON a.user_id = u.user_id "
102-
."ORDER BY u.user_id LIMIT 1";
102+
.'ORDER BY u.user_id LIMIT 1';
103+
103104
try {
104105
$stmt = $conn->prepare($sql);
105106
$stmt->execute();
106107
} catch (\PDOException $e) {
107108
$output->write('SQL error!'.PHP_EOL);
109+
108110
throw new \RuntimeException($e->getMessage(), $e->getCode(), $e);
109111
}
110112
$row = $stmt->fetch(\PDO::FETCH_ASSOC);

src/Command/Files/CleanConfigFilesCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function configure(): void
2727
protected function execute(InputInterface $input, OutputInterface $output)
2828
{
2929
parent::execute($input, $output);
30-
$this->writeCommandHeader($output, "Cleaning config files.");
30+
$this->writeCommandHeader($output, 'Cleaning config files.');
3131

3232
$helper = $this->getHelperSet()->get('question');
3333
$question = new ConfirmationQuestion(

0 commit comments

Comments
 (0)