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 | class PageRaterStarField extends FormField |
||
0 ignored issues
–
show
|
|||
4 | { |
||
5 | private static $extra_form_selector = ''; |
||
0 ignored issues
–
show
|
|||
6 | |||
7 | private static $allow_comments = false; |
||
0 ignored issues
–
show
|
|||
8 | |||
9 | private static $allow_name = false; |
||
0 ignored issues
–
show
|
|||
10 | |||
11 | private static $allow_title = false; |
||
0 ignored issues
–
show
|
|||
12 | |||
13 | protected $rating = 0; |
||
14 | |||
15 | protected $starOptions = 5; |
||
16 | |||
17 | protected $moreFieldsArray = array(); |
||
18 | |||
19 | /** |
||
20 | * Returns an input field, class="start field" and type="hidden" with an optional maxlength |
||
21 | */ |
||
22 | public function __construct($name, $title = null, $value = "", $starOptions = null, $form = null) |
||
23 | { |
||
24 | if ($starOptions) { |
||
25 | $this->starOptions = $starOptions; |
||
26 | } else { |
||
27 | $this->starOptions = PageRating::get_number_of_stars(); |
||
28 | } |
||
29 | |||
30 | parent::__construct($name, $title, $value, $form); |
||
0 ignored issues
–
show
The call to
FormField::__construct() has too many arguments starting with $form .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the
Loading history...
|
|||
31 | } |
||
32 | |||
33 | protected $_field_value = null; |
||
34 | |||
35 | public function Field($properties = array()) |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a
Loading history...
|
|||
36 | { |
||
37 | if (! $this->_field_value) { |
||
38 | Requirements::javascript(THIRDPARTY_DIR .'/jquery/jquery.js'); |
||
39 | Requirements::javascript(THIRDPARTY_DIR .'/jquery-form/jquery.form.js'); |
||
40 | Requirements::javascript('pagerater/javascript/jquery.rating.pack.js'); |
||
41 | Requirements::javascript('pagerater/javascript/PageRater.js'); |
||
42 | if ($this->Config()->get("extra_form_selector")) { |
||
43 | Requirements::customScript("PageRater.set_extra_form_selector('".$this->Config()->get("extra_form_selector")."');"); |
||
44 | } |
||
45 | Requirements::themedCSS('jquery.rating', "pagerater"); |
||
46 | $html = ""; |
||
47 | |||
48 | $name = $this->getName(); |
||
49 | $id = $this->id(); |
||
50 | for ($i = 1; $i < $this->starOptions + 1; $i++) { |
||
51 | if ($i == $this->Value()) { |
||
52 | $html .= "<input name='$id' class='$id' type='radio' checked='checked' value='$i' />"; |
||
53 | } else { |
||
54 | $html .= "<input name='$id' class='$id' type='radio' value='$i' />"; |
||
55 | } |
||
56 | } |
||
57 | $html .= "<input name='$name' type='hidden' id='$id' />"; |
||
58 | |||
59 | View Code Duplication | if ($this->Config()->get("allow_name")) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
60 | $fieldID = $id."_Name"; |
||
61 | $nameField = TextField::create($fieldID, _t("PageRaterStarField.NAME_LABEL", "Your Name")); |
||
62 | $nameField->addExtraClass("additionalComments"); |
||
63 | $html .= $nameField->FieldHolder(); |
||
64 | $this->moreFieldsArray[] = $fieldID; |
||
65 | } |
||
66 | |||
67 | View Code Duplication | if ($this->Config()->get("allow_title")) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
68 | $fieldID = $id."_Title"; |
||
69 | $titleField = TextField::create($fieldID, _t("PageRaterStarField.TITLE_LABEL", "Comment Header")); |
||
70 | $titleField->addExtraClass("additionalComments"); |
||
71 | $html .= $titleField->FieldHolder(); |
||
72 | $this->moreFieldsArray[] = $fieldID; |
||
73 | } |
||
74 | |||
75 | View Code Duplication | if ($this->Config()->get("allow_comments")) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
76 | $fieldID = $id."_Comment"; |
||
77 | $commentField = TextareaField::create($fieldID, _t("PageRaterStarField.COMMENTS_LABEL", "Any comments you may have")); |
||
78 | $commentField->addExtraClass("additionalComments"); |
||
79 | $html .= $commentField->FieldHolder(); |
||
80 | $this->moreFieldsArray[] = $fieldID; |
||
81 | } |
||
82 | $moreFieldsAsString = implode("', '", $this->moreFieldsArray); |
||
83 | Requirements::customScript(' |
||
84 | if(typeof PageRaterVariables === "undefined") { |
||
85 | var PageRaterVariables = []; |
||
86 | } |
||
87 | PageRaterVariables.push( |
||
88 | { |
||
89 | id: \''.$id.'\', |
||
90 | fields: [\''.$moreFieldsAsString.'\'] |
||
91 | } |
||
92 | ); |
||
93 | '); |
||
94 | $this->_field_value = $html; |
||
95 | } |
||
96 | return $this->_field_value; |
||
97 | } |
||
98 | |||
99 | public function getRequiredFields() |
||
100 | { |
||
101 | $this->Field(); |
||
102 | return $this->moreFieldsArray; |
||
103 | } |
||
104 | } |
||
105 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.