CatchSt   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A compile() 0 8 2
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA\Compiler\Statement;
7
8
use PHPSA\CompiledExpression;
9
use PHPSA\Context;
10
use PHPSA\Variable;
11
12
class CatchSt extends AbstractCompiler
13
{
14
    protected $name = '\PhpParser\Node\Stmt\Catch_';
15
16
    /**
17
     * @param \PhpParser\Node\Stmt\Catch_ $statement
18
     * @param Context $context
19
     */
20
    public function compile($statement, Context $context)
21
    {
22
        $context->addVariable(new Variable($statement->var, null, CompiledExpression::OBJECT));
0 ignored issues
show
Documentation introduced by
$statement->var is of type object<PhpParser\Node\Expr\Variable>, but the function expects a string.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
23
24
        foreach ($statement->stmts as $stmt) {
25
            \PHPSA\nodeVisitorFactory($stmt, $context);
26
        }
27
    }
28
}
29