These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Webino (http://webino.sk) |
||
4 | * |
||
5 | * @link https://github.com/webino/WebinoDraw for the canonical source repository |
||
6 | * @copyright Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk) |
||
7 | * @author Peter Bačinský <[email protected]> |
||
8 | * @license BSD-3-Clause |
||
9 | */ |
||
10 | |||
11 | namespace WebinoDraw\View\Renderer; |
||
12 | |||
13 | use Zend\View\Exception; |
||
14 | use Zend\View\Model\ModelInterface as Model; |
||
15 | use Zend\View\Renderer\PhpRenderer; |
||
16 | |||
17 | /** |
||
18 | * Uses file_get_contents() instead of include |
||
19 | * |
||
20 | * <pre> |
||
21 | * 'service_manager' => [ |
||
22 | * 'factories' => [ |
||
23 | * 'HttpViewManager' => 'WebinoDraw\Mvc\Service\HttpViewManagerFactory', |
||
24 | * ], |
||
25 | * ], |
||
26 | * </pre> |
||
27 | */ |
||
28 | class NotPhpRenderer extends PhpRenderer |
||
29 | { |
||
30 | /** |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | private $templates = []; |
||
34 | |||
35 | /** |
||
36 | * {@inheritDoc} |
||
37 | */ |
||
38 | public function render($nameOrModel, $values = null) |
||
39 | { |
||
40 | if ($nameOrModel instanceof Model) { |
||
0 ignored issues
–
show
|
|||
41 | $model = $nameOrModel; |
||
42 | $nameOrModel = $model->getTemplate(); |
||
43 | |||
44 | if (empty($nameOrModel)) { |
||
45 | throw new Exception\DomainException(sprintf( |
||
46 | '%s: received View Model argument, but template is empty', |
||
47 | __METHOD__ |
||
48 | )); |
||
49 | } |
||
50 | |||
51 | // Give view model awareness via ViewModel helper |
||
52 | $this->plugin('view_model')->setCurrent($model); |
||
53 | } |
||
54 | |||
55 | // find the script file name using the parent private method |
||
56 | $this->addTemplate($nameOrModel); |
||
57 | unset($nameOrModel); |
||
58 | |||
59 | $template = array_pop($this->templates); |
||
60 | $file = $this->resolver($template); |
||
61 | |||
62 | if (!$file) { |
||
63 | throw new Exception\RuntimeException(sprintf( |
||
64 | '%s: Unable to render template "%s"; resolver could not resolve to a file', |
||
65 | __METHOD__, |
||
66 | $template |
||
67 | )); |
||
68 | } |
||
69 | |||
70 | if (false === is_file($file)) { |
||
71 | throw new Exception\UnexpectedValueException(sprintf( |
||
72 | '%s: Unable to render template "%s"; file not found', |
||
73 | __METHOD__, |
||
74 | $file |
||
75 | )); |
||
76 | } |
||
77 | |||
78 | return $this->getFilterChain()->filter(file_get_contents($file)); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * {@inheritDoc} |
||
83 | */ |
||
84 | public function addTemplate($template) |
||
85 | { |
||
86 | $this->templates[] = $template; |
||
87 | return $this; |
||
88 | } |
||
89 | } |
||
90 |
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.