Conditions | 7 |
Paths | 13 |
Total Lines | 41 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 4 |
CRAP Score | 28.9113 |
Changes | 0 |
1 | <?php |
||
17 | 2 | public function parse(&$variable) |
|
18 | { |
||
19 | /** @noinspection PhpUndefinedClassInspection */ |
||
20 | if ( |
||
21 | 2 | !defined('\Smarty::SMARTY_VERSION') # lower than 3.x |
|
22 | || |
||
23 | 2 | !$variable instanceof \Smarty |
|
|
|||
24 | ) { |
||
25 | 2 | return false; |
|
26 | } |
||
27 | |||
28 | /** @noinspection PhpUndefinedClassInspection */ |
||
29 | $this->name = 'object Smarty (v' . substr(Smarty::SMARTY_VERSION, 7) . ')'; # trim 'Smarty-' |
||
30 | |||
31 | $assigned = $globalAssigns = array(); |
||
32 | /** @noinspection PhpUndefinedFieldInspection */ |
||
33 | foreach ($variable->tpl_vars as $name => $var) { |
||
34 | $assigned[$name] = $var->value; |
||
35 | } |
||
36 | |||
37 | /** @noinspection PhpUndefinedClassInspection */ |
||
38 | foreach (Smarty::$global_tpl_vars as $name => $var) { |
||
39 | if ($name === 'SCRIPT_NAME') { |
||
40 | continue; |
||
41 | } |
||
42 | |||
43 | $globalAssigns[$name] = $var->value; |
||
44 | } |
||
45 | |||
46 | /** @noinspection PhpUndefinedMethodInspection */ |
||
47 | return array( |
||
48 | 'Assigned' => $assigned, |
||
49 | 'Assigned globally' => $globalAssigns, |
||
50 | 'Configuration' => array( |
||
51 | 'Compiled files stored in' => isset($variable->compile_dir) |
||
52 | ? $variable->compile_dir |
||
53 | : $variable->getCompileDir(), |
||
54 | ), |
||
55 | ); |
||
56 | |||
57 | } |
||
58 | } |
||
59 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.