vaimo/composer-patches

View on GitHub
src/Config/Context.php

Summary

Maintainability
A
1 hr
Test Coverage

Method getOperationSystemName has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getOperationSystemName()
    {
        $typeId = OsInfo::os();

        $labels = array(
Severity: Minor
Found in src/Config/Context.php - About 1 hr to fix

    Avoid using static access to class '\loophp\phposinfo\OsInfo' in method 'getOperationSystemTypeCode'.
    Open

                    strtolower(OsInfo::os())
    Severity: Minor
    Found in src/Config/Context.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\loophp\phposinfo\OsInfo' in method 'getOperationSystemName'.
    Open

            $typeId = OsInfo::os();
    Severity: Minor
    Found in src/Config/Context.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\loophp\phposinfo\OsInfo' in method '__construct'.
    Open

            OsInfo::register();
    Severity: Minor
    Found in src/Config/Context.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Avoid using static access to class '\loophp\phposinfo\OsInfo' in method 'getOperationSystemFamily'.
    Open

            $familyId = OsInfo::family(); // phpcs:ignore PHPCompatibility.Extensions.RemovedExtensions
    Severity: Minor
    Found in src/Config/Context.php by phpmd

    StaticAccess

    Since: 1.4.0

    Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

    Example

    class Foo
    {
        public function bar()
        {
            Bar::baz();
        }
    }

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

    Define a constant instead of duplicating this literal "mingw" 3 times.
    Open

                OsName::MINGW => 'mingw',
    Severity: Critical
    Found in src/Config/Context.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "cygwin" 4 times.
    Open

                OsName::CYGWIN => 'cygwin',
    Severity: Critical
    Found in src/Config/Context.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "windows" 5 times.
    Open

                OsName::WIN32 => 'windows',
    Severity: Critical
    Found in src/Config/Context.php by sonar-php

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Reference to constant HPUX from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::HPUX => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant WINDOWS from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::WINDOWS => 'windows',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant WINDOWS from undeclared class \loophp\phposinfo\Enum\FamilyName
    Open

                FamilyName::WINDOWS => 'windows',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Call to method register from undeclared class \loophp\phposinfo\OsInfo
    Open

            OsInfo::register();
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant DARWIN from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::DARWIN => 'mac',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant NETBSD from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::NETBSD => 'bsd',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant MINIX from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::MINIX => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant SUNOS from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::SUNOS => 'sun',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant MINGW from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::MINGW => 'mingw',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant MINGW32NT61 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::MINGW32NT61 => 'mingw',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant AIX from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::AIX => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant SCOSV from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::SCOSV => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Call to method os from undeclared class \loophp\phposinfo\OsInfo
    Open

            $typeId = OsInfo::os();
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant DEBIANFREEBSD from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::DEBIANFREEBSD => 'bsd',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant WIN32 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::WIN32 => 'windows',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant CYGWIN from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::CYGWIN => 'cygwin',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant UNIXWARE from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::UNIXWARE => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant LINUX from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::LINUX => 'linux',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant CYGWINNT61 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::CYGWINNT61 => 'cygwin',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant CYGWINNT51 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::CYGWINNT51 => 'cygwin',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant ULTRIX from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::ULTRIX => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant OPENBSD from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::OPENBSD => 'bsd',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant SINIXY from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::SINIXY => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant UWINW7 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::UWINW7 => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant DRAGONFLY from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::DRAGONFLY => 'bsd',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant WINDOWSNT from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::WINDOWSNT => 'windows',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant LINUX from undeclared class \loophp\phposinfo\Enum\FamilyName
    Open

                FamilyName::LINUX => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant SOLARIS from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::SOLARIS => 'solaris',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant CYGWINNT61WOW64 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::CYGWINNT61WOW64 => 'cygwin',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant BSD from undeclared class \loophp\phposinfo\Enum\FamilyName
    Open

                FamilyName::BSD => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant OSF1 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::OSF1 => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant QNX from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::QNX => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant RELIANTUNIXY from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::RELIANTUNIXY => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant MSYSNT61 from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::MSYSNT61 => 'mingw'
    Severity: Critical
    Found in src/Config/Context.php by phan

    Call to method os from undeclared class \loophp\phposinfo\OsInfo
    Open

                    strtolower(OsInfo::os())
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant FREEBSD from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::FREEBSD => 'bsd',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant GNUFREEBSD from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::GNUFREEBSD => 'bsd',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant GNULINUX from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::GNULINUX => 'linux',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant WINNT from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::WINNT => 'windows',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Call to method family from undeclared class \loophp\phposinfo\OsInfo
    Open

            $familyId = OsInfo::family(); // phpcs:ignore PHPCompatibility.Extensions.RemovedExtensions
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant GNU from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::GNU => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant UWIN from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::UWIN => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant ZOS from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::ZOS => 'zos',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant DARWIN from undeclared class \loophp\phposinfo\Enum\FamilyName
    Open

                FamilyName::DARWIN => 'unix',
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant UNIX_ON_WINDOWS from undeclared class \loophp\phposinfo\Enum\FamilyName
    Open

                FamilyName::UNIX_ON_WINDOWS => 'windows-unix'
    Severity: Critical
    Found in src/Config/Context.php by phan

    Reference to constant GNUKFREEBSD from undeclared class \loophp\phposinfo\Enum\OsName
    Open

                OsName::GNUKFREEBSD => 'bsd',
    Severity: Critical
    Found in src/Config/Context.php by phan

    There are no issues that match your filters.

    Category
    Status