KSST /
KF
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * Koch Framework |
||
| 5 | * Jens-André Koch © 2005 - onwards. |
||
| 6 | * |
||
| 7 | * This file is part of "Koch Framework". |
||
| 8 | * |
||
| 9 | * License: GNU/GPL v2 or any later version, see LICENSE file. |
||
| 10 | * |
||
| 11 | * This program is free software; you can redistribute it and/or modify |
||
| 12 | * it under the terms of the GNU General Public License as published by |
||
| 13 | * the Free Software Foundation; either version 2 of the License, or |
||
| 14 | * (at your option) any later version. |
||
| 15 | * |
||
| 16 | * This program is distributed in the hope that it will be useful, |
||
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 19 | * GNU General Public License for more details. |
||
| 20 | * |
||
| 21 | * You should have received a copy of the GNU General Public License |
||
| 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
| 23 | */ |
||
| 24 | |||
| 25 | namespace Koch\View\Renderer; |
||
| 26 | |||
| 27 | use Koch\View\AbstractRenderer; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Koch Framework - View Renderer for Xtemplate templates. |
||
| 31 | * |
||
| 32 | * This is a wrapper/adapter for rendering with XTemplate. |
||
| 33 | * |
||
| 34 | * @link http://www.phpxtemplate.org/ Offical Website of PHP XTemplate |
||
| 35 | * @link http://xtpl.sourceforge.net/ Project's Website at Sourceforge |
||
| 36 | */ |
||
| 37 | class Xtemplate extends AbstractRenderer |
||
| 38 | { |
||
| 39 | /* @var \XTemplate */ |
||
| 40 | public $renderer = null; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Constructor. |
||
| 44 | * |
||
| 45 | * @param array $options |
||
| 46 | */ |
||
| 47 | public function __construct($options = []) |
||
| 48 | { |
||
| 49 | parent::__construct($options); |
||
| 50 | } |
||
| 51 | |||
| 52 | public function initializeEngine($template = null) |
||
| 53 | { |
||
| 54 | $xtpl = VENDOR_PATH . '/xtemplate/xtemplate.class.php'; |
||
| 55 | |||
| 56 | // prevent redeclaration |
||
| 57 | if (!class_exists('XTemplate', false)) { |
||
| 58 | // check if library exists |
||
| 59 | if (is_file($xtpl)) { |
||
| 60 | include $xtpl; |
||
| 61 | } else { |
||
| 62 | throw new \Exception('The vendor library "XTemplate" is required.'); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | |||
| 66 | $template = $this->getTemplatePath($template); |
||
|
0 ignored issues
–
show
|
|||
| 67 | |||
| 68 | #\Koch\Debug\Debug::firebug('Xtemplate loaded with Template: ' . $template); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
55% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 69 | |||
| 70 | // Do it with XTemplate style > eat like a bird, poop like an elefant! |
||
| 71 | return $this->renderer = new self($template); |
||
|
0 ignored issues
–
show
It seems like
new self($template) of type object<Koch\View\Renderer\Xtemplate> is incompatible with the declared type object<XTemplate> of property $renderer.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
The return type of
return $this->renderer = new self($template); (Koch\View\Renderer\Xtemplate) is incompatible with the return type declared by the abstract method Koch\View\AbstractRenderer::initializeEngine of type Koch\View\Engine.
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function Loading history...
|
|||
| 72 | } |
||
| 73 | |||
| 74 | public function configureEngine() |
||
| 75 | { |
||
| 76 | } |
||
| 77 | |||
| 78 | public function renderPartial($template) |
||
|
0 ignored issues
–
show
|
|||
| 79 | { |
||
| 80 | } |
||
| 81 | |||
| 82 | public function clearVars() |
||
| 83 | { |
||
| 84 | } |
||
| 85 | |||
| 86 | public function clearCache() |
||
| 87 | { |
||
| 88 | } |
||
| 89 | |||
| 90 | public function fetch($template, $data = null) |
||
| 91 | { |
||
| 92 | } |
||
| 93 | |||
| 94 | public function display($template, $data = null) |
||
| 95 | { |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Returns a clean xTemplate Object. |
||
| 100 | * |
||
| 101 | * @return Xtemplate Object |
||
|
0 ignored issues
–
show
|
|||
| 102 | */ |
||
| 103 | public function getEngine() |
||
| 104 | { |
||
| 105 | // clear assigns? |
||
| 106 | return $this->renderer; |
||
|
0 ignored issues
–
show
The return type of
return $this->renderer; (XTemplate) is incompatible with the return type of the parent method Koch\View\AbstractRenderer::getEngine of type Koch\View\Renderer|null.
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design. Let’s take a look at an example: class Author {
private $name;
public function __construct($name) {
$this->name = $name;
}
public function getName() {
return $this->name;
}
}
abstract class Post {
public function getAuthor() {
return 'Johannes';
}
}
class BlogPost extends Post {
public function getAuthor() {
return new Author('Johannes');
}
}
class ForumPost extends Post { /* ... */ }
function my_function(Post $post) {
echo strtoupper($post->getAuthor());
}
Our function Loading history...
|
|||
| 107 | } |
||
| 108 | |||
| 109 | public function render($template = null, $viewdata = null) |
||
| 110 | { |
||
| 111 | $this->renderer->assign($viewdata); |
||
| 112 | $this->renderer->parse($template); |
||
| 113 | $this->renderer->out($template); |
||
| 114 | } |
||
| 115 | |||
| 116 | public function assign($tpl_parameter, $value = null) |
||
| 117 | { |
||
| 118 | $this->renderer->assign($tpl_parameter, $value); |
||
|
0 ignored issues
–
show
$tpl_parameter does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).
This check examines a number of code elements and verifies that they conform to the given naming conventions. You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods. Loading history...
|
|||
| 119 | } |
||
| 120 | } |
||
| 121 |
If you implement
__calland you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__callis implemented by a parent class and only the child class knows which methods exist: