gdbots/common-php

View on GitHub

Showing 137 of 137 total issues

Remove error control operator '@' on line 27.
Open

    public function __construct($lat, $lon)
    {
        @trigger_error(sprintf('"%s" is deprecated.  Use "Gdbots\Pbj\WellKnown\GeoPoint" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);

        $this->latitude = (float)$lat;
Severity: Minor
Found in src/Common/GeoPoint.php by phpmd

ErrorControlOperator

Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

Example

function foo($filePath) {
    $file = @fopen($filPath); // hides exceptions
    $key = @$array[$notExistingKey]; // assigns null to $key
}

Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

Avoid too many return statements within this method.
Open

        return (string)$var;
Severity: Major
Found in src/Common/Util/StringUtils.php - About 30 mins to fix

    Missing class import via use statement (line '120', column '42').
    Open

                self::$values[$class] = (new \ReflectionClass($class))->getConstants();
    Severity: Minor
    Found in src/Common/Enum.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '33', column '23').
    Open

                throw new \InvalidArgumentException('Latitude must be within range [-90.0, 90.0]');
    Severity: Minor
    Found in src/Common/GeoPoint.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '37', column '23').
    Open

                throw new \InvalidArgumentException('Longitude must be within range [-180.0, 180.0]');
    Severity: Minor
    Found in src/Common/GeoPoint.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    Missing class import via use statement (line '65', column '19').
    Open

            throw new \InvalidArgumentException('Payload must be a GeoJson "Point" type.');
    Severity: Minor
    Found in src/Common/GeoPoint.php by phpmd

    MissingImport

    Since: 2.7.0

    Importing all external classes in a file through use statements makes them clearly visible.

    Example

    function make() {
        return new \stdClass();
    }

    Source http://phpmd.org/rules/cleancode.html#MissingImport

    The method isValid has a boolean flag argument $allowSlashes, which is a certain sign of a Single Responsibility Principle violation.
    Open

        public static function isValid($string, $allowSlashes = false)
    Severity: Minor
    Found in src/Common/Util/SlugUtils.php by phpmd

    BooleanArgumentFlag

    Since: 1.4.0

    A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

    Example

    class Foo {
        public function bar($flag = true) {
        }
    }

    Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

    Avoid too many return statements within this method.
    Open

                    return true;
    Severity: Major
    Found in src/Common/Util/HashtagUtils.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return false;
      Severity: Major
      Found in src/Common/Util/HashtagUtils.php - About 30 mins to fix

        Remove error control operator '@' on line 36.
        Open

            private function __construct()
            {
                @trigger_error(sprintf('"%s" is deprecated.  Use "Gdbots\Pbj\WellKnown\Microtime" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);
            }
        Severity: Minor
        Found in src/Common/Microtime.php by phpmd

        ErrorControlOperator

        Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

        Example

        function foo($filePath) {
            $file = @fopen($filPath); // hides exceptions
            $key = @$array[$notExistingKey]; // assigns null to $key
        }

        Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

        Missing class import via use statement (line '105', column '23').
        Open

                    throw new \InvalidArgumentException(
        Severity: Minor
        Found in src/Common/Microtime.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        The method getTraits has a boolean flag argument $deep, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public static function getTraits($class, $deep = true, $autoload = true)
        Severity: Minor
        Found in src/Common/Util/ClassUtils.php by phpmd

        BooleanArgumentFlag

        Since: 1.4.0

        A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

        Example

        class Foo {
            public function bar($flag = true) {
            }
        }

        Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

        Missing class import via use statement (line '54', column '30').
        Open

                $date = $date ?: new \DateTime();

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '25', column '23').
        Open

                    throw new \InvalidArgumentException(
        Severity: Minor
        Found in src/Identifiers/StringIdentifier.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Remove error control operator '@' on line 18.
        Open

            public function __construct($number, $scale = null)
            {
                @trigger_error(sprintf('"%s" is deprecated.  Use "Gdbots\Pbj\WellKnown\BigNumber" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);
                parent::__construct($number, $scale);
            }
        Severity: Minor
        Found in src/Common/BigNumber.php by phpmd

        ErrorControlOperator

        Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

        Example

        function foo($filePath) {
            $file = @fopen($filPath); // hides exceptions
            $key = @$array[$notExistingKey]; // assigns null to $key
        }

        Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

        The method create has a boolean flag argument $camelize, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public static function create($str, $camelize = true)
        Severity: Minor
        Found in src/Common/Util/HashtagUtils.php by phpmd

        BooleanArgumentFlag

        Since: 1.4.0

        A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

        Example

        class Foo {
            public function bar($flag = true) {
            }
        }

        Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

        The method create has a boolean flag argument $allowSlashes, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public static function create($string, $allowSlashes = false)
        Severity: Minor
        Found in src/Common/Util/SlugUtils.php by phpmd

        BooleanArgumentFlag

        Since: 1.4.0

        A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

        Example

        class Foo {
            public function bar($flag = true) {
            }
        }

        Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

        Remove error control operator '@' on line 23.
        Open

            protected function __construct($slug)
            {
                @trigger_error(sprintf('"%s" is deprecated.  Use "Gdbots\Pbj\WellKnown\DatedSlugIdentifier" from "gdbots/pbj" 1.1.x or later instead.', __CLASS__), E_USER_DEPRECATED);
        
                if (!is_string($slug)) {

        ErrorControlOperator

        Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

        Example

        function foo($filePath) {
            $file = @fopen($filPath); // hides exceptions
            $key = @$array[$notExistingKey]; // assigns null to $key
        }

        Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

        Avoid too many return statements within this method.
        Open

                    return 'false';
        Severity: Major
        Found in src/Common/Util/StringUtils.php - About 30 mins to fix

          The method isValidTimestamp has a boolean flag argument $allowNegative, which is a certain sign of a Single Responsibility Principle violation.
          Open

              public static function isValidTimestamp($timestamp, $allowNegative = false)
          Severity: Minor
          Found in src/Common/Util/DateUtils.php by phpmd

          BooleanArgumentFlag

          Since: 1.4.0

          A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

          Example

          class Foo {
              public function bar($flag = true) {
              }
          }

          Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

          Severity
          Category
          Status
          Source
          Language