Completed
Push — 2.x ( eb2bc2...ce9b15 )
by Akihito
03:04
created

ParserFactory::newInstance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of the Ray.Aop package
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace Ray\Aop;
8
9
use PhpParser\Lexer;
10
use PhpParser\Parser;
11
use PhpParser\ParserFactory as PhpParserFactory;
12
13
class ParserFactory
14
{
15 27
    public function newInstance()
16
    {
17 27
        if (class_exists('PhpParser\ParserFactory')) {
18 27
            return (new PhpParserFactory)->create(PhpParserFactory::PREFER_PHP7);
19
        }
20
21
        return new Parser(new Lexer());  // @codeCoverageIgnore
0 ignored issues
show
Unused Code introduced by
The call to Parser::__construct() has too many arguments starting with new \PhpParser\Lexer().

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.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
22
    }
23
}
24