Test Failed
Push — fix-update-with-expressions ( c5f2bd...e60186 )
by Sergei
35:48 queued 22:00
created

SqlParser   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 33
dl 0
loc 54
rs 10
c 1
b 0
f 0
wmc 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getNextPlaceholder() 0 34 9
A skipQuotedWithQ() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Oracle;
6
7
use Yiisoft\Db\Syntax\SqlParser as BaseSqlParser;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Db\Syntax\SqlParser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
final class SqlParser extends BaseSqlParser
10
{
11
    public function getNextPlaceholder(int|null &$position = null): string|null
12
    {
13
        $result = null;
14
        $length = $this->length - 1;
15
16
        while ($this->position < $length) {
17
            $pos = $this->position++;
18
19
            match ($this->sql[$pos]) {
20
                ':' => ($word = $this->parseWord()) === ''
21
                    ? $this->skipChars(':')
22
                    : $result = ':' . $word,
23
                '"' => $this->skipToAfterChar('"'),
24
                "'" => $this->skipQuotedWithoutEscape($this->sql[$pos]),
25
                'q', 'Q' => $this->sql[$this->position] === "'"
26
                    ? $this->skipQuotedWithQ()
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->skipQuotedWithQ() targeting Yiisoft\Db\Oracle\SqlParser::skipQuotedWithQ() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
27
                    : null,
28
                '-' => $this->sql[$this->position] === '-'
29
                    ? ++$this->position && $this->skipToAfterChar("\n")
30
                    : null,
31
                '/' => $this->sql[$this->position] === '*'
32
                    ? ++$this->position && $this->skipToAfterString('*/')
33
                    : null,
34
                default => null,
35
            };
36
37
            if ($result !== null) {
38
                $position = $pos;
39
40
                return $result;
41
            }
42
        }
43
44
        return null;
45
    }
46
47
    /**
48
     * Skips quoted string with Q-operator.
49
     */
50
    private function skipQuotedWithQ(): void
51
    {
52
        $endChar = match ($this->sql[++$this->position]) {
53
            '[' => ']',
54
            '<' => '>',
55
            '{' => '}',
56
            '(' => ')',
57
            default => $this->sql[$this->position],
58
        };
59
60
        ++$this->position;
61
62
        $this->skipToAfterString("$endChar'");
63
    }
64
}
65