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 | * This dataobject |
||
4 | * saves search replacements |
||
5 | * as in Smoogle will be replaced by Google. |
||
6 | */ |
||
7 | class SearchReplacement extends DataObject implements EditableEcommerceObject |
||
8 | { |
||
9 | private static $db = array( |
||
0 ignored issues
–
show
Comprehensibility
introduced
by
![]() |
|||
10 | 'Search' => 'Varchar(255)', |
||
11 | 'Replace' => 'Varchar(255)', |
||
12 | 'ReplaceWholePhrase' => 'Boolean' |
||
13 | ); |
||
14 | |||
15 | private static $indexes = array( |
||
0 ignored issues
–
show
|
|||
16 | 'SearchIndex' => 'unique("Search")', |
||
17 | 'Replace' => true |
||
18 | ); |
||
19 | |||
20 | private static $summary_fields = array( |
||
0 ignored issues
–
show
|
|||
21 | 'Search' => 'Search Alias (e.g. nz)', |
||
22 | 'Replace' => 'Actual Search Phrase (e.g. new zealand)', |
||
23 | ); |
||
24 | |||
25 | private static $field_labels = array( |
||
0 ignored issues
–
show
|
|||
26 | 'Search' => 'Search Alias (e.g. nz)', |
||
27 | 'Replace' => 'Actual Search Phrase (e.g. new zealand)', |
||
28 | 'ReplaceWholePhrase' => 'Replace Whole Phrase Only' |
||
29 | ); |
||
30 | |||
31 | |||
32 | /** |
||
33 | * standard SS variable. |
||
34 | * |
||
35 | * @Var String |
||
36 | */ |
||
37 | private static $singular_name = 'Search Replacement'; |
||
0 ignored issues
–
show
|
|||
38 | public function i18n_singular_name() |
||
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 ![]() |
|||
39 | { |
||
40 | return $this->Config()->get('singular_name'); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * standard SS variable. |
||
45 | * |
||
46 | * @Var String |
||
47 | */ |
||
48 | private static $plural_name = 'Search Replacements'; |
||
0 ignored issues
–
show
|
|||
49 | public function i18n_plural_name() |
||
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 ![]() |
|||
50 | { |
||
51 | return $this->Config()->get('plural_name'); |
||
52 | } |
||
53 | |||
54 | private static $separator = ','; |
||
55 | |||
56 | public function fieldLabels($includerelations = true) |
||
57 | { |
||
58 | return array( |
||
59 | 'Search' => 'When someone searches for ... (separate searches by '.$this->Config()->get('separator').') - aliases', |
||
60 | 'Replace' => 'It is replaced by - proper name ...', |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | public function onBeforeWrite() |
||
65 | { |
||
66 | parent::onBeforeWrite(); |
||
67 | //all lower case and make replace double spaces |
||
68 | $this->Search = trim(preg_replace('!\s+!', ' ', strtolower($this->Search))); |
||
0 ignored issues
–
show
The property
Search does not seem to exist. Did you mean searchable_fields ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
69 | $searchArray = array(); |
||
70 | foreach (explode(',', $this->Search) as $term) { |
||
0 ignored issues
–
show
The property
Search does not seem to exist. Did you mean searchable_fields ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
71 | $searchArray[] = trim($term); |
||
72 | } |
||
73 | $this->Search = implode(',', $searchArray); |
||
0 ignored issues
–
show
The property
Search does not seem to exist. Did you mean searchable_fields ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
74 | $this->Replace = strtolower($this->Replace); |
||
0 ignored issues
–
show
The property
Replace does not exist on object<SearchReplacement> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
Replace does not exist on object<SearchReplacement> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
75 | } |
||
76 | |||
77 | /** |
||
78 | * standard SS method. |
||
79 | * |
||
80 | * @param Member $member |
||
0 ignored issues
–
show
Should the type for parameter
$member not be Member|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
81 | * |
||
82 | * @return bool |
||
0 ignored issues
–
show
|
|||
83 | */ |
||
84 | public function canCreate($member = null) |
||
85 | { |
||
86 | if (! $member) { |
||
87 | $member = Member::currentUser(); |
||
88 | } |
||
89 | $extended = $this->extendedCan(__FUNCTION__, $member); |
||
0 ignored issues
–
show
$member is of type object<DataObject>|null , but the function expects a object<Member>|integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
90 | if ($extended !== null) { |
||
91 | return $extended; |
||
92 | } |
||
93 | if (Permission::checkMember($member, Config::inst()->get('EcommerceRole', 'admin_permission_code'))) { |
||
94 | return true; |
||
95 | } |
||
96 | |||
97 | return parent::canEdit($member); |
||
0 ignored issues
–
show
It seems like
$member defined by \Member::currentUser() on line 87 can also be of type object<DataObject> ; however, DataObject::canEdit() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() It seems like you call parent on a different method (
canEdit() instead of canCreate() ). Are you sure this is correct? If so, you might want to change this to $this->canEdit() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
98 | } |
||
99 | |||
100 | /** |
||
101 | * standard SS method. |
||
102 | * |
||
103 | * @param Member $member |
||
0 ignored issues
–
show
Should the type for parameter
$member not be Member|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
104 | * |
||
105 | * @return bool |
||
0 ignored issues
–
show
|
|||
106 | */ |
||
107 | public function canView($member = null) |
||
108 | { |
||
109 | if (! $member) { |
||
110 | $member = Member::currentUser(); |
||
111 | } |
||
112 | $extended = $this->extendedCan(__FUNCTION__, $member); |
||
0 ignored issues
–
show
$member is of type object<DataObject>|null , but the function expects a object<Member>|integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
113 | if ($extended !== null) { |
||
114 | return $extended; |
||
115 | } |
||
116 | if (Permission::checkMember($member, Config::inst()->get('EcommerceRole', 'admin_permission_code'))) { |
||
117 | return true; |
||
118 | } |
||
119 | |||
120 | return parent::canEdit($member); |
||
0 ignored issues
–
show
It seems like
$member defined by \Member::currentUser() on line 110 can also be of type object<DataObject> ; however, DataObject::canEdit() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() It seems like you call parent on a different method (
canEdit() instead of canView() ). Are you sure this is correct? If so, you might want to change this to $this->canEdit() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
121 | } |
||
122 | |||
123 | /** |
||
124 | * standard SS method. |
||
125 | * |
||
126 | * @param Member $member |
||
0 ignored issues
–
show
Should the type for parameter
$member not be Member|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
127 | * |
||
128 | * @return bool |
||
0 ignored issues
–
show
|
|||
129 | */ |
||
130 | public function canEdit($member = null) |
||
131 | { |
||
132 | if (! $member) { |
||
133 | $member = Member::currentUser(); |
||
134 | } |
||
135 | $extended = $this->extendedCan(__FUNCTION__, $member); |
||
0 ignored issues
–
show
$member is of type object<DataObject>|null , but the function expects a object<Member>|integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
136 | if ($extended !== null) { |
||
137 | return $extended; |
||
138 | } |
||
139 | if (Permission::checkMember($member, Config::inst()->get('EcommerceRole', 'admin_permission_code'))) { |
||
140 | return true; |
||
141 | } |
||
142 | |||
143 | return parent::canEdit($member); |
||
0 ignored issues
–
show
It seems like
$member defined by \Member::currentUser() on line 133 can also be of type object<DataObject> ; however, DataObject::canEdit() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
144 | } |
||
145 | |||
146 | /** |
||
147 | * standard SS method. |
||
148 | * |
||
149 | * @param Member $member |
||
0 ignored issues
–
show
Should the type for parameter
$member not be Member|null ?
This check looks for It makes a suggestion as to what type it considers more descriptive. Most often this is a case of a parameter that can be null in addition to its declared types. ![]() |
|||
150 | * |
||
151 | * @return bool |
||
0 ignored issues
–
show
|
|||
152 | */ |
||
153 | public function canDelete($member = null) |
||
154 | { |
||
155 | if (! $member) { |
||
156 | $member = Member::currentUser(); |
||
157 | } |
||
158 | $extended = $this->extendedCan(__FUNCTION__, $member); |
||
0 ignored issues
–
show
$member is of type object<DataObject>|null , but the function expects a object<Member>|integer .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
159 | if ($extended !== null) { |
||
160 | return $extended; |
||
161 | } |
||
162 | if (Permission::checkMember($member, Config::inst()->get('EcommerceRole', 'admin_permission_code'))) { |
||
163 | return true; |
||
164 | } |
||
165 | |||
166 | return parent::canEdit($member); |
||
0 ignored issues
–
show
It seems like
$member defined by \Member::currentUser() on line 156 can also be of type object<DataObject> ; however, DataObject::canEdit() does only seem to accept object<Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() It seems like you call parent on a different method (
canEdit() instead of canDelete() ). Are you sure this is correct? If so, you might want to change this to $this->canEdit() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
167 | } |
||
168 | |||
169 | /** |
||
170 | * link to edit the record. |
||
171 | * |
||
172 | * @param string | Null $action - e.g. edit |
||
173 | * |
||
174 | * @return string |
||
0 ignored issues
–
show
|
|||
175 | */ |
||
176 | public function CMSEditLink($action = null) |
||
177 | { |
||
178 | return CMSEditLinkAPI::find_edit_link_for_object($this, $action); |
||
179 | } |
||
180 | } |
||
181 |