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 | abstract class Ajde_Resource extends Ajde_Object_Standard |
||
4 | { |
||
5 | const TYPE_JAVASCRIPT = 'js'; |
||
6 | const TYPE_STYLESHEET = 'css'; |
||
7 | |||
8 | public function __construct($type) |
||
9 | { |
||
10 | $this->setType($type); |
||
0 ignored issues
–
show
|
|||
11 | } |
||
12 | |||
13 | public function __toString() |
||
14 | { |
||
15 | return implode(', ', $this->_data); |
||
16 | } |
||
17 | |||
18 | abstract public function getFilename(); |
||
19 | |||
20 | abstract protected function getLinkUrl(); |
||
21 | |||
22 | protected static function exist($filename) |
||
23 | { |
||
24 | if (is_file(self::realpath($filename))) { |
||
25 | return true; |
||
26 | } |
||
27 | |||
28 | return false; |
||
29 | } |
||
30 | |||
31 | protected static function realpath($filename) |
||
32 | { |
||
33 | // dump($filename, realpath(LOCAL_ROOT . $filename)); |
||
34 | return realpath(LOCAL_ROOT.$filename); |
||
35 | } |
||
36 | |||
37 | public static function encodeFingerprint($array) |
||
38 | { |
||
39 | return self::_urlEncode(serialize($array)); |
||
40 | } |
||
41 | |||
42 | public static function decodeFingerprint($fingerprint) |
||
43 | { |
||
44 | return unserialize(self::_urlDecode($fingerprint)); |
||
45 | } |
||
46 | |||
47 | public static function _urlDecode($string) |
||
48 | { |
||
49 | return base64_decode($string); |
||
50 | } |
||
51 | |||
52 | public static function _urlEncode($string) |
||
53 | { |
||
54 | return base64_encode($string); |
||
55 | } |
||
56 | |||
57 | public static function getLinkTemplateFilename($type, $format = 'null') |
||
58 | { |
||
59 | if (Ajde::app()->getDocument()->hasLayout()) { |
||
0 ignored issues
–
show
The method
hasLayout does not exist on object<Ajde_Document> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
60 | $layout = Ajde::app()->getDocument()->getLayout(); |
||
61 | } else { |
||
62 | $layout = new Ajde_Layout(config('layout.frontend')); |
||
63 | } |
||
64 | $format = issetor($format, 'html'); |
||
0 ignored issues
–
show
Are you sure the assignment to
$format is correct as issetor($format, 'html') (which targets issetor() ) seems to always return null.
This check looks for function or method calls that always return null and whose return value is assigned to a variable. class A
{
function getObject()
{
return null;
}
}
$a = new A();
$object = $a->getObject();
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. ![]() |
|||
65 | |||
66 | $dirPrefixPatterns = [ |
||
67 | APP_DIR, |
||
68 | CORE_DIR, |
||
69 | ]; |
||
70 | foreach ($dirPrefixPatterns as $dirPrefixPattern) { |
||
71 | $prefixedLayout = $dirPrefixPattern.LAYOUT_DIR; |
||
72 | if (self::exist($prefixedLayout.$layout->getName().'/link/'.$type.'.'.$format.'.php')) { |
||
73 | return $prefixedLayout.$layout->getName().'/link/'.$type.'.'.$format.'.php'; |
||
74 | } |
||
75 | } |
||
76 | |||
77 | return false; |
||
78 | } |
||
79 | |||
80 | public function getType() |
||
81 | { |
||
82 | return $this->get('type'); |
||
83 | } |
||
84 | |||
85 | public function setPosition($position) |
||
86 | { |
||
87 | $this->set('position', $position); |
||
88 | } |
||
89 | |||
90 | public function getPosition() |
||
91 | { |
||
92 | return $this->get('position'); |
||
93 | } |
||
94 | |||
95 | protected function _getLinkTemplateFilename() |
||
96 | { |
||
97 | $format = $this->hasFormat() ? $this->getFormat() : null; |
||
0 ignored issues
–
show
The method
hasFormat does not exist on object<Ajde_Resource> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() The method
getFormat does not exist on object<Ajde_Resource> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
98 | |||
99 | return self::getLinkTemplateFilename($this->getType(), $format); |
||
100 | } |
||
101 | |||
102 | public function getLinkCode() |
||
103 | { |
||
104 | ob_start(); |
||
105 | |||
106 | // variables for use in included link template |
||
107 | $url = $this->getLinkUrl(); |
||
108 | $arguments = $this->hasArguments() ? $this->getArguments() : ''; |
||
0 ignored issues
–
show
The method
hasArguments does not exist on object<Ajde_Resource> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() The method
getArguments does not exist on object<Ajde_Resource> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
109 | |||
110 | // create temporary resource for link filename |
||
111 | $linkFilename = $this->_getLinkTemplateFilename(); |
||
112 | |||
113 | // TODO: performance gain? |
||
114 | // Ajde_Cache::getInstance()->addFile($linkFilename); |
||
115 | if ($linkFilename) { |
||
0 ignored issues
–
show
The expression
$linkFilename of type string|false is loosely compared to true ; this is ambiguous if the string can be empty. You might want to explicitly use !== false instead.
In PHP, under loose comparison (like For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
116 | include LOCAL_ROOT.$linkFilename; |
||
117 | } else { |
||
118 | throw new Ajde_Exception('Link filename for '.$url.' not found'); |
||
119 | } |
||
120 | |||
121 | $contents = ob_get_contents(); |
||
122 | ob_end_clean(); |
||
123 | |||
124 | return $contents; |
||
125 | } |
||
126 | |||
127 | public function getContents() |
||
128 | { |
||
129 | ob_start(); |
||
130 | |||
131 | $filename = $this->getFilename(); |
||
132 | |||
133 | Ajde_Cache::getInstance()->addFile($filename); |
||
134 | if ($this->exist($filename)) { |
||
135 | include $this->realpath($filename); |
||
136 | } else { |
||
137 | throw new Exception("Couldn't find resource ".$filename); |
||
138 | } |
||
139 | |||
140 | $contents = ob_get_contents(); |
||
141 | ob_end_clean(); |
||
142 | |||
143 | return $contents; |
||
144 | } |
||
145 | } |
||
146 |
If you implement
__call
and 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
__call
is implemented by a parent class and only the child class knows which methods exist: