Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
8 | class PromotionsTest extends AbstractAPITest |
||
9 | { |
||
10 | protected static $promotionId; |
||
11 | protected static $couponPromotionId; |
||
12 | |||
13 | protected $promotion; |
||
14 | |||
15 | public function setUp() |
||
29 | |||
30 | public function testListPromotions() |
||
35 | |||
36 | public function testCreatePromotion() |
||
44 | |||
45 | /** |
||
46 | * @depends testCreatePromotion |
||
47 | */ |
||
48 | public function testGetPromotion() |
||
55 | |||
56 | /** |
||
57 | * @depends testGetPromotion |
||
58 | */ |
||
59 | public function testUpdatePromotion() |
||
67 | |||
68 | /** |
||
69 | * @depends testUpdatePromotion |
||
70 | */ |
||
71 | public function testSetPromotionSubject() |
||
83 | |||
84 | /** |
||
85 | * @depends testSetPromotionSubject |
||
86 | */ |
||
87 | public function testGetPromotionSubject() |
||
94 | |||
95 | public function testSetPromotionPaymentSystems() |
||
99 | |||
100 | /** |
||
101 | * @depends testGetPromotionSubject |
||
102 | */ |
||
103 | public function testGetPromotionPaymentSystems() |
||
110 | |||
111 | /** |
||
112 | * @depends testGetPromotionPaymentSystems |
||
113 | */ |
||
114 | public function testSetPromotionPeriods() |
||
131 | |||
132 | /** |
||
133 | * @depends testSetPromotionPeriods |
||
134 | */ |
||
135 | public function testGetPromotionPeriods() |
||
142 | |||
143 | /** |
||
144 | * @depends testGetPromotionPeriods |
||
145 | */ |
||
146 | View Code Duplication | public function testSetPromotionRewards() |
|
158 | |||
159 | /** |
||
160 | * @depends testSetPromotionRewards |
||
161 | */ |
||
162 | public function testGetPromotionRewards() |
||
169 | |||
170 | /** |
||
171 | * @depends testGetPromotionRewards |
||
172 | */ |
||
173 | public function testReviewPromotion() |
||
180 | |||
181 | /** |
||
182 | * @depends testReviewPromotion |
||
183 | */ |
||
184 | public function testCreateCouponPromotion() |
||
199 | |||
200 | /** |
||
201 | * @depends testCreateCouponPromotion |
||
202 | */ |
||
203 | View Code Duplication | public function testGetCouponPromotions() |
|
211 | |||
212 | /** |
||
213 | * @depends testCreateCouponPromotion |
||
214 | */ |
||
215 | View Code Duplication | public function testUpdatePromotionCampaigns() |
|
225 | |||
226 | /** |
||
227 | * @depends testUpdatePromotionCampaigns |
||
228 | */ |
||
229 | public function testTogglePromotion() |
||
236 | |||
237 | /** |
||
238 | * @depends testUpdatePromotionCampaigns |
||
239 | */ |
||
240 | public function testDeletePromotion() |
||
247 | } |
||
248 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.