These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kaloa\Renderer; |
||
4 | |||
5 | use Exception; |
||
6 | use Kaloa\Renderer\Config; |
||
7 | use Kaloa\Renderer\Xml\Rule\FootnotesRule; |
||
8 | use Kaloa\Renderer\Xml\Rule\ListingsRule; |
||
9 | use Kaloa\Renderer\Xml\Rule\PrefixRelativeUrisRule; |
||
10 | use Kaloa\Renderer\Xml\Rule\TocRule; |
||
11 | use Kaloa\Renderer\Xml\Rule\YouTubeRule; |
||
12 | |||
13 | /** |
||
14 | * |
||
15 | * @api |
||
16 | */ |
||
17 | final class Factory |
||
18 | { |
||
19 | /** |
||
20 | * |
||
21 | * @param string $type |
||
22 | * @param Config $config |
||
23 | * @return RendererInterface |
||
24 | * @throws Exception |
||
25 | */ |
||
26 | public static function createRenderer($type, Config $config = null) |
||
27 | { |
||
28 | $renderer = null; |
||
29 | |||
30 | if (null === $config) { |
||
31 | $config = new Config(); |
||
32 | } |
||
33 | |||
34 | switch ($type) { |
||
35 | case 'commonmark': |
||
36 | $renderer = new CommonMarkRenderer($config); |
||
0 ignored issues
–
show
|
|||
37 | break; |
||
38 | case 'inigo': |
||
39 | $renderer = new InigoRenderer($config); |
||
40 | break; |
||
41 | case 'markdown': |
||
42 | $renderer = new MarkdownRenderer($config); |
||
0 ignored issues
–
show
The call to
MarkdownRenderer::__construct() has too many arguments starting with $config .
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
Loading history...
|
|||
43 | break; |
||
44 | case 'xml': |
||
45 | $renderer = new XmlRenderer(); |
||
46 | $renderer->registerRule(new TocRule()); |
||
47 | $renderer->registerRule(new YouTubeRule()); |
||
48 | $renderer->registerRule(new ListingsRule()); |
||
49 | $renderer->registerRule(new PrefixRelativeUrisRule()); |
||
50 | $renderer->registerRule(new FootnotesRule()); |
||
51 | break; |
||
52 | case 'xmllegacy': |
||
53 | $renderer = new XmlLegacyRenderer($config); |
||
54 | break; |
||
55 | default: |
||
56 | throw new Exception('Unknown renderer "' . $type . '"'); |
||
57 | // no break |
||
58 | } |
||
59 | |||
60 | return $renderer; |
||
61 | } |
||
62 | } |
||
63 |
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.