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 | *@author nicolaas [at] sunny side up. co . nz |
||
5 | * |
||
6 | * |
||
7 | **/ |
||
8 | |||
9 | |||
10 | class DpsPxPayStoredPayment extends DpsPxPayPayment |
||
0 ignored issues
–
show
|
|||
11 | { |
||
12 | private static $pxaccess_url = 'https://sec.paymentexpress.com/pxpay/pxaccess.aspx'; |
||
0 ignored issues
–
show
|
|||
13 | |||
14 | private static $pxpost_url = 'https://sec.paymentexpress.com/pxpost.aspx'; |
||
0 ignored issues
–
show
|
|||
15 | |||
16 | private static $username = ''; |
||
0 ignored issues
–
show
|
|||
17 | |||
18 | private static $password = ''; |
||
0 ignored issues
–
show
|
|||
19 | |||
20 | private static $add_card_explanation = "Storing a Card means your Credit Card will be kept on file for your next purchase. "; |
||
0 ignored issues
–
show
|
|||
21 | |||
22 | public function getPaymentFormFields() |
||
23 | { |
||
24 | $logo = '<img src="' . self::$logo . '" alt="Credit Card Payments Powered by DPS"/>'; |
||
0 ignored issues
–
show
The property
$logo is declared private in DpsPxPayPayment . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
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. ![]() |
|||
25 | $privacyLink = '<a href="' . self::$privacy_link . '" target="_blank" title="Read DPS\'s privacy policy">' . $logo . '</a><br/>'; |
||
0 ignored issues
–
show
The property
$privacy_link is declared private in DpsPxPayPayment . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
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. ![]() |
|||
26 | $paymentsList = ''; |
||
27 | foreach (self::$credit_cards as $name => $image) { |
||
0 ignored issues
–
show
The property
$credit_cards is declared private in DpsPxPayPayment . Since you implemented __get() , maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.
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. ![]() |
|||
28 | $paymentsList .= '<img src="' . $image . '" alt="' . $name . '"/>'; |
||
29 | } |
||
30 | |||
31 | $fields = new FieldList(); |
||
32 | $storedCards = null; |
||
33 | if ($m = Member::currentUser()) { |
||
34 | $storedCards = DpsPxPayStoredCard::get()->filter(array("MemberID" => $m->ID)); |
||
35 | } |
||
36 | |||
37 | $cardsDropdown = array('' => ' --- Select Stored Card ---'); |
||
38 | |||
39 | if ($storedCards->count()) { |
||
40 | foreach ($storedCards as $card) { |
||
0 ignored issues
–
show
The expression
$storedCards of type object<DataList>|null is not guaranteed to be traversable. How about adding an additional type check?
There are different options of fixing this problem.
![]() |
|||
41 | $cardsDropdown[$card->BillingID] = $card->CardHolder.' - '.$card->CardNumber.' ('.$card->CardName.')'; |
||
42 | } |
||
43 | $s = ""; |
||
44 | if ($storedCards->count()>1) { |
||
45 | $s = "s"; |
||
46 | } |
||
47 | $cardsDropdown["deletecards"] = " --- Delete Stored Card$s --- "; |
||
48 | $fields->push(new DropdownField('DPSUseStoredCard', 'Use a stored card?', $cardsDropdown, $value = $card->BillingID, $form = null, $emptyString = "--- use new Credit Card ---")); |
||
0 ignored issues
–
show
The variable
$card seems to be defined by a foreach iteration on line 40 . Are you sure the iterator is never empty, otherwise this variable is not defined?
It seems like you are relying on a variable being defined by an iteration: foreach ($a as $b) {
}
// $b is defined here only if $a has elements, for example if $a is array()
// then $b would not be defined here. To avoid that, we recommend to set a
// default value for $b.
// Better
$b = 0; // or whatever default makes sense in your context
foreach ($a as $b) {
}
// $b is now guaranteed to be defined here.
![]() |
|||
49 | } else { |
||
50 | $fields->push(new DropdownField('DPSStoreCard', '', array(1 => 'Store Credit Card', 0 => 'Do NOT Store Credit Card'))); |
||
51 | $fields->push(new LiteralField("AddCardExplanation", "<p>".Config::inst()->get('DpsPxPayStoredPayment', 'add_card_explanation')."</p>")); |
||
52 | } |
||
53 | $fields->push(new LiteralField('DPSInfo', $privacyLink)); |
||
54 | $fields->push(new LiteralField('DPSPaymentsList', $paymentsList)); |
||
55 | Requirements::javascript(THIRDPARTY_DIR."/jquery/jquery.js"); |
||
56 | //Requirements::block(THIRDPARTY_DIR."/jquery/jquery.js"); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
56% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
57 | //Requirements::javascript(Director::protocol()."ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
62% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
58 | Requirements::javascript("payment_dps/javascript/DpxPxPayStoredPayment.js"); |
||
59 | return $fields; |
||
60 | } |
||
61 | |||
62 | public function autoProcessPayment($amount, $ref) |
||
63 | { |
||
64 | $DPSUrl = $this->buildURL($amount, $ref, false); |
||
0 ignored issues
–
show
$DPSUrl is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
65 | /* |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
51% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
66 | add CURL HERE |
||
67 | $data = array('page' => $page); |
||
68 | // create our curl object |
||
69 | $ch = curl_init(); |
||
70 | $lurl = 'http://www.test.com'; |
||
71 | curl_setopt( $ch, CURLOPT_POST, true ); |
||
72 | curl_setopt( $ch, CURLOPT_POSTFIELDS,$data); |
||
73 | curl_setopt($ch, CURLOPT_URL, $lurl); |
||
74 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); |
||
75 | curl_setopt($ch, CURLOPT_HEADER, 0); |
||
76 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
||
77 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); |
||
78 | curl_setopt($ch, CURLOPT_FAILONERROR, 0); |
||
79 | $content = curl_exec($ch); |
||
80 | curl_close($ch); |
||
81 | return $content; |
||
82 | */ |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @param array $data The form request data - see OrderForm |
||
87 | * @param OrderForm $form The form object submitted on |
||
88 | * |
||
89 | * @return EcommercePayment_Result |
||
90 | */ |
||
91 | public function processPayment($data, $form) |
||
92 | { |
||
93 | if (!isset($data["DPSUseStoredCard"])) { |
||
94 | $data["DPSUseStoredCard"] = null; |
||
95 | } |
||
96 | if (!isset($data["DPSStoreCard"])) { |
||
97 | $data["DPSStoreCard"] = null; |
||
98 | } |
||
99 | if (!isset($data["Amount"])) { |
||
100 | USER_ERROR("There was no amount information for processing the payment.", E_USER_WARNING); |
||
101 | } |
||
102 | if ($data["DPSUseStoredCard"] == "deletecards") { |
||
103 | //important!!! |
||
104 | $data["DPSUseStoredCard"] = null; |
||
105 | if ($m = Member::currentUser()) { |
||
106 | $storedCards = DpsPxPayStoredCard::get()->filter(array("MemberID" => $m->ID)); |
||
107 | if ($storedCards->count()) { |
||
108 | foreach ($storedCards as $card) { |
||
109 | $card->delete(); |
||
110 | } |
||
111 | if ($storedCards = DpsPxPayStoredCard::get()->filter(array("MemberID" => $m->ID))) { |
||
0 ignored issues
–
show
$storedCards is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
112 | DB::query("DELETE FROM DpsPxPayStoredCard WHERE MemberID = ".$m->ID); |
||
113 | } |
||
114 | } |
||
115 | } |
||
116 | } elseif ($data["DPSUseStoredCard"]) { |
||
117 | return $this->processViaPostRatherThanPxPay($data, $form, $data["DPSUseStoredCard"]); |
||
118 | } |
||
119 | $url = $this->buildURL($data["Amount"], $data["DPSUseStoredCard"], $data["DPSStoreCard"]); |
||
120 | return $this->executeURL($url); |
||
121 | } |
||
122 | |||
123 | |||
124 | |||
125 | |||
126 | public function processViaPostRatherThanPxPay($data, $form, $cardToUse) |
||
0 ignored issues
–
show
|
|||
127 | { |
||
128 | |||
129 | // 1) Main Settings |
||
130 | |||
131 | $inputs['PostUsername'] = $this->config->get("username"); |
||
0 ignored issues
–
show
The property
config does not exist on object<DpsPxPayStoredPayment> . 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. ![]() Coding Style
Comprehensibility
introduced
by
$inputs was never initialized. Although not strictly required by PHP, it is generally a good practice to add $inputs = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
132 | $inputs['PostPassword'] = $this->config->get("password"); |
||
0 ignored issues
–
show
The property
config does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
133 | |||
134 | // 2) Payment Informations |
||
135 | |||
136 | $inputs['Amount'] = $this->Amount->Amount; |
||
0 ignored issues
–
show
The property
Amount does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
137 | $inputs['InputCurrency'] = $this->Amount->Currency; |
||
0 ignored issues
–
show
The property
Amount does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
138 | $inputs['TxnId'] = $this->ID; |
||
139 | $inputs['TxnType'] = DpsPxPayComs::get_txn_type(); |
||
140 | $inputs["MerchantReference"] = $this->ID; |
||
141 | |||
142 | // 3) Credit Card Informations |
||
143 | $inputs["DpsBillingId"] = $cardToUse; |
||
144 | |||
145 | |||
146 | // 4) DPS Transaction Sending |
||
147 | |||
148 | $responseFields = $this->doPayment($inputs); |
||
149 | // 5) DPS Response Management |
||
150 | |||
151 | if (isset($responseFields['SUCCESS']) && $responseFields['SUCCESS']) { |
||
152 | $this->Status = 'Success'; |
||
0 ignored issues
–
show
The property
Status does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
153 | $result = EcommercePayment_Success::create(); |
||
154 | } else { |
||
155 | $this->Status = 'Failure'; |
||
0 ignored issues
–
show
The property
Status does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
156 | $result = EcommercePayment_Failure::create(); |
||
157 | } |
||
158 | if (isset($responseFields['DPSTXNREF'])) { |
||
159 | if ($transactionRef = $responseFields['DPSTXNREF']) { |
||
160 | $this->TxnRef = $transactionRef; |
||
0 ignored issues
–
show
The property
TxnRef does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
161 | } |
||
162 | } |
||
163 | |||
164 | if (isset($responseFields['HELPTEXT'])) { |
||
165 | if ($helpText = $responseFields['HELPTEXT']) { |
||
166 | $this->Message = $helpText; |
||
0 ignored issues
–
show
The property
Message does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
167 | } |
||
168 | } |
||
169 | if (isset($responseFields['RESPONSETEXT'])) { |
||
170 | if ($responseText = $responseFields['RESPONSETEXT']) { |
||
171 | $this->Message .= $responseText; |
||
0 ignored issues
–
show
The property
Message does not exist on object<DpsPxPayStoredPayment> . 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. ![]() |
|||
172 | } |
||
173 | } |
||
174 | |||
175 | $this->write(); |
||
176 | return $result; |
||
177 | } |
||
178 | |||
179 | public function doPayment(array $inputs) |
||
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 ![]() |
|||
180 | { |
||
181 | |||
182 | // 1) Transaction Creation |
||
183 | $transaction = "<Txn>"; |
||
184 | foreach ($inputs as $name => $value) { |
||
185 | if ($name == "Amount") { |
||
186 | $value = number_format($value, 2, '.', ''); |
||
187 | } |
||
188 | $transaction .= "<$name>$value</$name>"; |
||
189 | } |
||
190 | $transaction .= "</Txn>"; |
||
191 | |||
192 | // 2) CURL Creation |
||
193 | $clientURL = curl_init(); |
||
194 | curl_setopt($clientURL, CURLOPT_URL, $this->config()-get("pxpost_url")); |
||
195 | curl_setopt($clientURL, CURLOPT_POST, 1); |
||
196 | curl_setopt($clientURL, CURLOPT_POSTFIELDS, $transaction); |
||
197 | curl_setopt($clientURL, CURLOPT_RETURNTRANSFER, 1); |
||
198 | //curl_setopt($clientURL, CURLOPT_SSLVERSION, 3); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
199 | |||
200 | // 3) CURL Execution |
||
201 | |||
202 | $resultXml = curl_exec($clientURL); |
||
203 | |||
204 | // 4) CURL Closing |
||
205 | |||
206 | curl_close($clientURL); |
||
207 | |||
208 | // 5) XML Parser Creation |
||
209 | |||
210 | $xmlParser = xml_parser_create(); |
||
211 | $values = null; |
||
212 | $indexes = null; |
||
213 | xml_parse_into_struct($xmlParser, $resultXml, $values, $indexes); |
||
214 | xml_parser_free($xmlParser); |
||
215 | |||
216 | // 6) XML Result Parsed In A PHP Array |
||
217 | |||
218 | $resultPhp = array(); |
||
219 | $level = array(); |
||
220 | foreach ($values as $xmlElement) { |
||
221 | if ($xmlElement['type'] == 'open') { |
||
222 | if (array_key_exists('attributes', $xmlElement)) { |
||
223 | $arrayValues = array_values($xmlElement['attributes']); |
||
224 | list($level[$xmlElement['level']], $extra) = $arrayValues; |
||
0 ignored issues
–
show
The assignment to
$extra is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
225 | } else { |
||
226 | $level[$xmlElement['level']] = $xmlElement['tag']; |
||
227 | } |
||
228 | } elseif ($xmlElement['type'] == 'complete') { |
||
229 | $startLevel = 1; |
||
230 | $phpArray = '$resultPhp'; |
||
231 | while ($startLevel < $xmlElement['level']) { |
||
232 | $phpArray .= '[$level['. $startLevel++ .']]'; |
||
233 | } |
||
234 | $phpArray .= '[$xmlElement[\'tag\']] = array_key_exists(\'value\', $xmlElement)? $xmlElement[\'value\'] : null;'; |
||
235 | eval($phpArray); |
||
0 ignored issues
–
show
It is generally not recommended to use
eval unless absolutely required.
On one hand, ![]() |
|||
236 | } |
||
237 | } |
||
238 | if (!isset($resultPhp['TXN'])) { |
||
239 | return false; |
||
240 | } |
||
241 | $result = $resultPhp['TXN']; |
||
242 | return $result; |
||
243 | } |
||
244 | |||
245 | |||
246 | |||
247 | protected function buildURL($amount, $cardToUse = '', $storeCard = false) |
||
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 ![]() |
|||
248 | { |
||
249 | $commsObject = new DpsPxPayComs(); |
||
250 | |||
251 | /** |
||
252 | * order details |
||
253 | **/ |
||
254 | $commsObject->setTxnType(DpsPxPayComs::get_txn_type()); |
||
255 | $commsObject->setMerchantReference($this->ID); |
||
256 | //replace any character that is NOT [0-9] or dot (.) |
||
257 | $commsObject->setAmountInput(floatval(preg_replace("/[^0-9\.]/", "", $amount))); |
||
258 | |||
259 | if (isset($cardToUse)) { |
||
260 | $commsObject->setBillingId($cardToUse); |
||
261 | } elseif ($storeCard) { |
||
262 | $commsObject->setEnableAddBillCard(1); |
||
263 | } |
||
264 | |||
265 | /** |
||
266 | * details of the redirection |
||
267 | **/ |
||
268 | $link = DpsPxPayStoredPayment_Handler::absolute_complete_link(); |
||
269 | $commsObject->setUrlFail($link); |
||
270 | $commsObject->setUrlSuccess($link); |
||
271 | |||
272 | /** |
||
273 | * process payment data (check if it is OK and go forward if it is... |
||
274 | **/ |
||
275 | $url = $commsObject->startPaymentProcess(); |
||
276 | |||
277 | return $url; |
||
278 | } |
||
279 | } |
||
280 |
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.