Conditions | 2 |
Paths | 2 |
Total Lines | 40 |
Code Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
16 | public function generate(): Node |
||
17 | { |
||
18 | $classChunks = explode('\\', $this->yaml['class']); |
||
19 | $className = array_pop($classChunks); |
||
20 | $namespace = $this->yaml['src']['namespace'] . '\\' . static::NAMESPACE; |
||
21 | if (count($classChunks) > 0) { |
||
22 | $namespace .= '\\' . implode('\\', $classChunks); |
||
23 | $namespace = str_replace('\\\\', '\\', $namespace); |
||
24 | } |
||
25 | $baseClass = $this->yaml['src']['namespace'] . '\\' . $this->yaml['class']; |
||
26 | |||
27 | $factory = new BuilderFactory(); |
||
28 | |||
29 | $class = $factory->class($className) |
||
30 | ->extend('Base' . $className); |
||
31 | |||
32 | $class->addStmt( |
||
33 | $factory->method('refresh') |
||
34 | ->makePublic() |
||
35 | ->setReturnType($className) |
||
36 | ->addStmt( |
||
37 | new Node\Stmt\Throw_( |
||
38 | new Node\Expr\New_( |
||
39 | new Node\Name('\Exception'), |
||
40 | [ |
||
|
|||
41 | new Node\Scalar\String_( |
||
42 | 'TODO: create refresh method!' |
||
43 | ) |
||
44 | ] |
||
45 | ) |
||
46 | ) |
||
47 | ) |
||
48 | ); |
||
49 | |||
50 | return $factory->namespace($namespace) |
||
51 | ->addStmt($factory->use($baseClass)->as('Base' . $className)) |
||
52 | ->addStmt($class) |
||
53 | ->getNode() |
||
54 | ; |
||
55 | } |
||
56 | } |
||
57 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: