YetiForceCompany/YetiForceCRM

View on GitHub
app/Installer/Developer.php

Summary

Maintainability
A
0 mins
Test Coverage
F
0%

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

    public static function generateSwaggerByType(string $type, string $path = self::PATH, $errorHandler = true): string
Severity: Minor
Found in app/Installer/Developer.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 using static access to class '\OpenApi\Generator' in method 'generateSwaggerByType'.
Open

        $openApi = \OpenApi\Generator::scan([ROOT_DIRECTORY . '/api/webservice/' . $type]);
Severity: Minor
Found in app/Installer/Developer.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 '\App\ErrorHandler' in method 'generateSwagger'.
Open

            $errorString = \App\ErrorHandler::error2string($errNo);
Severity: Minor
Found in app/Installer/Developer.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 '\App\ErrorHandler' in method 'generateSwaggerByType'.
Open

                $errorString = \App\ErrorHandler::error2string($errNo);
Severity: Minor
Found in app/Installer/Developer.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

Call to method scan from undeclared class \OpenApi\Generator (Did you mean class \Generator)
Open

        $openApi = \OpenApi\Generator::scan([ROOT_DIRECTORY . '/api/webservice/' . $type]);
Severity: Critical
Found in app/Installer/Developer.php by phan

Expected @param annotation for path to be before the @param annotation for errorHandler
Open

     * @param bool   $errorHandler
Severity: Info
Found in app/Installer/Developer.php by phan

Argument 1 (error_handler) is Closure(mixed,mixed,mixed,mixed):void but \set_error_handler() takes callable(int,string):bool|callable(int,string,string):bool|callable(int,string,string,int):bool|callable(int,string,string,int,array):bool|null
Open

        set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
Severity: Minor
Found in app/Installer/Developer.php by phan

Argument 1 (error_handler) is Closure(mixed,mixed,mixed,mixed):void but \set_error_handler() takes callable(int,string):bool|callable(int,string,string):bool|callable(int,string,string,int):bool|callable(int,string,string,int,array):bool|null
Open

            set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
Severity: Minor
Found in app/Installer/Developer.php by phan

Spaces must be used to indent lines; tabs are not allowed
Open

     * Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations.
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        if ($errorHandler) {
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $msg = reset($errorString) . ": {$errStr}\nFile: {$errFile}\nLine: $errLine" . PHP_EOL;
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param bool   $errorHandler
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $errorString = \App\ErrorHandler::error2string($errNo);
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach (\Api\Core\Containers::$list as $type) {
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $openApi->saveAs(ROOT_DIRECTORY . "{$path}/{$type}.json");
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $openApi->toJson();
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $path
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public const PATH = '/api/doc';
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     *
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                $msg = reset($errorString) . ": {$errStr}\nFile: {$errFile}\nLine: $errLine" . PHP_EOL;
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /** @var string Default path */
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $openApi->saveAs(ROOT_DIRECTORY . "{$path}/{$type}.yaml");
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $path
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            set_error_handler(function ($errNo, $errStr, $errFile, $errLine) {
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $openApi = \OpenApi\Generator::scan([ROOT_DIRECTORY . '/api/webservice/' . $type]);
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @return string
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations by type.
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $json = '';
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                echo "<pre>$msg</pre><hr>";
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            echo "<pre>$msg</pre><hr>";
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                $errorString = \App\ErrorHandler::error2string($errNo);
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function generateSwaggerByType(string $type, string $path = self::PATH, $errorHandler = true): string
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public static function generateSwagger(string $path = self::PATH): string
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }, E_ALL);
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            $json .= self::generateSwaggerByType($type, $path, false);
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        return $json;
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * @param string $type
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            }, E_ALL);
Severity: Minor
Found in app/Installer/Developer.php by phpcodesniffer

There are no issues that match your filters.

Category
Status