Skip to content

Commit

Permalink
Clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Dec 19, 2019
1 parent d794586 commit 5313e71
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 39 deletions.
4 changes: 4 additions & 0 deletions ecs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ services:
SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff:
ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach: 'true'

PhpCsFixer\Fixer\Phpdoc\NoSuperfluousPhpdocTagsFixer:
remove_inheritdoc: true

parameters:
sets:
- 'clean-code'
- 'symfony'
- 'symfony-risky'
7 changes: 1 addition & 6 deletions src/Command/Common/CommonCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,6 @@ public function setExtraDatabaseSettings(array $databaseSettings)
$this->extraDatabaseSettings = $databaseSettings;
}

/**
* @return mixed
*/
public function getExtraDatabaseSettings()
{
return $this->extraDatabaseSettings;
Expand Down Expand Up @@ -179,7 +176,7 @@ public function getCourseSysPath(): ?string
*/
public function getInstallationFolder()
{
$chashFolder = dirname(dirname(dirname(__FILE__)));
$chashFolder = dirname(dirname(__DIR__));

return $chashFolder.'/Resources/Database/';
}
Expand Down Expand Up @@ -428,8 +425,6 @@ public function getAvailableVersionInfo($version)

/**
* Gets the min version available to migrate with this command.
*
* @return mixed
*/
public function getMinVersionSupportedByInstall()
{
Expand Down
3 changes: 0 additions & 3 deletions src/Command/Common/DatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
*/
class DatabaseCommand extends CommonCommand
{
/**
* {@inheritdoc}
*/
public function getConnection()
{
try {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Files/DeleteCoursesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

// Check the courses that match the search criteria
if (!empty($courseId)) {
$courseId = intval($courseId);
$courseId = (int) $courseId;
$sql = "SELECT id, code, category_code, creation_date
FROM course
WHERE id = $courseId ";
Expand Down
3 changes: 0 additions & 3 deletions src/Command/Installation/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ protected function configure(): void
;
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
Expand Down
2 changes: 0 additions & 2 deletions src/Command/Installation/UpgradeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,6 @@ public function saveDatabaseList($path, $databaseSection, $version, $type)
* @param string $section
* @param string $version
* @param string $type
*
* @return mixed
*/
public function getDatabasesPerSection($output, $courseList, $path, $section, $version, $type)
{
Expand Down
11 changes: 1 addition & 10 deletions src/Command/Installation/UpgradeDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,6 @@ public function saveDatabaseList($path, $databaseSection, $version, $type)
* @param string $section
* @param string $version
* @param string $type
*
* @return mixed
*/
public function getDatabasesPerSection($output, $courseList, $path, $section, $version, $type)
{
Expand Down Expand Up @@ -492,8 +490,6 @@ public function getSQLContents($file, $section, $output)
*
* @param OutputInterface $output
* @param string $dryRun
*
* @return int
*/
public function createCourseTables($output, $dryRun): int
{
Expand Down Expand Up @@ -534,12 +530,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
{
// sudo php /var/www/html/chash/chash.php chash:chamilo_upgrade 1.11.x --linux-user=jmontoya --linux-group=jmontoya

Expand Down
3 changes: 0 additions & 3 deletions src/Command/Translation/AddSubLanguageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ protected function configure(): void
);
}

/**
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
parent::execute($input, $output);
Expand Down
6 changes: 3 additions & 3 deletions src/Command/Translation/TermsPackageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('The directory '.$destination.' does not seem to exist. The destination directory must exist in order for this script to write the results in a safe place');
exit;
}
if (!is_writeable($destination)) {
if (!is_writable($destination)) {
$output->writeln('The destination directory must be writeable. '.$destination.' seems not to be writeable now.');
exit;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}*/
if (is_dir($destination.$language)) {
if (!is_writeable($destination.$language)) {
if (!is_writable($destination.$language)) {
$output->writeln('Destination directory '.$destination.$language.' already exists but is not writeable. Please make sure whoever launches this script has privileges to write in there.');
exit;
}
Expand All @@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
exit;
}
if (is_dir($destination.$origLang)) {
if (!is_writeable($destination.$origLang)) {
if (!is_writable($destination.$origLang)) {
$output->writeln('Destination directory '.$destination.$origLang.' already exists but is not writeable. Please make sure whoever launches this script has privileges to write in there.');
exit;
}
Expand Down
10 changes: 2 additions & 8 deletions src/DoctrineExtensions/DBAL/Types/UTCDateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ class UTCDateTimeType extends DateTimeType
{
private static $utc = null;

/**
* {@inheritdoc}
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (null === $value) {
return null;
}

if (is_null(self::$utc)) {
if (null === self::$utc) {
self::$utc = new \DateTimeZone('UTC');
}

Expand All @@ -33,16 +30,13 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
return $value->format($platform->getDateTimeFormatString());
}

/**
* {@inheritdoc}
*/
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if (null === $value) {
return null;
}

if (is_null(self::$utc)) {
if (null === self::$utc) {
self::$utc = new \DateTimeZone('UTC');
}

Expand Down

0 comments on commit 5313e71

Please sign in to comment.