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 | * connection with external stock setting systems |
||
5 | * as an orderstep |
||
6 | * |
||
7 | * |
||
8 | */ |
||
9 | |||
10 | |||
11 | class StockControlPing_OrderStep extends OrderStep |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
14 | "URLToPing" => "Varchar(200)", |
||
15 | "Username" => "Varchar(30)", |
||
16 | "Password" => "Varchar(30)" |
||
17 | ); |
||
18 | |||
19 | private static $defaults = array( |
||
0 ignored issues
–
show
|
|||
20 | "CustomerCanEdit" => 0, |
||
21 | "CustomerCanPay" => 0, |
||
22 | "CustomerCanCancel" => 0, |
||
23 | "Name" => "StockControlPing", |
||
24 | "Code" => "STOCKCONTROLPING", |
||
25 | "Sort" => 23, |
||
26 | "ShowAsInProcessOrder" => 1 |
||
27 | ); |
||
28 | |||
29 | public function getCMSFields() |
||
30 | { |
||
31 | $fields = parent::getCMSFields(); |
||
32 | $fields->addFieldToTab("Root.Main", new HeaderField("HowToSaveSubmittedOrder", _t("OrderStep.STOCKCONTROLPING", "Please enter details below"), 3), "URLToPing"); |
||
33 | return $fields; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Can run this step once any items have been submitted. |
||
38 | * @param DataObject - $order Order |
||
39 | * @return Boolean |
||
40 | **/ |
||
41 | public function initStep(Order $order) |
||
42 | { |
||
43 | return true; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Add a member to the order - in case he / she is not a shop admin. |
||
48 | * @param DataObject - $order Order |
||
49 | * @return Boolean |
||
50 | **/ |
||
51 | public function doStep(Order $order) |
||
52 | { |
||
53 | $stockControlPing = StockControlPing_OrderStatusLog::get() |
||
54 | ->filter(array('OrderID' => $order->ID))->First(); |
||
55 | if (!$stockControlPing) { |
||
56 | if ($this->Username && $this->Password) { |
||
0 ignored issues
–
show
The property
Username does not exist on object<StockControlPing_OrderStep> . 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...
The property
Password does not exist on object<StockControlPing_OrderStep> . 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...
|
|||
57 | $authentication = array( |
||
58 | CURLOPT_USERPWD => |
||
59 | $this->Username.":".$this->Password |
||
0 ignored issues
–
show
The property
Username does not exist on object<StockControlPing_OrderStep> . 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...
The property
Password does not exist on object<StockControlPing_OrderStep> . 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...
|
|||
60 | ); |
||
61 | } else { |
||
62 | $authentication = array(); |
||
63 | } |
||
64 | $outcome = $this->curlGet( |
||
65 | $this->URLToPing, |
||
0 ignored issues
–
show
The property
URLToPing does not exist on object<StockControlPing_OrderStep> . 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...
|
|||
66 | array( |
||
67 | "id" => $order->ID, |
||
68 | "link" => urlencode($order->APILink()) |
||
69 | ), |
||
70 | $authentication |
||
71 | ); |
||
72 | //create record |
||
73 | $obj = new StockControlPing_OrderStatusLog(); |
||
74 | $obj->OrderID = $order->ID; |
||
0 ignored issues
–
show
The property
OrderID does not exist on object<StockControlPing_OrderStatusLog> . 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...
|
|||
75 | $obj->Note = $outcome; |
||
0 ignored issues
–
show
The property
Note does not exist on object<StockControlPing_OrderStatusLog> . 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...
|
|||
76 | $obj->write(); |
||
77 | } |
||
78 | return true; |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * go to next step if order has been submitted. |
||
83 | *@param DataObject - $order Order |
||
84 | *@return DataObject | Null (next step OrderStep) |
||
0 ignored issues
–
show
|
|||
85 | **/ |
||
86 | public function nextStep(Order $order) |
||
87 | { |
||
88 | if ($order->IsSubmitted()) { |
||
89 | return parent::nextStep($order); |
||
90 | } |
||
91 | return null; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * |
||
96 | * @return Boolean |
||
97 | */ |
||
98 | protected function hasCustomerMessage() |
||
99 | { |
||
100 | return false; |
||
101 | } |
||
102 | |||
103 | /** |
||
104 | * Explains the current order step. |
||
105 | * @return String |
||
106 | */ |
||
107 | protected function myDescription() |
||
108 | { |
||
109 | return _t("OrderStep.STOCKCONTROLPING_DESCRIPTION", "Sends a 'ping' to a third-party stock control system."); |
||
110 | } |
||
111 | |||
112 | |||
113 | /** |
||
114 | * Send a GET requst using cURL |
||
115 | * @source php.net |
||
116 | * @param string $url to request |
||
117 | * @param array $get values to send |
||
0 ignored issues
–
show
Should the type for parameter
$get not be null|array ?
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...
|
|||
118 | * @param array $options for cURL |
||
119 | * @return string |
||
120 | */ |
||
121 | protected function curlGet($url, array $get = null, array $options = array()) |
||
122 | { |
||
123 | $defaults = array( |
||
124 | CURLOPT_URL => $url. (strpos($url, '?') === false ? '?' : ''). http_build_query($get), |
||
125 | CURLOPT_HEADER => 0, |
||
126 | CURLOPT_RETURNTRANSFER => true, |
||
127 | CURLOPT_TIMEOUT => 4 |
||
128 | ); |
||
129 | $ch = curl_init(); |
||
130 | curl_setopt_array($ch, ($options + $defaults)); |
||
131 | if (! $result = curl_exec($ch)) { |
||
132 | return curl_error($ch); |
||
133 | } |
||
134 | curl_close($ch); |
||
135 | return $result; |
||
136 | } |
||
137 | } |
||
138 | |||
139 | |||
140 | class StockControlPing_OrderStatusLog extends OrderStatusLog |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
Loading history...
|
|||
141 | { |
||
142 | private static $singular_name = "Stock Control External Ping"; |
||
0 ignored issues
–
show
|
|||
143 | public function i18n_singular_name() |
||
144 | { |
||
145 | return _t("OrderStatusLog.STOCKCONTROLEXTERNALPING", "Stock Control External Ping"); |
||
146 | } |
||
147 | |||
148 | private static $plural_name = "Stock Control External Pings"; |
||
0 ignored issues
–
show
|
|||
149 | public function i18n_plural_name() |
||
150 | { |
||
151 | return _t("OrderStatusLog.STOCKCONTROLEXTERNALPINGS", "Stock Control External Pings"); |
||
152 | } |
||
153 | |||
154 | private static $defaults = array( |
||
0 ignored issues
–
show
|
|||
155 | 'Title' => 'Ping External Service', |
||
156 | 'Note' => 'HTMLText', |
||
157 | 'InternalUseOnly' => 1 |
||
158 | ); |
||
159 | } |
||
160 | |||
161 | /** |
||
162 | * |
||
163 | * |
||
164 | * |
||
165 | * |
||
166 | * |
||
167 | * Example of POST: |
||
168 | * function TestPost() { |
||
169 | * |
||
170 | * $baseURL = Director::absoluteBaseURL(); |
||
171 | * |
||
172 | * // 1) My Personal Data |
||
173 | * |
||
174 | * $className = 'StockControlPing_IncomingUpdate'; |
||
175 | * $fields = array( |
||
176 | * 'AllowPurchase' => 0, |
||
177 | * 'InternalItemID' => "xxxx", |
||
178 | * //below are optional (if you include ID then you leave out InternalItemID)k6 |
||
179 | * |
||
180 | * //'BuyableClassName' => 'Product', |
||
181 | * //'BuyableID' => 123, |
||
182 | * ); |
||
183 | * |
||
184 | * // 2) The Query |
||
185 | * |
||
186 | * $url = "{$baseURL}/api/ecommerce/v1/{$className}.xml"; |
||
187 | * $body = $fields; |
||
188 | * $c = curl_init($url); |
||
189 | * curl_setopt($c, CURLOPT_POST, true); |
||
190 | * curl_setopt($c, CURLOPT_POSTFIELDS, $body); |
||
191 | * curl_setopt($c, CURLOPT_RETURNTRANSFER, true); |
||
192 | * $page = curl_exec($c); |
||
193 | * curl_close($c); |
||
194 | * |
||
195 | * // 3) The XML Result |
||
196 | * return $page; |
||
197 | * } |
||
198 | * |
||
199 | * |
||
200 | */ |
||
201 | class StockControlPing_IncomingUpdate extends DataObject |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.
Loading history...
|
|||
202 | { |
||
203 | private static $api_access = array( |
||
0 ignored issues
–
show
|
|||
204 | 'create' => array('InternalItemID', 'BuyableClassName', 'BuyableID', 'AllowPurchase'), |
||
205 | 'add' => array('InternalItemID', 'BuyableClassName', 'BuyableID', 'AllowPurchase'), |
||
206 | 'view' => array('InternalItemID', 'BuyableClassName', 'BuyableID', 'AllowPurchase') |
||
207 | ); |
||
208 | |||
209 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
210 | "InternalItemID" => "Varchar(30)", |
||
211 | "BuyableClassName" => "Varchar(50)", |
||
212 | "BuyableID" => "Int", |
||
213 | "AllowPurchase" => "Boolean", |
||
214 | "Actioned" => "Boolean" |
||
215 | ); |
||
216 | |||
217 | private static $default_sort = "\"LastEdited\" DESC"; |
||
0 ignored issues
–
show
|
|||
218 | |||
219 | private static $singular_name = "External Update to Product Availability"; |
||
0 ignored issues
–
show
|
|||
220 | public function i18n_singular_name() |
||
221 | { |
||
222 | return _t("StockControlPing.EXTERNALUPDATETOPRODUCTAVAILABILITY", "External Update to Product Availability"); |
||
223 | } |
||
224 | |||
225 | private static $plural_name = "External Updates to Product Availability"; |
||
0 ignored issues
–
show
|
|||
226 | public function i18n_plural_name() |
||
227 | { |
||
228 | return _t("StockControlPing.EXTERNALUPDATESTOPRODUCTAVAILABILITY", "External Updates to Product Availability"); |
||
229 | } |
||
230 | |||
231 | public function canView($member = null) |
||
232 | { |
||
233 | return $this->canDoAnything($member); |
||
234 | } |
||
235 | |||
236 | public function canCreate($member = null) |
||
237 | { |
||
238 | return $this->canDoAnything($member); |
||
239 | } |
||
240 | |||
241 | public function canEdit($member = null) |
||
242 | { |
||
243 | return false; |
||
244 | } |
||
245 | |||
246 | public function canDelete($member = null) |
||
247 | { |
||
248 | return false; |
||
249 | } |
||
250 | |||
251 | View Code Duplication | protected function canDoAnything($member = null) |
|
0 ignored issues
–
show
This method seems to be duplicated in 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...
|
|||
252 | { |
||
253 | $shopAdminCode = EcommerceConfig::get("EcommerceRole", "admin_permission_code"); |
||
254 | if (!Permission::check("ADMIN") && !Permission::check($shopAdminCode)) { |
||
255 | Security::permissionFailure($this, _t('Security.PERMFAILURE', ' This page is secured and you need administrator rights to access it. Enter your credentials below and we will send you right along.')); |
||
0 ignored issues
–
show
$this is of type this<StockControlPing_IncomingUpdate> , but the function expects a object<Controller>|null .
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...
|
|||
256 | } |
||
257 | return true; |
||
258 | } |
||
259 | |||
260 | |||
261 | public function onAfterWrite() |
||
262 | { |
||
263 | parent::onAfterWrite(); |
||
264 | //TODO: move to findBuyable in Core Ecommerce Code! |
||
265 | if (!$this->Actioned) { |
||
0 ignored issues
–
show
The property
Actioned does not exist on object<StockControlPing_IncomingUpdate> . 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...
|
|||
266 | $internalItemID = Convert::raw2sql($this->InternalItemID); |
||
0 ignored issues
–
show
The property
InternalItemID does not exist on object<StockControlPing_IncomingUpdate> . 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...
|
|||
267 | $id = intval($this->ID); |
||
268 | $className = Convert::raw2sql($this->BuyableClassName); |
||
0 ignored issues
–
show
The property
BuyableClassName does not seem to exist. Did you mean ClassName ?
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.
Loading history...
|
|||
269 | $allowPurchase = $this->AllowPurchase ? 1 : 0; |
||
0 ignored issues
–
show
The property
AllowPurchase does not exist on object<StockControlPing_IncomingUpdate> . 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...
|
|||
270 | if ($className) { |
||
271 | if ($className && $id) { |
||
272 | $buyable = $className::get()->byID($id); |
||
273 | } else { |
||
274 | $buyable = $className::get()->filter(array('InternalItemID' => $internalItemID))->First(); |
||
275 | } |
||
276 | } else { |
||
277 | $buyablesArray = EcommerceConfig::get($className = "EcommerceDBConfig", $identifier = "array_of_buyables"); |
||
278 | if (is_array($buyablesArray)) { |
||
279 | if (count($buyablesArray)) { |
||
280 | foreach ($buyablesArray as $className) { |
||
281 | $buyable = $className::get()->filter(array('InternalItemID' => $internalItemID))->First(); |
||
282 | if ($buyable) { |
||
283 | break; |
||
284 | } |
||
285 | } |
||
286 | } |
||
287 | } |
||
288 | } |
||
289 | if ($buyable) { |
||
290 | if ($buyable->AllowPurchase =! $allowPurchase) { |
||
291 | $buyable->AllowPurchase = $allowPurchase; |
||
0 ignored issues
–
show
The variable
$buyable does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
Loading history...
|
|||
292 | if ($buyable instanceof SiteTree) { |
||
293 | $buyable->writeToStage('Stage'); |
||
294 | $buyable->publish('Stage', 'Live'); |
||
0 ignored issues
–
show
|
|||
295 | } else { |
||
296 | $buyable->write(); |
||
297 | } |
||
298 | } |
||
299 | $this->BuyableClassName = $buyable->ClassName; |
||
0 ignored issues
–
show
The property
BuyableClassName does not seem to exist. Did you mean ClassName ?
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.
Loading history...
|
|||
300 | $this->BuyableID = $buyable->ID; |
||
0 ignored issues
–
show
The property
BuyableID does not exist on object<StockControlPing_IncomingUpdate> . 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...
|
|||
301 | } |
||
302 | $this->Actioned = 1; |
||
0 ignored issues
–
show
The property
Actioned does not exist on object<StockControlPing_IncomingUpdate> . 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...
|
|||
303 | $this->write(); |
||
304 | } |
||
305 | } |
||
306 | } |
||
307 |
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.