Global variable or function should never be used 3

  • Major
  • Architecture

More information: https://insight.symfony.com/what-we-analyse/php.use_global_variable_or_function

  1. * @copyright Copyright (c) 2011 by CANTICO ({@link http://www.cantico.fr})
  2. */
  3. require_once 'base.php';
  4. function approbnotify_translate($str, $str_plurals = null, $number = null)

    approbnotify_translate() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by pauder
  5. {
  6. if ($translate = bab_functionality::get('Translate/Gettext'))
  7. {
  8. /* @var $translate Func_Translate_Gettext */
in programs/init.php, line 27
  1. */
  2. require_once 'base.php';
  3. function approbnotify_upgrade($version_base, $version_ini)

    approbnotify_upgrade() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by pauder
  4. {
  5. bab_functionality::includefile('PortletBackend');
  6. if (!class_exists('Func_PortletBackend')) {
  7. return false;
in programs/init.php, line 46
  1. return true;
  2. }
  3. function approbnotify_onDeleteAddon()

    approbnotify_onDeleteAddon() adds to the global scope. Prefer class properties or methods to let other developers know what this relates to.

    Time to fix: about 1 day
    Open Issue Permalink
    Last edited by pauder
  4. {
  5. require_once $GLOBALS['babInstallPath'].'utilit/functionalityincl.php';
  6. $functionalities = new bab_functionalities();
  7. $functionalities->unregister('PortletBackend/ApprobNotify');

exit() and die() functions should be avoided

  • Major
  • Bugrisk

More information: https://insight.symfony.com/what-we-analyse/php.use_exit_function

in programs/base.php, line 23
  1. //-------------------------------------------------------------------------
  2. /**
  3. * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
  4. * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr})
  5. */
  6. exit;

    This line stops the execution flow, without explanation. If this is for debug, you should remove it. If this is to deal with an error, use exceptions instead.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by pauder

Unused method, property, variable or parameter 2

  • Minor
  • Deadcode

More information: https://insight.symfony.com/what-we-analyse/php.unused_local_variable_or_private_member

  1. class PortletDefinition_ApprobNotify implements portlet_PortletDefinitionInterface
  2. {
  3. private $addon;

    This addon attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
  4. public function __construct()
  5. {
  6. $this->addon = bab_getAddonInfosInstance('approbnotify');
  7. }
  1. class Portlet_ApprobNotify extends Widget_Item implements portlet_PortletInterface
  2. {
  3. private $options = array();

    This options attribute is declared but never used. You should remove it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
  4. /**
  5. * @param Widget_Canvas $canvas
  6. * @return string

Text files should end with a newline character 6

  • Info
  • Codestyle

More information: https://insight.symfony.com/what-we-analyse/missing_e_o_l

in programs/base.php, line 23
  1. //-------------------------------------------------------------------------
  2. /**
  3. * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL)
  4. * @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr})
  5. */
  6. exit;

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
  1. return $translate->translate($str, $str_plurals, $number);
  2. }
  3. return $str;
  4. }

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
in programs/init.php, line 53
  1. require_once $GLOBALS['babInstallPath'].'utilit/functionalityincl.php';
  2. $functionalities = new bab_functionalities();
  3. $functionalities->unregister('PortletBackend/ApprobNotify');
  4. return true;
  5. }

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
in composer.json, line 10
  1. "license": "GPL-2.0+",
  2. "minimum-stability": "dev",
  3. "require": {
  4. "php": ">=5.1.0"
  5. }
  6. }

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
in programs/addonini.php, line 25
  1. [addons]
  2. widgets =">=1.0.31"
  3. LibTranslate =">=1.12.0rc3.01"
  4. ;*/

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
in README.md, line 3
  1. # approbnotify #
  2. [![SensioLabsInsight](https://insight.sensiolabs.com/projects/44427320-2ac6-4466-8f9e-39c006a0574c/mini.png)](https://insight.sensiolabs.com/projects/44427320-2ac6-4466-8f9e-39c006a0574c)

    This file ends with no newline character. It won't render properly on a terminal, and it's considered a bad practice. Add a simple line feed as the last character to fix it.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by Paul de Rosanbo

Class should be unique per PHP file

  • Info
  • Codestyle

More information: https://insight.symfony.com/what-we-analyse/php.file_contains_more_than_one_class

This file contains 3 classes. Keeping only one class per file is a standard in the PHP community, since it promotes interoperability and maintainability.

Time to fix: about 6 hours
Open Issue Permalink
Last edited by pauder
  • Func_PortletBackend_ApprobNotify (defined at line 28)
  • PortletDefinition_ApprobNotify (defined at line 77)
  • Portlet_ApprobNotify (defined at line 159)

PHP code should follow PSR-1 basic coding standard

  • Info
  • Codestyle

More information: https://insight.symfony.com/what-we-analyse/php.psr1

  1. {
  2. return $this->Portlet_ApprobNotify();
  3. }
  4. public function Portlet_ApprobNotify()

    Method names should be declared in camelCase.
    You should rename this method to comply with PSR-1.

    Time to fix: about 15 minutes
    Open Issue Permalink
    Last edited by pauder
  5. {
  6. return new PortletDefinition_ApprobNotify();
  7. }
  8. }

Project files should not mix end of lines

  • Info
  • Codestyle

More information: https://insight.symfony.com/what-we-analyse/invalid_e_o_l

Some files contain mixed and/or invalid end of lines ( \r\n instead of \n). Homogenize them to improve compatibility across different platforms.

  • README.md

To solve this issue, run the below command:

Time to fix: about 15 minutes
Open Issue Permalink
Collective
sed -i "s/\r//g" 'README.md'