Global variable or function should never be used 7

  • Major
  • Architecture

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

  1. define('LINE_WIDTH', 75);
  2. define('LINE', str_repeat('-', LINE_WIDTH)."\n");
  3. function bailout($message)

    bailout() 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 Bernhard Schussek
  4. {
  5. echo wordwrap($message, LINE_WIDTH)." Aborting.\n";
  6. exit(1);
  7. }
  • fabpot

    Ignored on Tue, 02 Feb 2016 14:02:08 GMT
  1. echo wordwrap($message, LINE_WIDTH)." Aborting.\n";
  2. exit(1);
  3. }
  4. function strip_minor_versions($version)

    strip_minor_versions() 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 Bernhard Schussek
  5. {
  6. preg_match('/^(?P<version>[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches);
  7. return $matches['version'];
  8. }
  • fabpot

    Ignored on Tue, 02 Feb 2016 14:02:24 GMT
  1. preg_match('/^(?P<version>[0-9]\.[0-9]|[0-9]{2,})/', $version, $matches);
  2. return $matches['version'];
  3. }
  4. function centered($text)

    centered() 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 Bernhard Schussek
  5. {
  6. $padding = (int) ((LINE_WIDTH - strlen($text)) / 2);
  7. return str_repeat(' ', $padding).$text;
  8. }
  • fabpot

    Ignored on Tue, 02 Feb 2016 14:02:28 GMT
  1. $padding = (int) ((LINE_WIDTH - strlen($text)) / 2);
  2. return str_repeat(' ', $padding).$text;
  3. }
  4. function cd($dir)

    cd() 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 Bernhard Schussek
  5. {
  6. if (false === chdir($dir)) {
  7. bailout("Could not switch to directory $dir.");
  8. }
  9. }
  • fabpot

    Ignored on Tue, 02 Feb 2016 14:02:31 GMT
  1. if (false === chdir($dir)) {
  2. bailout("Could not switch to directory $dir.");
  3. }
  4. }
  5. function run($command)

    run() 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 Bernhard Schussek
  6. {
  7. exec($command, $output, $status);
  8. if (0 !== $status) {
  9. $output = implode("\n", $output);
  • fabpot

    Ignored on Tue, 02 Feb 2016 14:02:36 GMT
  1. bailout("\"$command\" failed.");
  2. }
  3. }
  4. function get_icu_version_from_genrb($genrb)

    get_icu_version_from_genrb() 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 Bernhard Schussek
  5. {
  6. exec($genrb.' --version 2>&1', $output, $status);
  7. if (0 !== $status) {
  8. bailout($genrb.' failed.');
  • fabpot

    Ignored on Tue, 02 Feb 2016 14:02:41 GMT
  1. if (!function_exists('dump')) {
  2. /**
  3. * @author Nicolas Grekas <p@tchwork.com>
  4. */
  5. function dump($var)

    dump() 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 Nicolas Grekas
  6. {
  7. foreach (func_get_args() as $var) {
  8. VarDumper::dump($var);
  9. }
  10. }
  • fabpot

    Ignored on Tue, 02 Feb 2016 14:02:45 GMT

Code should not be duplicated

  • Minor
  • Architecture

More information: https://insight.sensiolabs.com/what-we-analyse/php.duplicated_code

  1. /**
  2. * Return a valid Unix shell.
  3. *
  4. * @return string|bool The valid shell name, false in case no valid shell is found
  5. */
  6. private function getShell()

    The next 36 lines appear both in src/Symfony/Component/Console/Helper/DialogHelper.php:435 and src/Symfony/Component/Console/Helper/QuestionHelper.php:403.

    Time to fix: about 4 hours
    Open Issue Permalink
    Last edited by Romain Neutron
  7. {
  8. if (null !== self::$shell) {
  9. return self::$shell;
  10. }
  • fabpot

    Ignored on Tue, 16 Feb 2016 07:28:48 GMT

Interfaces names should end with "Interface"

  • Info
  • Codestyle

More information: https://insight.sensiolabs.com/what-we-analyse/php.interface_has_no_interface_suffix

  1. * Contains resolved option values.
  2. *
  3. * @author Bernhard Schussek <bschussek@gmail.com>
  4. * @author Tobias Schultze <http://tobion.de>
  5. */
  6. interface Options extends \ArrayAccess, \Countable

    Interface Options should be named OptionsInterface for better clarity.

    Time to fix: about 1 hour
    Open Issue Permalink
    Last edited by Bernhard Schussek
  7. {
  8. }
  • fabpot

    Ignored on Sun, 27 Sep 2015 14:52:50 GMT