YetiForceCompany/YetiForceCRM

View on GitHub
api/webservice/Controller.php

Summary

Maintainability
B
4 hrs
Test Coverage
A
90%

debugRequest accesses the super-global variable $_SERVER.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

debugRequest accesses the super-global variable $_GET.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

debugRequest accesses the super-global variable $_SERVER.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

debugRequest accesses the super-global variable $_POST.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

debugRequest accesses the super-global variable $_SERVER.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

debugRequest accesses the super-global variable $_SERVER.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

debugRequest accesses the super-global variable $_GET.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

debugRequest accesses the super-global variable $_POST.
Open

    public function debugRequest(): void
    {
        if (\App\Config::debug('apiLogAllRequests')) {
            $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
            $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
Severity: Minor
Found in api/webservice/Controller.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method preProcess has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function preProcess(): bool
    {
        register_shutdown_function(function () {
            if ($error = error_get_last()) {
                $this->errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
Severity: Minor
Found in api/webservice/Controller.php - About 1 hr to fix

    Method debugRequest has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function debugRequest(): void
        {
            if (\App\Config::debug('apiLogAllRequests')) {
                $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
                $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
    Severity: Minor
    Found in api/webservice/Controller.php - About 1 hr to fix

      Method process has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function process(): void
          {
              $handlerClass = $this->getActionClassName();
              $this->request->loadData();
              $this->debugRequest();
      Severity: Minor
      Found in api/webservice/Controller.php - About 1 hr to fix

        Function debugRequest has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            public function debugRequest(): void
            {
                if (\App\Config::debug('apiLogAllRequests')) {
                    $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
                    $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
        Severity: Minor
        Found in api/webservice/Controller.php - About 55 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function getActionClassName has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function getActionClassName(): string
            {
                $type = $this->request->getByType('_container', 'Standard');
                $this->request->delete('_container');
                $actionName = $this->request->getByType('action', 'Alnum');
        Severity: Minor
        Found in api/webservice/Controller.php - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Avoid using undefined variables such as '$listTables' which will lead to PHP notices.
        Open

                $this->app['tables'] = Core\Containers::$listTables[$this->app['type']] ?? [];
        Severity: Minor
        Found in api/webservice/Controller.php by phpmd

        UndefinedVariable

        Since: 2.8.0

        Detects when a variable is used that has not been defined before.

        Example

        class Foo
        {
            private function bar()
            {
                // $message is undefined
                echo $message;
            }
        }

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

        The class Controller has a coupling between objects value of 14. Consider to reduce the number of dependencies under 13.
        Open

        class Controller
        {
            /** @var \self */
            private static $instance;
        
        
        Severity: Minor
        Found in api/webservice/Controller.php by phpmd

        CouplingBetweenObjects

        Since: 1.1.0

        A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

        Example

        class Foo {
            /**
             * @var \foo\bar\X
             */
            private $x = null;
        
            /**
             * @var \foo\bar\Y
             */
            private $y = null;
        
            /**
             * @var \foo\bar\Z
             */
            private $z = null;
        
            public function setFoo(\Foo $foo) {}
            public function setBar(\Bar $bar) {}
            public function setBaz(\Baz $baz) {}
        
            /**
             * @return \SplObjectStorage
             * @throws \OutOfRangeException
             * @throws \InvalidArgumentException
             * @throws \ErrorException
             */
            public function process(\Iterator $it) {}
        
            // ...
        }

        Source https://phpmd.org/rules/design.html#couplingbetweenobjects

        Avoid assigning values to variables in if clauses and the like (line '75', column '8').
        Open

            public function preProcess(): bool
            {
                register_shutdown_function(function () {
                    if ($error = error_get_last()) {
                        $this->errorHandler($error['type'], $error['message'], $error['file'], $error['line']);
        Severity: Minor
        Found in api/webservice/Controller.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

        Avoid using static access to class '\App\Log' in method 'errorHandler'.
        Open

                    \App\Log::error($no . ': ' . $str . ' in ' . $file . ', line ' . $line);
        Severity: Minor
        Found in api/webservice/Controller.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 'Api\Core\Response' in method '__construct'.
        Open

                $this->response = Core\Response::getInstance();
        Severity: Minor
        Found in api/webservice/Controller.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 'Api\Core\Request' in method '__construct'.
        Open

                $this->request = Core\Request::init();
        Severity: Minor
        Found in api/webservice/Controller.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\Request' in method '__construct'.
        Open

                $this->method = \App\Request::getRequestMethod();
        Severity: Minor
        Found in api/webservice/Controller.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\Request' in method 'debugRequest'.
        Open

                    $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
        Severity: Minor
        Found in api/webservice/Controller.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\RequestUtil' in method 'debugRequest'.
        Open

                    $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
        Severity: Minor
        Found in api/webservice/Controller.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 'Api\Core\Auth' in method 'preProcess'.
        Open

                Core\Auth::init($this);
        Severity: Minor
        Found in api/webservice/Controller.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\RequestUtil' in method 'preProcess'.
        Open

                if (!empty($this->app['ips']) && !\in_array(\App\RequestUtil::getRemoteIP(true), array_map('trim', explode(',', $this->app['ips'])))) {
        Severity: Minor
        Found in api/webservice/Controller.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 assigning values to variables in if clauses and the like (line '210', column '8').
        Open

            public function debugRequest(): void
            {
                if (\App\Config::debug('apiLogAllRequests')) {
                    $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";
                    $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;
        Severity: Minor
        Found in api/webservice/Controller.php by phpmd

        IfStatementAssignment

        Since: 2.7.0

        Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($foo = 'bar') { // possible typo
                    // ...
                }
                if ($baz = 0) { // always false
                    // ...
                }
            }
        }

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

        Avoid using static access to class '\App\Config' in method 'debugRequest'.
        Open

                if (\App\Config::debug('apiLogAllRequests')) {
        Severity: Minor
        Found in api/webservice/Controller.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 "action" 3 times.
        Open

                if ($this->request->isEmpty('action', true)) {
        Severity: Critical
        Found in api/webservice/Controller.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.

        Doc-block of getInstance contains declared return type \self which is incompatible with the return type \Api\Controller declared in the signature
        Open

             * @return \self
        Severity: Minor
        Found in api/webservice/Controller.php by phan

        Assigning \Api\Controller to property but \Api\Controller::$instance is \self
        Open

                return self::$instance = new self();
        Severity: Minor
        Found in api/webservice/Controller.php by phan

        Return type of getInstance() is undeclared type \self
        Open

            public static function getInstance(): self
        Severity: Minor
        Found in api/webservice/Controller.php by phan

        Call to method error from undeclared class \App\Log
        Open

                    \App\Log::error($no . ': ' . $str . ' in ' . $file . ', line ' . $line);
        Severity: Critical
        Found in api/webservice/Controller.php by phan

        Argument 1 (raw) is 'module' but \Api\Core\Request::getModule() takes bool|true defined at /code/app/Request.php:548
        Open

                $module = $this->request->getModule('module');
        Severity: Minor
        Found in api/webservice/Controller.php by phan

        Remove the code after this "throw".
        Open

                            throw new Core\Exception('Unsupported response type: ' . $this->actionHandler->responseType, 400);
        Severity: Major
        Found in api/webservice/Controller.php by sonar-php

        Jump statements (return, break, continue, and goto) and throw expressions move control flow out of the current code block. Typically, any statements in a block that come after a jump or throw are simply wasted keystrokes lying in wait to confuse the unwary.

        Rarely, as illustrated below, code after a jump or throw is reachable. However, such code is difficult to understand, and should be refactored.

        Noncompliant Code Example

        function fun($a) {
          $i = 10;
          return $i + $a;
          $i++;             // this is never executed
        }
        
        function foo($a) {
          if ($a == 5) {
            goto error;
          } else {
            // do the job
          }
          return;
        
          error:
            printf("don't use 5"); // this is reachable but unreadable
        
        }
        

        Compliant Solution

        function fun($a) {
          $i = 10;
          return $i + $a;
        }
        
        function foo($a) {
          if ($a == 5) {
            handleError();
          } else {
            // do the job
          }
          return;
        }
        

        See

        • MISRA C:2004, 14.1 - There shall be no unreachable code
        • MISRA C++:2008, 0-1-1 - A project shall not contain unreachable code
        • MISRA C++:2008, 0-1-9 - There shall be no dead code
        • MISRA C:2012, 2.1 - A project shall not contain unreachable code
        • MISRA C:2012, 2.2 - There shall be no dead code
        • MITRE, CWE-561 - Dead Code
        • CERT, MSC56-J. - Detect and remove superfluous code and values
        • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
        • CERT, MSC07-CPP. - Detect and remove dead code

        Avoid variables with short names like $no. Configured minimum length is 3.
        Open

            public static function errorHandler(int $no, string $str, string $file, int $line): void
        Severity: Minor
        Found in api/webservice/Controller.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

        Avoid variables with short names like $e. Configured minimum length is 3.
        Open

            public function handleError(\Throwable $e): void
        Severity: Minor
        Found in api/webservice/Controller.php by phpmd

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

        Source https://phpmd.org/rules/naming.html#shortvariable

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

            public $request;

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

             * Construct.

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

            /** @var array Headers. */

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

            /** @var array Current server details (w_#__servers). */

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

                $this->response = Core\Response::getInstance();

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

            public function __construct()

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

                $this->request = Core\Request::init();

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

            /** @var \self */

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

            private $actionHandler;

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

            /**

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

            public static function getInstance(): self

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

                    return self::$instance;

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

                return self::$instance = new self();

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

            }

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

            public $app;

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

            {

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

             * @return bool

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

            /** @var string Request method. */

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

            /**

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

             *

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

             */

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

                $this->headers = $this->request->getHeaders();

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

            {

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

                $this->response->setAcceptableMethods($this->actionHandler->allowedMethod);

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

            {

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

             */

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

                $actionName = $this->request->getByType('action', 'Alnum');

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

                    }

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

                    }

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

            public function debugRequest(): void

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

            /**

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

            /** @var \Api\Core\Request Request instance. */

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

             * @return \self

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

                    }

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

                }

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

                $this->app['tables'] = Core\Containers::$listTables[$this->app['type']] ?? [];

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

                $this->response->setAcceptableHeaders($this->actionHandler->allowedHeaders);

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

                $this->actionHandler->preProcess();

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

                            break;

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

                $this->response->send();

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

            }

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

                    $log .= '----------- Headers -----------' . PHP_EOL;

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

                    file_put_contents(ROOT_DIRECTORY . '/cache/logs/webserviceDebug.log', $log, FILE_APPEND);

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

             */

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

                if (isset(self::$instance)) {

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

                Core\Auth::init($this);

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

             *

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

                $this->request->loadData();

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

                $return = \call_user_func([$this->actionHandler, strtolower($this->method)]);

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

                                'status' => 1,

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

                            break;

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

             *

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

                    $log .= print_r($this->request->getAllRaw(), true) . PHP_EOL;

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

             * Handle error function.

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

            private static $instance;

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

            /**

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

             */

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

            public function preProcess(): bool

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

                }

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

                if (null !== $return) {

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

                        case 'data':

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

                                'result' => $return,

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

                        default:

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

                    $className = "Api\\$type\\$module\\$actionName";

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

                    }

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

                        $log .= print_r($payload, true) . PHP_EOL;

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

                $this->response->setRequest($this->request);

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

                $this->method = \App\Request::getRequestMethod();

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

                return true;

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

             *

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

             *

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

            /**

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

             */

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

             */

        Line exceeds 120 characters; contains 139 characters
        Open

                    $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";

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

                    $log .= 'REQUEST_METHOD: ' . \App\Request::getRequestMethod() . PHP_EOL;

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

                        $log .= "----------- _GET -----------\n";

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

            public $response;

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

            public $method;

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

            public $headers;

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

             * Pre process function.

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

                    $this->response->setAcceptableHeaders($handler->allowedHeaders);

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

            }

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

                    switch ($this->actionHandler->responseType) {

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

                            $this->response->setBody([

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

            }

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

                    if (class_exists($className)) {

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

                $className = "Api\\$type\\BaseAction\\$actionName";

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

                    foreach ($this->request->getHeaders() as $key => $header) {

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

                    if ($_GET) {

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

             * Get controller instance.

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

                    if ($error = error_get_last()) {

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

                    $handlerClass = $this->getActionClassName();

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

                \App\Process::$processType = $this->app['type'];

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

                }

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

             * Post process function.

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

             * @return void

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

            /**

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

                $this->request->delete('_container');

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

                    if (class_exists($className)) {

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

                if (\App\Config::debug('apiLogAllRequests')) {

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

                    $log .= 'REQUEST_URI: ' . $_SERVER['REQUEST_URI'] . PHP_EOL;

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

                        $log .= print_r($_GET, true) . PHP_EOL;

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

            /** @var \Api\Core\Response Response instance. */

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

            }

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

            public function postProcess(): void

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

             * @throws \Api\Core\Exception

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

             * @return string

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

                $module = $this->request->getModule('module');

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

                    $className = "Api\\$type\\BaseModule\\$actionName";

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

                    $log .= '----------- Request data -----------' . PHP_EOL;

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

             * @throws \Api\Core\Exception

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

                if ('OPTIONS' === $this->method) {

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

                    $handler = new $handlerClass();

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

                    $this->response->setAcceptableMethods($handler->allowedMethod);

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

             * Get action class name.

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

                        return $className;

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

                }

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

                throw new Core\Exception('No action found', 405);

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

            /**

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

                    $log = '============ Request ' . \App\RequestUtil::requestId() . ' (Controller) ======  ' . date('Y-m-d H:i:s') . "  ======\n";

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

                    throw new Core\Exception('Web service - Applications: Unauthorized', 401);

        Line exceeds 120 characters; contains 143 characters
        Open

                if (!empty($this->app['ips']) && !\in_array(\App\RequestUtil::getRemoteIP(true), array_map('trim', explode(',', $this->app['ips'])))) {

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

                    throw new Core\Exception('Illegal IP address', 401);

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

                }

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

                $this->actionHandler->controller = $this;

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

             *

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

             *

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

                if ($module) {

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

             *

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

                    $log .= 'PATH_INFO: ' . ($_SERVER['PATH_INFO'] ?? '') . PHP_EOL;

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

                        $log .= print_r($_POST, true) . PHP_EOL;

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

                    }

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

                        $log .= "----------- Request payload -----------\n";

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

                            'error_method' => $this->request->getServer('REQUEST_URI'),

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

                if (\in_array($no, [E_ERROR, E_WARNING, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR])) {

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

            /** @var Core\BaseAction */

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

            {

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

            }

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

                }

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

                        $this->errorHandler($error['type'], $error['message'], $error['file'], $error['line']);

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

                    throw new Core\Exception('No action', 404);

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

            public function process(): void

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

                $handlerClass = $this->getActionClassName();

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

                $this->actionHandler = new $handlerClass();

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

                $this->actionHandler->checkAction();

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

                            break;

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

                    }

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

                        return $className;

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

            {

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

                    $log .= 'QUERY_STRING: ' . $_SERVER['QUERY_STRING'] . PHP_EOL;

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

                    $log .= 'IP: ' . $_SERVER['REMOTE_ADDR'] . PHP_EOL;

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

             *

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

            }

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

            public static function errorHandler(int $no, string $str, string $file, int $line): void

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

                });

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

                    return false;

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

             * @throws \Api\Core\Exception

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

                $this->debugRequest();

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

                if (!$module && class_exists($className)) {

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

             * @return void

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

                        $log .= "----------- _POST -----------\n";

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

            {

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

             * @param string $str

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

                register_shutdown_function(function () {

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

                if (empty($this->app)) {

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

                if ($this->request->isEmpty('action', true)) {

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

            private function getActionClassName(): string

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

                    return $className;

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

             * Debug request function.

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

                    }

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

             * @param string $file

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

             *

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

            {

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

                set_error_handler([$this, 'errorHandler']);

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

                }

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

                if (!empty($this->app['ips']) && !\in_array(\App\RequestUtil::getRemoteIP(true), array_map('trim', explode(',', $this->app['ips'])))) {

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

                \App\Process::$processName = $this->request->getByType('action', \App\Purifier::ALNUM);

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

             * Process function.

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

             * @return void

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

             */

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

                            ]);

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

                        case 'file':

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

            {

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

                $type = $this->request->getByType('_container', 'Standard');

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

                    if ($payload = file_get_contents('php://input')) {

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

                    }

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

                }

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

             */

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

             *

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

            }

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

                    $this->actionHandler->updateUser([

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

                            $this->response->setFile($return);

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

                            throw new Core\Exception('Unsupported response type: ' . $this->actionHandler->responseType, 400);

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

            /**

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

                }

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

                        $log .= "$key : $header\n";

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

                    if ($_POST) {

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

            }

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

            public function handleError(\Throwable $e): void

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

                        'custom_params' => [

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

                    ]);

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

             * @throws \Api\Core\Exception

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

                if (isset($this->actionHandler)) {

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

             *

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

             * @return void

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

                            'last_error' => $e->getMessage(),

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

                            'error_time' => date('Y-m-d H:i:s'),

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

             * @param int    $no

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

                }

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

             * Exception error handler function..

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

            /**

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

                    \App\Log::error($no . ': ' . $str . ' in ' . $file . ', line ' . $line);

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

             *

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

             * @param \Throwable $e

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

                    $this->actionHandler->updateSession();

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

             * @see https://secure.php.net/manual/en/function.set-error-handler.php

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

             * @param int    $line

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

             */

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

            {

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

             *

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

             * @return void

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

                        ],

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

             *

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

                }

        There are no issues that match your filters.

        Category
        Status