Minor - format code

pull/3016/head
Julio Montoya 6 years ago
parent 4da2c3784d
commit 85aa745256
  1. 3
      composer.json
  2. 2
      main/admin/access_url_check_user_session.php
  3. 1
      main/admin/access_urls.php
  4. 6
      main/admin/add_drh_to_user.php
  5. 1
      main/admin/archive_cleanup.php
  6. 2
      main/admin/career_diagram.php
  7. 2
      main/admin/careers.php
  8. 5
      main/admin/user_import.php
  9. 6
      main/inc/lib/api.lib.php
  10. 2
      main/inc/lib/extra_field_value.lib.php
  11. 4
      main/inc/lib/model.lib.php
  12. 3
      main/inc/lib/timeline.lib.php
  13. 2
      main/mySpace/admin.php
  14. 3
      main/mySpace/coaches.php
  15. 2
      main/mySpace/myStudents.php
  16. 3
      main/ticket/download.php
  17. 4
      phpstan.neon
  18. 9
      src/ThemeBundle/EventListener/TwigListener.php
  19. 10
      tests/phpstan/doctrine-orm-bootstrap.php

@ -185,7 +185,8 @@
"behat/mink-goutte-driver": "@stable", "behat/mink-goutte-driver": "@stable",
"behat/mink-selenium2-driver": "@stable", "behat/mink-selenium2-driver": "@stable",
"phpstan/phpstan": "^0.11.19", "phpstan/phpstan": "^0.11.19",
"phpstan/phpstan-symfony": "^0.11.6" "phpstan/phpstan-symfony": "^0.11.6",
"phpstan/phpstan-doctrine": "^0.11.6"
}, },
"scripts": { "scripts": {
"auto-scripts": { "auto-scripts": {

@ -94,7 +94,7 @@ foreach ($session_list as $session_item) {
if ($user['access_url_id'] != $url_id) { if ($user['access_url_id'] != $url_id) {
$user_link .= ' '.Display::return_icon('warning.png', get_lang('Users not added to the URL'), [], ICON_SIZE_MEDIUM); $user_link .= ' '.Display::return_icon('warning.png', get_lang('Users not added to the URL'), [], ICON_SIZE_MEDIUM);
$add = Display::return_icon('add.png', get_lang('Add users to an URL'), [], ICON_SIZE_MEDIUM); $add = Display::return_icon('add.png', get_lang('Add users to an URL'), [], ICON_SIZE_MEDIUM);
$link_to_add_user_in_url = '<a href="'.api_get_self().'?'.Security::remove_XSS($_SERVER['QUERY_STRING']).'&action=add_user_to_url&id_session='.$id_session.'&user_id='.$user['user_id'].'">'.$add.'</a>'; $link_to_add_user_in_url = '<a href="'.api_get_self().'?'.Security::remove_XSS($_SERVER['QUERY_STRING']).'&action=add_user_to_url&id_session='.$session_id.'&user_id='.$user['user_id'].'">'.$add.'</a>';
} }
} }
$html .= '<tr> $html .= '<tr>

@ -1,5 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Frontend script for multiple access urls. * Frontend script for multiple access urls.
* *

@ -19,7 +19,7 @@ $userRepository = UserManager::getRepository();
/** @var UserEntity $user */ /** @var UserEntity $user */
$user = UserManager::getManager()->find($_REQUEST['u']); $user = UserManager::getManager()->find($_REQUEST['u']);
if (!$user) { if ($user === null) {
api_not_allowed(true); api_not_allowed(true);
} }
@ -34,7 +34,7 @@ foreach ($subscribedUsers as $subscribedUser) {
/** @var UserEntity $hrm */ /** @var UserEntity $hrm */
$hrm = UserManager::getManager()->find($subscribedUser->getFriendUserId()); $hrm = UserManager::getManager()->find($subscribedUser->getFriendUserId());
if (!$hrm) { if ($hrm === null) {
continue; continue;
} }
@ -68,7 +68,7 @@ if ($form->validate()) {
/** @var UserEntity $hrm */ /** @var UserEntity $hrm */
$hrm = UserManager::getManager()->find($hrmId); $hrm = UserManager::getManager()->find($hrmId);
if (!$hrm) { if ($hrm === null) {
continue; continue;
} }

@ -6,7 +6,6 @@
// resetting the course id // resetting the course id
$cidReset = true; $cidReset = true;
// including some necessary files
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
ini_set('memory_limit', -1); ini_set('memory_limit', -1);

@ -75,7 +75,7 @@ $itemUrls = $extraFieldValue->get_values_by_handler_and_field_variable(
'career_urls', 'career_urls',
false, false,
false, false,
false 0
); );
$urlToString = ''; $urlToString = '';

@ -143,7 +143,7 @@ switch ($action) {
break; break;
case 'edit': case 'edit':
api_protect_admin_script(); api_protect_admin_script();
$id = isset($_GET['id']) ? (int) $_GET['id'] : null; $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$careerInfo = $career->get($id); $careerInfo = $career->get($id);
if (empty($careerInfo)) { if (empty($careerInfo)) {
api_not_allowed(true); api_not_allowed(true);

@ -61,7 +61,10 @@ function validate_data($users, $checkUniqueEmail = false)
// 2.1.1 // 2.1.1
$hasDash = strpos($username, '-'); $hasDash = strpos($username, '-');
if ($hasDash !== false) { if ($hasDash !== false) {
$user['message'] .= Display::return_message(get_lang('The username cannot contain the '-' character'), 'warning'); $user['message'] .= Display::return_message(
get_lang('The username cannot contain the \' - \' character'),
'warning'
);
$user['has_error'] = true; $user['has_error'] = true;
} }
// 2.2. Check whether the username was used twice in import file. // 2.2. Check whether the username was used twice in import file.

@ -6431,7 +6431,9 @@ function api_get_current_access_url_id()
* *
* @author Julio Montoya <gugli100@gmail.com> * @author Julio Montoya <gugli100@gmail.com>
* *
* @return int user id * @param int $user_id
*
* @return array
*/ */
function api_get_access_url_from_user($user_id) function api_get_access_url_from_user($user_id)
{ {
@ -6442,7 +6444,7 @@ function api_get_access_url_from_user($user_id)
FROM $table_url_rel_user url_rel_user FROM $table_url_rel_user url_rel_user
INNER JOIN $table_url u INNER JOIN $table_url u
ON (url_rel_user.access_url_id = u.id) ON (url_rel_user.access_url_id = u.id)
WHERE user_id = ".intval($user_id); WHERE user_id = ".$user_id;
$result = Database::query($sql); $result = Database::query($sql);
$list = []; $list = [];
while ($row = Database::fetch_array($result, 'ASSOC')) { while ($row = Database::fetch_array($result, 'ASSOC')) {

@ -502,8 +502,8 @@ class ExtraFieldValue extends Model
/* Enable this when field_loggeable is introduced as a table field (2.0) /* Enable this when field_loggeable is introduced as a table field (2.0)
if ($extraFieldInfo['field_loggeable'] == 1) { if ($extraFieldInfo['field_loggeable'] == 1) {
*/ */
$params['id'] = $field_values['id']; $params['id'] = $field_values['id'];
return parent::update($params, $showQuery); return parent::update($params, $showQuery);
} }
} }

@ -2,12 +2,10 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Class Model * Class Model.
* This class provides basic methods to implement a CRUD for a new table in the * This class provides basic methods to implement a CRUD for a new table in the
* database see examples in: career.lib.php and promotion.lib.php * database see examples in: career.lib.php and promotion.lib.php
* Include/require it in your code to use its features. * Include/require it in your code to use its features.
*
* @package chamilo.library
*/ */
class Model class Model
{ {

@ -4,8 +4,6 @@
/** /**
* Class Timeline * Class Timeline
* Timeline model class definition. * Timeline model class definition.
*
* @package chamilo.library
*/ */
class Timeline extends Model class Timeline extends Model
{ {
@ -31,6 +29,7 @@ class Timeline extends Model
*/ */
public function __construct() public function __construct()
{ {
parent::__construct();
$this->table = Database::get_course_table(TABLE_TIMELINE); $this->table = Database::get_course_table(TABLE_TIMELINE);
} }

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Special reporting page for admins. * * Special reporting page for admins.
*/ */
ob_start(); ob_start();

@ -2,9 +2,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Coaches reporting * Coaches reporting.
*/ */
ob_start(); ob_start();
$cidReset = true; $cidReset = true;

@ -4,11 +4,9 @@
use Chamilo\CourseBundle\Entity\CLpCategory; use Chamilo\CourseBundle\Entity\CLpCategory;
use ChamiloSession as Session; use ChamiloSession as Session;
/** /**
* Implements the tracking of students in the Reporting pages. * Implements the tracking of students in the Reporting pages.
*/ */
if (!isset($_GET['course'])) { if (!isset($_GET['course'])) {
$cidReset = true; $cidReset = true;
} }

@ -1,9 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/**
* @package chamilo.plugin.ticket
*/
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users(); api_block_anonymous_users();

@ -1,4 +1,8 @@
parameters: parameters:
symfony:
container_xml_path: '%rootDir%/../../../var/cache/dev/srcChamilo_KernelDevDebugContainer.xml'
doctrine :
objectManagerLoader: '%rootDir%/../../../tests/phpstan/doctrine-orm-bootstrap.php'
autoload_files: autoload_files:
- %rootDir%/../../../main/work/work.lib.php - %rootDir%/../../../main/work/work.lib.php
excludes_analyse: excludes_analyse:

@ -35,7 +35,7 @@ class TwigListener implements EventSubscriberInterface
public function onKernelRequest(RequestEvent $event) public function onKernelRequest(RequestEvent $event)
{ {
if (!$event->isMasterRequest()) { if (!$event->isMasterRequest()) {
return; return false;
} }
$container = $this->container; $container = $this->container;
@ -47,6 +47,11 @@ class TwigListener implements EventSubscriberInterface
$theme = api_get_visual_theme(); $theme = api_get_visual_theme();
$twig = $container->get('twig'); $twig = $container->get('twig');
if (empty($twig)) {
return false;
}
$twig->addGlobal('favico', \Template::getPortalIcon($theme)); $twig->addGlobal('favico', \Template::getPortalIcon($theme));
if ($settingsManager->getSetting('display.show_administrator_data') === 'true') { if ($settingsManager->getSetting('display.show_administrator_data') === 'true') {
@ -195,6 +200,8 @@ class TwigListener implements EventSubscriberInterface
} }
$twig->addGlobal("plugin_$region", $contentToString); $twig->addGlobal("plugin_$region", $contentToString);
} }
return true;
} }
/** /**

@ -0,0 +1,10 @@
<?php
use Chamilo\Kernel;
require dirname(__DIR__).'/../config/bootstrap.php';
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$kernel->boot();
return $kernel->getContainer()->get('doctrine')->getManager();
Loading…
Cancel
Save