Issues (25)

Classes/System/Log/Logger.php (5 issues)

1
<?php
2
namespace Aoe\Asdis\System\Log;
3
4
use TYPO3\CMS\Core\Utility\GeneralUtility;
5
use TYPO3\CMS\Core\SingletonInterface;
6
7
/**
8
 * System logger.
9
 */
10
class Logger implements SingletonInterface
11
{
12
    /**
13
     * @param string $context
14
     * @param Exception $e
0 ignored issues
show
The type Aoe\Asdis\System\Log\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
15
     */
16
    public function logException($context, \Exception $e)
17
    {
18
        if (true === version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '9.5.0', '<')) {
19
            $this->syslog(
20
                $context,
21
                'Exception occured ' . PHP_EOL .
0 ignored issues
show
'Exception occured ' . A... $e->getTraceAsString() of type string is incompatible with the type integer expected by parameter $severity of Aoe\Asdis\System\Log\Logger::syslog(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
                /** @scrutinizer ignore-type */ 'Exception occured ' . PHP_EOL .
Loading history...
22
                '  Code:    ' . $e->getCode() . PHP_EOL .
23
                '  Message: "' . $e->getMessage() . '"' . PHP_EOL .
24
                '  Trace:' . PHP_EOL . $e->getTraceAsString(),
25
                4
0 ignored issues
show
The call to Aoe\Asdis\System\Log\Logger::syslog() has too many arguments starting with 4. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
            $this->/** @scrutinizer ignore-call */ 
26
                   syslog(

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
26
            );
27
            return;
28
        }
29
30
        $this->logger = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class)->getLogger(__CLASS__);
0 ignored issues
show
Bug Best Practice introduced by
The property logger does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
        $this->logger->error(
32
            $context . ': ' . $e->getMessage(),
33
            $e->getTrace()
34
        );
35
    }
36
37
    /**
38
     * @param string $message
39
     * @param integer $severity
40
     */
41
    private function syslog($message, $severity)
42
    {
43
        GeneralUtility::sysLog($message, 'asdis', $severity);
0 ignored issues
show
The method sysLog() does not exist on TYPO3\CMS\Core\Utility\GeneralUtility. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        GeneralUtility::/** @scrutinizer ignore-call */ 
44
                        sysLog($message, 'asdis', $severity);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
    }
45
}