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 | namespace Radowoj\Yaah; |
||
4 | |||
5 | use Radowoj\Yaah\Constants\SellFormOpts; |
||
6 | use Radowoj\Yaah\Journal\Deal; |
||
7 | |||
8 | class Helper |
||
9 | { |
||
10 | protected $client = null; |
||
11 | |||
12 | 21 | public function __construct(Client $client) |
|
13 | { |
||
14 | 21 | $this->client = $client; |
|
15 | 21 | } |
|
16 | |||
17 | /** |
||
18 | * Get simplified fields list for given category |
||
19 | * @param integer $idCategory id of category in question |
||
20 | * @return array of fields metadata |
||
21 | */ |
||
22 | 2 | public function getFieldsByCategory($idCategory) |
|
23 | { |
||
24 | 2 | $data = $this->client->doGetSellFormFieldsForCategory(['categoryId' => $idCategory]); |
|
0 ignored issues
–
show
|
|||
25 | |||
26 | 2 | if (!isset($data->sellFormFieldsForCategory->sellFormFieldsList->item)) { |
|
27 | 1 | throw new Exception('Invalid WebAPI response: ' . print_r($data, 1)); |
|
28 | } |
||
29 | |||
30 | 1 | $items = $data->sellFormFieldsForCategory->sellFormFieldsList->item; |
|
31 | |||
32 | return array_map(function ($item) { |
||
33 | return [ |
||
34 | 1 | 'fid' => $item->sellFormId, |
|
35 | 1 | 'title' => $item->sellFormTitle, |
|
36 | 1 | 'required' => ($item->sellFormOpt == SellFormOpts::SELL_FORM_OPT_REQUIRED), |
|
37 | 1 | 'options' => $item->sellFormOptsValues, |
|
38 | 1 | 'optionsDesc' => $item->sellFormDesc, |
|
39 | 1 | ]; |
|
40 | 1 | }, $items); |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Create new auction |
||
45 | * |
||
46 | * @throws Exception on failure |
||
47 | * |
||
48 | * @param Auction $auction Auction to create |
||
49 | * @param integer $localId - local item id, required by WebAPI |
||
50 | * @return integer id of created auction |
||
51 | */ |
||
52 | 2 | public function newAuction(AuctionInterface $auction, $localId) |
|
53 | { |
||
54 | 2 | $auctionArray = $auction->toApiRepresentation(); |
|
55 | 2 | $auctionArray['localId'] = $localId; |
|
56 | |||
57 | 2 | $this->client->doNewAuctionExt($auctionArray); |
|
0 ignored issues
–
show
The method
doNewAuctionExt does not exist on object<Radowoj\Yaah\Client> ? 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 { }
![]() |
|||
58 | 2 | $resultVerify = $this->client->doVerifyItem(['localId' => $localId]); |
|
0 ignored issues
–
show
The method
doVerifyItem does not exist on object<Radowoj\Yaah\Client> ? 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 { }
![]() |
|||
59 | |||
60 | 2 | if (!is_object($resultVerify) || !isset($resultVerify->itemId)) { |
|
61 | 1 | throw new Exception("Auction has not been created: " . print_r($resultVerify, 1)); |
|
62 | } |
||
63 | |||
64 | 1 | return $resultVerify->itemId; |
|
65 | } |
||
66 | |||
67 | |||
68 | /** |
||
69 | * Finish a single auction |
||
70 | * @param integer $auctionId itemId of auction to finish |
||
71 | * @param integer $cancelAllBids whether to cancel all bids |
||
72 | * @param string $finishCancelReason reason |
||
73 | * @return array |
||
74 | */ |
||
75 | 4 | public function finishAuction($auctionId, $cancelAllBids = 0, $finishCancelReason = '') |
|
76 | { |
||
77 | 4 | return $this->finishAuctions((array)($auctionId), $cancelAllBids, $finishCancelReason); |
|
78 | } |
||
79 | |||
80 | |||
81 | /** |
||
82 | * Finish a single auction |
||
83 | * @param array $auctionIds itemIds of auctions to finish |
||
84 | * @param integer $cancelAllBids whether to cancel all bids |
||
85 | * @param string $finishCancelReason reason |
||
86 | * @return array |
||
87 | */ |
||
88 | 8 | public function finishAuctions(array $auctionIds, $cancelAllBids = 0, $finishCancelReason = '') |
|
89 | { |
||
90 | $finishItemsList = array_map(function ($auctionId) use ($cancelAllBids, $finishCancelReason) { |
||
91 | return [ |
||
92 | 8 | 'finishItemId' => $auctionId, |
|
93 | 8 | 'finishCancelAllBids' => $cancelAllBids, |
|
94 | 8 | 'finishCancelReason' => $finishCancelReason, |
|
95 | 8 | ]; |
|
96 | 8 | }, $auctionIds); |
|
97 | |||
98 | 8 | return $this->client->doFinishItems(['finishItemsList' => $finishItemsList]); |
|
0 ignored issues
–
show
The method
doFinishItems does not exist on object<Radowoj\Yaah\Client> ? 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 { }
![]() |
|||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Change quantity of items available in auction |
||
103 | * @param integer $auctionId itemId of auction to change quantity |
||
104 | * @param integer $newQuantity new quantity to set |
||
105 | * @return array |
||
106 | */ |
||
107 | 1 | public function changeQuantity($auctionId, $newQuantity) |
|
108 | { |
||
109 | 1 | return $this->client->doChangeQuantityItem([ |
|
0 ignored issues
–
show
The method
doChangeQuantityItem does not exist on object<Radowoj\Yaah\Client> ? 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 { }
![]() |
|||
110 | 1 | 'itemId' => $auctionId, |
|
111 | 'newItemQuantity' => $newQuantity |
||
112 | 1 | ]); |
|
113 | } |
||
114 | |||
115 | |||
116 | /** |
||
117 | * Return site journal deals |
||
118 | * @param integer $journalStart start point (dealEventId) |
||
119 | * @return array |
||
120 | */ |
||
121 | 3 | public function getSiteJournalDeals($journalStart = 0) |
|
122 | { |
||
123 | 3 | $response = $this->client->doGetSiteJournalDeals(['journalStart' => $journalStart]); |
|
0 ignored issues
–
show
The method
doGetSiteJournalDeals does not exist on object<Radowoj\Yaah\Client> ? 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 { }
![]() |
|||
124 | 3 | if (isset($response->siteJournalDeals->item)) { |
|
125 | 2 | return array_map(function($deal){ |
|
126 | 2 | return new Deal($deal); |
|
127 | 2 | }, $response->siteJournalDeals->item); |
|
128 | } |
||
129 | |||
130 | 1 | throw new Exception("Unable to get site journal deals: " . print_r($response, 1)); |
|
131 | } |
||
132 | |||
133 | |||
134 | /** |
||
135 | * @param integer $itemId id of auction to get |
||
136 | * @return Auction | null |
||
137 | */ |
||
138 | 2 | public function getAuctionByItemId($itemId) |
|
139 | { |
||
140 | 2 | $response = $this->client->doGetItemFields(['itemId' => $itemId]); |
|
0 ignored issues
–
show
The method
doGetItemFields does not exist on object<Radowoj\Yaah\Client> ? 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 { }
![]() |
|||
141 | 2 | if (!isset($response->itemFields->item)) { |
|
142 | 1 | throw new Exception('Invalid WebAPI response: ' . print_r($response, 1)); |
|
143 | } |
||
144 | |||
145 | 1 | $auction = new Auction(); |
|
146 | 1 | $auction->fromApiRepresentation($response->itemFields->item); |
|
147 | 1 | return $auction; |
|
148 | } |
||
149 | |||
150 | |||
151 | /** |
||
152 | * Directly call WebAPI method (prefixed by "do") |
||
153 | * @param string $name method name |
||
154 | * @param [type] $args method arguments |
||
0 ignored issues
–
show
The doc-type
[type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
155 | * @return [type] [description] |
||
0 ignored issues
–
show
The doc-type
[type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
156 | */ |
||
157 | 3 | public function __call($name, $args) |
|
158 | { |
||
159 | 3 | if (strpos($name, 'do') !== 0) { |
|
160 | 1 | throw new Exception("Method {$name} is not implemented in " . get_class($this)); |
|
161 | } |
||
162 | |||
163 | 2 | return call_user_func_array([$this->client, $name], $args); |
|
164 | } |
||
165 | |||
166 | } |
||
167 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: