diff --git a/ecs.yaml b/ecs.yaml index 915c795403..659a2819b9 100644 --- a/ecs.yaml +++ b/ecs.yaml @@ -9,3 +9,4 @@ parameters: sets: - 'clean-code' - 'symfony' + - 'symfony-risky' diff --git a/src/CoreBundle/Component/Editor/Editor.php b/src/CoreBundle/Component/Editor/Editor.php index 50914d2966..3fa9603677 100644 --- a/src/CoreBundle/Component/Editor/Editor.php +++ b/src/CoreBundle/Component/Editor/Editor.php @@ -203,7 +203,7 @@ class Editor // Arrays in JSON can't be associative. If the array is empty or if it // has sequential whole number keys starting with 0, it's not associative // so we can go ahead and convert it as an array. - if (empty($var) || array_keys($var) === range(0, sizeof($var) - 1)) { + if (empty($var) || array_keys($var) === range(0, count($var) - 1)) { $output = []; foreach ($var as $v) { $output[] = $this->toJavascript($v); @@ -216,7 +216,7 @@ class Editor // Otherwise, fall through to convert the array as an object. $output = []; foreach ($var as $k => $v) { - $output[] = $this->toJavascript(strval($k)).': '.$this->toJavascript($v); + $output[] = $this->toJavascript((string) $k).': '.$this->toJavascript($v); } return '{ '.implode(', ', $output).' }'; diff --git a/src/CoreBundle/Component/Utils/ChamiloApi.php b/src/CoreBundle/Component/Utils/ChamiloApi.php index 419de150a1..e2ad46e1bb 100644 --- a/src/CoreBundle/Component/Utils/ChamiloApi.php +++ b/src/CoreBundle/Component/Utils/ChamiloApi.php @@ -312,7 +312,7 @@ class ChamiloApi foreach ($palette as $index => $color) { $components = preg_split('/,/', trim($color)); $components[3] = round($components[3] / 100, 1); - $palette[$index] = join(',', $components); + $palette[$index] = implode(',', $components); } } if ($wrapInRGBA) { diff --git a/src/CoreBundle/Controller/CourseController.php b/src/CoreBundle/Controller/CourseController.php index bd09f10f95..e04d81b3c0 100644 --- a/src/CoreBundle/Controller/CourseController.php +++ b/src/CoreBundle/Controller/CourseController.php @@ -99,7 +99,7 @@ class CourseController extends AbstractController $courseTags = []; - if (!is_null($tagField)) { + if (null !== $tagField) { $courseTags = $fieldTagsRepo->getTags($tagField, $courseId); } diff --git a/src/CoreBundle/Controller/SessionController.php b/src/CoreBundle/Controller/SessionController.php index 1285fa54bd..a46c5f4486 100644 --- a/src/CoreBundle/Controller/SessionController.php +++ b/src/CoreBundle/Controller/SessionController.php @@ -67,7 +67,7 @@ class SessionController extends AbstractController $sessionCourse = $sessionRelCourse->getCourse(); $courseTags = []; - if (!is_null($tagField)) { + if (null !== $tagField) { $courseTags = $fieldTagsRepo->getTags($tagField, $sessionCourse->getId()); } diff --git a/src/CoreBundle/Entity/Course.php b/src/CoreBundle/Entity/Course.php index 38ac4381b5..c9d166e85c 100644 --- a/src/CoreBundle/Entity/Course.php +++ b/src/CoreBundle/Entity/Course.php @@ -913,7 +913,7 @@ class Course extends AbstractResource implements ResourceInterface */ public function setDiskQuota($diskQuota) { - $this->diskQuota = intval($diskQuota); + $this->diskQuota = (int) $diskQuota; return $this; } diff --git a/src/CoreBundle/Entity/Session.php b/src/CoreBundle/Entity/Session.php index 0d8ea91adb..75c2e3cf2d 100644 --- a/src/CoreBundle/Entity/Session.php +++ b/src/CoreBundle/Entity/Session.php @@ -552,7 +552,7 @@ class Session Criteria::expr()->eq('user', $user) ); - if (!is_null($status)) { + if (null !== $status) { $criteria->andWhere( Criteria::expr()->eq('status', $status) ); diff --git a/src/CoreBundle/Entity/SettingsCurrent.php b/src/CoreBundle/Entity/SettingsCurrent.php index 0d4925e5b4..d2eaea729f 100644 --- a/src/CoreBundle/Entity/SettingsCurrent.php +++ b/src/CoreBundle/Entity/SettingsCurrent.php @@ -374,7 +374,7 @@ class SettingsCurrent */ public function setAccessUrlLocked($accessUrlLocked) { - $this->accessUrlLocked = intval($accessUrlLocked); + $this->accessUrlLocked = (int) $accessUrlLocked; return $this; } diff --git a/src/CoreBundle/Migrations/Schema/V110/Version20151214170800.php b/src/CoreBundle/Migrations/Schema/V110/Version20151214170800.php index 1c6d05a204..1c22364b61 100644 --- a/src/CoreBundle/Migrations/Schema/V110/Version20151214170800.php +++ b/src/CoreBundle/Migrations/Schema/V110/Version20151214170800.php @@ -56,10 +56,10 @@ class Version20151214170800 extends AbstractMigrationChamilo switch ($answer['hotspot_type']) { case 'square': $oldCenter = explode(';', $oldPairedString[0]); - $oldCenterX = intval($oldCenter[0]); - $oldCenterY = intval($oldCenter[1]); - $oldWidth = intval($oldPairedString[1]); - $oldHeight = intval($oldPairedString[2]); + $oldCenterX = (int) ($oldCenter[0]); + $oldCenterY = (int) ($oldCenter[1]); + $oldWidth = (int) ($oldPairedString[1]); + $oldHeight = (int) ($oldPairedString[2]); $newX = floor(($oldCenterX - $oldWidth / 2) * $widthRatio) + ceil($widthRatio); $newY = floor(($oldCenterY - $oldHeight / 2) * $heightRatio) + ceil($heightRatio); @@ -73,10 +73,10 @@ class Version20151214170800 extends AbstractMigrationChamilo break; case 'circle': $oldCenter = explode(';', $oldPairedString[0]); - $oldCenterX = intval($oldCenter[0]); - $oldCenterY = intval($oldCenter[1]); - $oldRadiusX = intval($oldPairedString[1]) / 2; - $oldRadiusY = intval($oldPairedString[2]) / 2; + $oldCenterX = (int) ($oldCenter[0]); + $oldCenterY = (int) ($oldCenter[1]); + $oldRadiusX = (int) ($oldPairedString[1]) / 2; + $oldRadiusY = (int) ($oldPairedString[2]) / 2; $newCenterX = floor($oldCenterX * $widthRatio) + ceil($widthRatio); $newCenterY = floor($oldCenterY * $heightRatio) + ceil($heightRatio); @@ -94,8 +94,8 @@ class Version20151214170800 extends AbstractMigrationChamilo $paired = []; foreach ($oldPairedString as $pairString) { $pair = explode(';', $pairString); - $x = isset($pair[0]) ? intval($pair[0]) : 0; - $y = isset($pair[1]) ? intval($pair[1]) : 0; + $x = isset($pair[0]) ? (int) ($pair[0]) : 0; + $y = isset($pair[1]) ? (int) ($pair[1]) : 0; $paired[] = [$x, $y]; } diff --git a/src/CoreBundle/Repository/ExtraFieldRelTagRepository.php b/src/CoreBundle/Repository/ExtraFieldRelTagRepository.php index 0ddd01ad91..88c52e2de6 100644 --- a/src/CoreBundle/Repository/ExtraFieldRelTagRepository.php +++ b/src/CoreBundle/Repository/ExtraFieldRelTagRepository.php @@ -47,7 +47,7 @@ class ExtraFieldRelTagRepository extends ServiceEntityRepository ) ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('ft.itemId', intval($itemId)), + $queryBuilder->expr()->eq('ft.itemId', (int) $itemId), $queryBuilder->expr()->eq('ft.fieldId', $extraField->getId()) ) ); diff --git a/src/CoreBundle/Repository/ExtraFieldValuesRepository.php b/src/CoreBundle/Repository/ExtraFieldValuesRepository.php index 4de7260349..94b8338084 100644 --- a/src/CoreBundle/Repository/ExtraFieldValuesRepository.php +++ b/src/CoreBundle/Repository/ExtraFieldValuesRepository.php @@ -46,8 +46,8 @@ class ExtraFieldValuesRepository extends ServiceEntityRepository ) ->where( $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('f.extraFieldType', intval($extraFieldType)), - $queryBuilder->expr()->eq('fv.itemId', intval($itemId)), + $queryBuilder->expr()->eq('f.extraFieldType', (int) $extraFieldType), + $queryBuilder->expr()->eq('fv.itemId', (int) $itemId), $queryBuilder->expr()->eq('f.visibleToSelf', true) ) )