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 | namespace Ajax\bootstrap\html; |
||
4 | |||
5 | use Ajax\JsUtils; |
||
6 | use Ajax\bootstrap\html\content\HtmlCarouselControl; |
||
7 | use Ajax\bootstrap\html\base\CssRef; |
||
8 | use Ajax\bootstrap\html\base\HtmlBsDoubleElement; |
||
9 | use Ajax\bootstrap\html\content\HtmlCarouselItem; |
||
10 | |||
11 | use Ajax\common\html\BaseHtml; |
||
12 | /** |
||
13 | * Composant Twitter Bootstrap Carousel |
||
14 | * @see http://getbootstrap.com/components/#carousel |
||
15 | * @author jc |
||
16 | * @version 1.001 |
||
17 | */ |
||
18 | class HtmlCarousel extends BaseHtml { |
||
19 | protected $indicators=array (); |
||
20 | protected $slides=array (); |
||
21 | protected $leftControl=""; |
||
22 | protected $rightControl=""; |
||
23 | protected $_base=""; |
||
24 | protected $_glyphs=array (); |
||
25 | |||
26 | public function __construct($identifier, $images=NULL) { |
||
27 | parent::__construct($identifier); |
||
28 | $this->_template=include 'templates/tplCarousel.php'; |
||
29 | if ($images!=NULL) { |
||
30 | if (is_array($images)) { |
||
31 | $this->fromArray($images); |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 | |||
36 | public function getBase() { |
||
37 | return $this->_base; |
||
38 | } |
||
39 | |||
40 | public function setBase($_base) { |
||
41 | foreach ($this->slides as $slide){ |
||
42 | $imgSrc=$slide->getImageSrc(); |
||
43 | $slide->setImageSrc(str_replace($this->_base.$imgSrc, $_base.$imgSrc, $imgSrc)); |
||
44 | } |
||
45 | $this->_base=$_base; |
||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | public function run(JsUtils $js) { |
||
50 | $this->_bsComponent=$js->bootstrap()->carousel("#".$this->identifier); |
||
51 | $this->addEventsOnRun($js); |
||
52 | return $this->_bsComponent; |
||
53 | } |
||
54 | |||
55 | private function createControls() { |
||
56 | $this->rightControl=$this->createControl("next", "right"); |
||
0 ignored issues
–
show
|
|||
57 | $this->leftControl=$this->createControl("previous", "left"); |
||
0 ignored issues
–
show
It seems like
$this->createControl('previous', 'left') can also be of type object<Ajax\bootstrap\ht...nt\HtmlCarouselControl> . However, the property $leftControl is declared as type string . Maybe add an additional type check?
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly. For example, imagine you have a variable Either this assignment is in error or a type check should be added for that assignment. class Id
{
public $id;
public function __construct($id)
{
$this->id = $id;
}
}
class Account
{
/** @var Id $id */
public $id;
}
$account_id = false;
if (starsAreRight()) {
$account_id = new Id(42);
}
$account = new Account();
if ($account instanceof Id)
{
$account->id = $account_id;
}
![]() |
|||
58 | } |
||
59 | |||
60 | /** |
||
61 | * |
||
62 | * @param string $caption |
||
63 | * @param string $sens |
||
64 | * @return HtmlCarouselControl|string |
||
65 | */ |
||
66 | private function createControl($caption="next", $sens="left") { |
||
67 | $control=new HtmlCarouselControl($sens."-ctrl-".$this->identifier); |
||
68 | $control->setClass($sens." carousel-control"); |
||
69 | $control->setProperty("data-slide", substr($caption, 0, 4)); |
||
70 | $control->setHref("#".$this->identifier); |
||
71 | $control->setRole("button"); |
||
72 | $control->setCaption(ucfirst($caption)); |
||
73 | $control->setGlyphIcon($this->getGlyph($sens)); |
||
74 | return $control; |
||
75 | } |
||
76 | |||
77 | private function getGlyph($sens="left") { |
||
78 | if (array_key_exists($sens, $this->_glyphs)) |
||
79 | return $this->_glyphs [$sens]; |
||
80 | return "glyphicon-chevron-".$sens; |
||
81 | } |
||
82 | |||
83 | public function setRightGlyph($glyphicon) { |
||
84 | $glyphs=CssRef::glyphIcons(); |
||
85 | if (array_search($glyphicon, $glyphs)!==false) |
||
86 | $this->_glyphs ["right"]=$glyphicon; |
||
87 | } |
||
88 | |||
89 | public function setLeftGlyph($glyphicon) { |
||
90 | $glyphs=CssRef::glyphIcons(); |
||
91 | if (array_search($glyphicon, $glyphs)!==false) |
||
92 | $this->_glyphs ["left"]=$glyphicon; |
||
93 | } |
||
94 | |||
95 | public function addImage($imageSrc, $imageAlt="", $caption=NULL, $description=NULL) { |
||
96 | if(is_array($imageSrc)){ |
||
97 | $this->addImage($imageSrc[0],@$imageSrc[1],@$imageSrc[2],@$imageSrc[3]); |
||
98 | }else{ |
||
99 | $image=new HtmlCarouselItem("item-".$this->identifier); |
||
100 | $image->setImageSrc($this->_base.$imageSrc); |
||
101 | $image->setImageAlt($imageAlt); |
||
102 | $image->setClass("item"); |
||
103 | if (isset($caption)) { |
||
104 | $optCaption="<h3>".$caption."</h3>"; |
||
105 | if (isset($description)) { |
||
106 | $optCaption.="<p>".$description."</p>"; |
||
107 | } |
||
108 | $image->setCaption($optCaption); |
||
109 | } |
||
110 | $this->slides []=$image; |
||
111 | $this->createIndicator(); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | /* |
||
116 | * (non-PHPdoc) |
||
117 | * @see \Ajax\bootstrap\html\base\BaseHtml::fromArray() |
||
118 | */ |
||
119 | public function fromArray($array) { |
||
120 | if (is_array($array) && sizeof($array)>0) { |
||
121 | foreach ( $array as $value ) { |
||
122 | if (is_array($value)) { |
||
123 | $this->addImage($value ["src"], @$value ["alt"], @$value ["caption"], @$value ["description"]); |
||
124 | } else { |
||
125 | $this->addImage($value); |
||
126 | } |
||
127 | } |
||
128 | } |
||
129 | return $this; |
||
130 | } |
||
131 | |||
132 | private function createIndicator() { |
||
133 | $indicator=new HtmlBsDoubleElement("indicator-".$this->identifier); |
||
134 | $indicator->setProperty("data-target", "#".$this->identifier); |
||
135 | $indicator->setProperty("data-slide-to", sizeof($this->indicators)); |
||
136 | $indicator->setTagName("li"); |
||
137 | $this->indicators []=$indicator; |
||
138 | } |
||
139 | |||
140 | /* |
||
141 | * (non-PHPdoc) |
||
142 | * @see \Ajax\bootstrap\html\base\BaseHtml::compile() |
||
143 | */ |
||
144 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
||
145 | $this->slides [0]->setClass("item active"); |
||
146 | $this->indicators [0]->setClass("active"); |
||
147 | $this->createControls(); |
||
148 | return parent::compile($js, $view); |
||
149 | } |
||
150 | |||
151 | |||
152 | /* (non-PHPdoc) |
||
153 | * @see \Ajax\bootstrap\html\base\BaseHtml::fromDatabaseObject() |
||
154 | */ |
||
155 | public function fromDatabaseObject($object, $function) { |
||
156 | $this->addImage($function($object)); |
||
157 | } |
||
158 | } |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.