1 | <?php |
||
17 | class CartFinisher extends BaseObject |
||
18 | { |
||
19 | /** |
||
20 | * @var ShoppingCart |
||
21 | */ |
||
22 | public $cart; |
||
23 | |||
24 | /** |
||
25 | * @var PurchaseStrategyInterface[] |
||
26 | */ |
||
27 | protected $purchasers = []; |
||
28 | |||
29 | /** |
||
30 | * @var AbstractPurchase[] array of successful purchases |
||
31 | */ |
||
32 | protected $_success = []; |
||
33 | |||
34 | /** |
||
35 | * @var ErrorPurchaseException[] array of failed purchases |
||
36 | */ |
||
37 | protected $_error = []; |
||
38 | |||
39 | /** |
||
40 | * @var PendingPurchaseException[] array of purchases that are pending |
||
41 | */ |
||
42 | protected $_pending = []; |
||
43 | |||
44 | /** |
||
45 | * Getter for array of successful purchases. |
||
46 | * @return AbstractPurchase[] |
||
47 | */ |
||
48 | public function getSuccess() |
||
52 | |||
53 | /** |
||
54 | * Getter for array of failed purchases. |
||
55 | * @return ErrorPurchaseException[] |
||
56 | */ |
||
57 | public function getError() |
||
61 | |||
62 | /** |
||
63 | * Getter for array of failed purchases. |
||
64 | * @return PendingPurchaseException[] |
||
65 | */ |
||
66 | public function getPending() |
||
70 | |||
71 | /** |
||
72 | * Runs the purchase. |
||
73 | * Purchases the positions in the [[cart]]. |
||
74 | */ |
||
75 | public function run() |
||
96 | |||
97 | protected function ensureCanBeFinished() |
||
120 | |||
121 | protected function createPurchasers() |
||
133 | |||
134 | /** |
||
135 | * @param string $class |
||
136 | * @return PurchaseStrategyInterface |
||
137 | */ |
||
138 | protected function getPurchaser($class) |
||
146 | } |
||
147 |
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: