Completed
Pull Request — master (#1186)
by Alessandro
11:56
created

Lexer::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 2
rs 10
1
<?php
2
3
namespace JMS\Serializer\Type;
4
5
use Doctrine\Common\Lexer\AbstractLexer;
6
use Hoa\Exception\Exception;
7
use JMS\Serializer\Type\Exception\SyntaxError;
8
9
class Lexer extends AbstractLexer implements ParserInterface
10
{
11
    public function parse(string $type): array
12
    {
13
        try {
14
            return $this->getType($type);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getType($type) returns the type null which is incompatible with the type-hinted return array.
Loading history...
Bug introduced by
Are you sure the usage of $this->getType($type) targeting JMS\Serializer\Type\Lexer::getType() 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...
15
        } catch (Exception $e) {
16
            throw new SyntaxError($e->getMessage(), 0, $e);
17
        }
18
    }
19
20
    protected function getCatchablePatterns(): array
21
    {
22
        return [
23
            '(?:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\)*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', // name
24
            '(\+|\-)?(0|[1-9]\d*)(\.\d+)?', // number
25
            'null',
26
            '""|\'\'', // empty string
27
            '"[^"]+"', // quoted string
28
            "'[^']+'", // apostrophed string
29
        ];
30
    }
31
32
    protected function getNonCatchablePatterns(): array
33
    {
34
        return [
35
            // TODO: Implement getNonCatchablePatterns() method.
36
        ];
37
    }
38
39
    protected function getType(&$value)
40
    {
41
        // TODO: Implement getType() method.
42
    }
43
}
44