sunnysideup /
silverstripe-ecommerce
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 | /*** |
||
| 5 | * Class used to describe the steps in the checkout |
||
| 6 | * |
||
| 7 | */ |
||
| 8 | |||
| 9 | class OrderFeedback extends DataObject implements EditableEcommerceObject |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * standard SS variable. |
||
| 13 | * |
||
| 14 | * @Var Array |
||
| 15 | */ |
||
| 16 | private static $db = array( |
||
|
0 ignored issues
–
show
Comprehensibility
introduced
by
Loading history...
|
|||
| 17 | 'Rating' => 'Varchar', |
||
| 18 | 'Note' => 'Text', |
||
| 19 | 'Actioned' => 'Boolean' |
||
| 20 | ); |
||
| 21 | /** |
||
| 22 | * standard SS variable. |
||
| 23 | * |
||
| 24 | * @Var Array |
||
| 25 | */ |
||
| 26 | private static $has_one = array( |
||
|
0 ignored issues
–
show
|
|||
| 27 | 'Order' => 'Order' |
||
| 28 | ); |
||
| 29 | |||
| 30 | /** |
||
| 31 | * standard SS variable. |
||
| 32 | * |
||
| 33 | * @Var Array |
||
| 34 | */ |
||
| 35 | private static $searchable_fields = array( |
||
|
0 ignored issues
–
show
|
|||
| 36 | 'Rating' => 'PartialMatchFilter', |
||
| 37 | 'Note' => 'PartialMatchFilter', |
||
| 38 | 'OrderID' => array( |
||
| 39 | 'field' => 'NumericField', |
||
| 40 | 'title' => 'Order Number', |
||
| 41 | ) |
||
| 42 | ); |
||
| 43 | |||
| 44 | /** |
||
| 45 | * standard SS variable. |
||
| 46 | * |
||
| 47 | * @Var Array |
||
| 48 | */ |
||
| 49 | private static $summary_fields = array( |
||
|
0 ignored issues
–
show
|
|||
| 50 | 'Order.Title' => 'Order', |
||
| 51 | 'Created' => 'When', |
||
| 52 | 'Rating' => 'Rating', |
||
| 53 | 'Note' => 'Note' |
||
| 54 | ); |
||
| 55 | |||
| 56 | /** |
||
| 57 | * standard SS variable. |
||
| 58 | * |
||
| 59 | * @Var Array |
||
| 60 | */ |
||
| 61 | private static $casting = array( |
||
|
0 ignored issues
–
show
|
|||
| 62 | 'Title' => 'Varchar' |
||
| 63 | ); |
||
| 64 | |||
| 65 | /** |
||
| 66 | * standard SS variable. |
||
| 67 | * |
||
| 68 | * @Var Array |
||
| 69 | */ |
||
| 70 | private static $default_sorting = array( |
||
| 71 | 'Created' => 'DESC' |
||
| 72 | ); |
||
| 73 | |||
| 74 | /** |
||
| 75 | * standard SS variable. |
||
| 76 | * |
||
| 77 | * @Var String |
||
| 78 | */ |
||
| 79 | private static $singular_name = 'Order Feedback'; |
||
|
0 ignored issues
–
show
|
|||
| 80 | public function i18n_singular_name() |
||
| 81 | { |
||
| 82 | return _t('OrderFeedback.SINGULAR_NAME', 'Order Feedback'); |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * standard SS variable. |
||
| 87 | * |
||
| 88 | * @Var String |
||
| 89 | */ |
||
| 90 | private static $plural_name = 'Checkout Feedback Entries'; |
||
|
0 ignored issues
–
show
|
|||
| 91 | public function i18n_plural_name() |
||
| 92 | { |
||
| 93 | return _t('OrderFeedback.PLURAL_NAME', 'Order Feedback Entries'); |
||
| 94 | } |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Standard SS variable. |
||
| 98 | * |
||
| 99 | * @var string |
||
| 100 | */ |
||
| 101 | private static $description = 'Customer Order Feedback'; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * standard SS variable. |
||
| 105 | * |
||
| 106 | * @return bool |
||
| 107 | */ |
||
| 108 | private static $can_create = false; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * these are only created programmatically |
||
| 112 | * standard SS method. |
||
| 113 | * |
||
| 114 | * @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. Loading history...
|
|||
| 115 | * |
||
| 116 | * @return bool |
||
| 117 | */ |
||
| 118 | public function canCreate($member = null) |
||
| 119 | { |
||
| 120 | return false; |
||
| 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. Loading history...
|
|||
| 127 | * |
||
| 128 | * @return bool |
||
|
0 ignored issues
–
show
|
|||
| 129 | */ |
||
| 130 | public function canView($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);
Loading history...
|
|||
| 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::canView($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::canView() 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. Loading history...
|
|||
| 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. Loading history...
|
|||
| 150 | * |
||
| 151 | * @return bool |
||
| 152 | */ |
||
| 153 | public function canEdit($member = null) |
||
| 154 | { |
||
| 155 | return false; |
||
| 156 | } |
||
| 157 | |||
| 158 | /** |
||
| 159 | * standard SS method. |
||
| 160 | * |
||
| 161 | * @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. Loading history...
|
|||
| 162 | * |
||
| 163 | * @return bool |
||
| 164 | */ |
||
| 165 | public function canDelete($member = null) |
||
| 166 | { |
||
| 167 | return false; |
||
| 168 | } |
||
| 169 | |||
| 170 | /** |
||
| 171 | * standard SS method. |
||
| 172 | * |
||
| 173 | * @return FieldList |
||
| 174 | */ |
||
| 175 | public function getCMSFields() |
||
| 176 | { |
||
| 177 | $fields = parent::getCMSFields(); |
||
| 178 | $fields->replaceField( |
||
| 179 | 'OrderID', |
||
| 180 | CMSEditLinkField::create( |
||
| 181 | 'OrderIDLink', |
||
| 182 | Injector::inst()->get('Order')->singular_name(), |
||
| 183 | $this->Order() |
||
|
0 ignored issues
–
show
The method
Order does not exist on object<OrderFeedback>? 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 { }
Loading history...
|
|||
| 184 | ) |
||
| 185 | ); |
||
| 186 | return $fields; |
||
| 187 | } |
||
| 188 | |||
| 189 | /** |
||
| 190 | * link to edit the record. |
||
| 191 | * |
||
| 192 | * @param string | Null $action - e.g. edit |
||
| 193 | * |
||
| 194 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 195 | */ |
||
| 196 | public function CMSEditLink($action = null) |
||
| 197 | { |
||
| 198 | return CMSEditLinkAPI::find_edit_link_for_object($this, $action); |
||
| 199 | } |
||
| 200 | |||
| 201 | /** |
||
| 202 | * casted variable. |
||
| 203 | * |
||
| 204 | * @return string |
||
| 205 | */ |
||
| 206 | public function Title() |
||
| 207 | { |
||
| 208 | return $this->getTitle(); |
||
| 209 | } |
||
| 210 | public function getTitle() |
||
| 211 | { |
||
| 212 | $string = $this->Created; |
||
| 213 | if ($this->Order()) { |
||
|
0 ignored issues
–
show
The method
Order does not exist on object<OrderFeedback>? 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 { }
Loading history...
|
|||
| 214 | $string .= ' ('.$this->Order()->getTitle().')'; |
||
|
0 ignored issues
–
show
The method
Order does not exist on object<OrderFeedback>? 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 { }
Loading history...
|
|||
| 215 | } |
||
| 216 | $string .= ' - '.$this->Rating; |
||
|
0 ignored issues
–
show
The property
Rating does not exist on object<OrderFeedback>. 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. Loading history...
|
|||
| 217 | if ($this->Note) { |
||
|
0 ignored issues
–
show
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
|
|||
| 218 | $string .= ' / '. substr($this->Note, 0, 25); |
||
|
0 ignored issues
–
show
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
|
|||
| 219 | } |
||
| 220 | return $string; |
||
| 221 | } |
||
| 222 | |||
| 223 | /** |
||
| 224 | * Event handler called before writing to the database. |
||
| 225 | */ |
||
| 226 | public function onBeforeWrite() |
||
| 227 | { |
||
| 228 | parent::onBeforeWrite(); |
||
| 229 | $this->Note = str_replace(array("\n", "\r"), ' ¶ ', $this->Note); |
||
|
0 ignored issues
–
show
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
|
|||
| 230 | $this->Note = str_replace(array("¶ ¶"), ' ¶ ', $this->Note); |
||
|
0 ignored issues
–
show
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
|
|||
| 231 | $this->Note = str_replace(array("¶ ¶"), ' ¶ ', $this->Note); |
||
|
0 ignored issues
–
show
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
|
|||
| 232 | $this->Note = str_replace(array("¶ ¶"), ' ¶ ', $this->Note); |
||
|
0 ignored issues
–
show
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
The property
Note does not exist on object<OrderFeedback>. 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. Loading history...
|
|||
| 233 | } |
||
| 234 | } |
||
| 235 |