GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Setup Failed
Push — action_getCatTree_order ( 77944b )
by
unknown
23:56
created

Order   F

Complexity

Total Complexity 71

Size/Duplication

Total Lines 485
Duplicated Lines 4.12 %

Coupling/Cohesion

Components 2
Dependencies 26

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 71
lcom 2
cbo 26
dl 20
loc 485
rs 1.3043
c 1
b 1
f 0

30 Methods

Rating   Name   Duplication   Size   Complexity  
A tableName() 0 4 1
A getItems() 0 4 1
A getPaymentType() 0 4 1
A getTransactions() 0 4 1
A getUser() 0 4 1
A getCode() 0 4 1
A getCustomer() 0 4 1
A getContragent() 0 4 1
A getManager() 0 4 1
A getOrderDeliveryInformation() 0 4 1
A clearStaticOrder() 0 4 1
A behaviors() 0 17 1
B rules() 0 35 1
B scenarios() 0 34 1
B attributeLabels() 0 27 1
A getStage() 0 7 2
A getShippingOption() 0 5 2
A getSpecialPriceObjects() 0 15 1
A getFullPrice() 0 8 2
B beforeDelete() 0 20 5
A search() 20 20 2
C create() 0 27 7
D getOrder() 0 29 9
C calculate() 0 35 11
A beforeSave() 0 5 1
B afterSave() 0 13 6
A afterDelete() 0 5 1
A deleteOrderElements() 0 10 3
A getImmutability() 0 9 2
A getOrderState() 0 7 2

How to fix   Duplicated Code    Complexity   

Duplicated Code

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:

Complex Class

 Tip:   Before tackling complexity, make sure that you eliminate any duplication first. This often can reduce the size of classes significantly.

Complex classes like Order often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Order, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace app\modules\shop\models;
4
5
use app\modules\core\helpers\EventTriggeringHelper;
6
use app\modules\shop\events\OrderCalculateEvent;
7
use app\modules\shop\helpers\PriceHelper;
8
use app\modules\user\models\User;
9
use app\properties\HasProperties;
10
use Yii;
11
use yii\base\Exception;
12
use yii\behaviors\TimestampBehavior;
13
use yii\caching\TagDependency;
14
use yii\data\ActiveDataProvider;
15
use yii\db\Expression;
16
17
/**
18
 * This is the model class for table "{{%order}}".
19
 * Model fields:
20
 * @property integer $id
21
 * @property integer $user_id
22
 * @property integer $customer_id
23
 * @property integer $contragent_id
24
 * @property integer $manager_id
25
 * @property string $start_date
26
 * @property string $update_date
27
 * @property string $end_date
28
 * @property integer $cart_forming_time
29
 * @property integer $order_stage_id
30
 * @property integer $payment_type_id
31
 * @property integer $assigned_id
32
 * @property integer $tax_id
33
 * @property string $external_id
34
 * @property integer $items_count
35
 * @property double $total_price
36
 * @property double $total_payed
37
 * @property string $hash
38
 * @property bool $is_deleted
39
 * @property bool $temporary
40
 * @property bool $show_price_changed_notification
41
 * @property bool $in_cart
42
 * Relations:
43
 * @property \app\properties\AbstractModel $abstractModel
44
 * @property OrderItem[] $items
45
 * @property SpecialPriceObject[] $specialPriceObjects
46
 * @property ShippingOption $shippingOption
47
 * @property OrderStage $stage
48
 * @property PaymentType $paymentType
49
 * @property OrderTransaction[] $transactions
50
 * @property User $user
51
 * @property User $manager
52
 * @property float $fullPrice
53
 * @property Contragent $contragent
54
 * @property DiscountCode $code
55
 * @property Customer $customer
56
 * @property OrderDeliveryInformation $orderDeliveryInformation
57
 */
58
class Order extends \yii\db\ActiveRecord
59
{
60
    const IMMUTABLE_NONE = 0;
61
    const IMMUTABLE_USER = 1;
62
    const IMMUTABLE_MANAGER = 2;
63
    const IMMUTABLE_ASSIGNED = 4;
64
    const IMMUTABLE_ALL = 128;
65
    const ORDER_STATE_FINISH = 0;
66
    const ORDER_STATE_IN_PROCESS = 1;
67
68
    /**
69
     * @var Order $order
70
     */
71
    protected static $order;
72
    /** @var OrderStage $orderStage */
73
    protected $orderStage = null;
74
75
    /**
76
     * @inheritdoc
77
     */
78
    public function behaviors()
79
    {
80
        return [
81
            [
82
                'class' => HasProperties::className(),
83
            ],
84
            [
85
                'class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className(),
86
            ],
87
            [
88
                'class' => TimestampBehavior::className(),
89
                'createdAtAttribute' => 'start_date',
90
                'updatedAtAttribute' => 'update_date',
91
                'value' => new Expression('NOW()'),
92
            ],
93
        ];
94
    }
95
96
    /**
97
     * @inheritdoc
98
     */
99
    public static function tableName()
100
    {
101
        return '{{%order}}';
102
    }
103
104
    /**
105
     * @inheritdoc
106
     */
107
    public function rules()
108
    {
109
        return [
110
            [
111
                [
112
                    'user_id',
113
                    'customer_id',
114
                    'contragent_id',
115
                    'order_stage_id',
116
                    'total_price',
117
                    'payment_type_id',
118
                    'in_cart',
119
                ],
120
                'required'
121
            ],
122
            [
123
                [
124
                    'user_id',
125
                    'customer_id',
126
                    'contragent_id',
127
                    'order_stage_id',
128
                    'payment_type_id',
129
                    'assigned_id',
130
                    'tax_id'
131
                ],
132
                'integer'
133
            ],
134
            [['start_date', 'end_date', 'update_date'], 'safe'],
135
            [['total_price', 'items_count', 'total_payed'], 'number'],
136
            [['external_id'], 'string', 'max' => 38],
137
            [['is_deleted', 'temporary', 'show_price_changed_notification', 'in_cart'], 'boolean'],
138
            [['user_id', 'customer_id', 'contragent_id', 'in_cart'], 'default', 'value' => 0],
139
            [['temporary'], 'default', 'value' => 1],
140
        ];
141
    }
142
143
    /**
144
     * @inheritdoc
145
     */
146
    public function scenarios()
147
    {
148
        return [
149
            'default' => [
150
                'user_id',
151
                'cart_forming_time',
152
                'order_stage_id',
153
                'items_count',
154
                'total_price',
155
                'hash',
156
                'in_cart',
157
            ],
158
            'search' => [
159
                'id',
160
                'user_id',
161
                'manager_id',
162
                'start_date',
163
                'end_date',
164
                'order_stage_id',
165
                'payment_type_id',
166
                'items_count',
167
                'total_price',
168
                'hash',
169
            ],
170
            'shippingOption' => ['order_stage_id'],
171
            'paymentType' => ['payment_type_id', 'order_stage_id'],
172
            'changeManager' => ['manager_id'],
173
            'backend' => [
174
                'user_id',
175
                'customer_id',
176
                'contragent_id',
177
            ],
178
        ];
179
    }
180
181
    /**
182
     * @inheritdoc
183
     */
184
    public function attributeLabels()
185
    {
186
        return [
187
            'id' => Yii::t('app', 'ID'),
188
            'user_id' => Yii::t('app', 'User'),
189
            'customer_id' => Yii::t('app', 'Customer'),
190
            'contragent_id' => Yii::t('app', 'Contragent'),
191
            'manager_id' => Yii::t('app', 'Manager'),
192
            'start_date' => Yii::t('app', 'Start Date'),
193
            'update_date' => Yii::t('app', 'Update date'),
194
            'end_date' => Yii::t('app', 'End Date'),
195
            'cart_forming_time' => Yii::t('app', 'Cart Forming Time'),
196
            'order_stage_id' => Yii::t('app', 'Stage'),
197
            'payment_type_id' => Yii::t('app', 'Payment Type'),
198
            'assigned_id' => Yii::t('app', 'Assigned'),
199
            'tax_id' => Yii::t('app', 'Tax'),
200
            'external_id' => Yii::t('app', 'External ID'),
201
            'items_count' => Yii::t('app', 'Items Count'),
202
            'total_price' => Yii::t('app', 'Total Price'),
203
            'total_payed' => Yii::t('app', 'Total payed'),
204
            'hash' => Yii::t('app', 'Hash'),
205
            'is_deleted' => Yii::t('app', 'Is deleted'),
206
            'temporary' => Yii::t('app', 'Temporary'),
207
            'show_price_changed_notification' => Yii::t('app', 'Show price changed notification'),
208
            'in_cart' => Yii::t('app', 'In Cart'),
209
        ];
210
    }
211
212
    public function getItems()
213
    {
214
        return $this->hasMany(OrderItem::className(), ['order_id' => 'id']);
215
    }
216
217
    /**
218
     * @return OrderStage|null
0 ignored issues
show
Documentation introduced by
Should the return type not be \yii\db\ActiveQuery|OrderStage?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
219
     */
220
    public function getStage()
221
    {
222
        if (null === $this->orderStage) {
223
            $this->orderStage = $this->hasOne(OrderStage::className(), ['id' => 'order_stage_id']);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->hasOne(\app\modul...' => 'order_stage_id')) of type object<yii\db\ActiveQuery> is incompatible with the declared type object<app\modules\shop\models\OrderStage> of property $orderStage.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
224
        }
225
        return $this->orderStage;
226
    }
227
228
    public function getShippingOption()
0 ignored issues
show
Documentation introduced by
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 @return annotation as described here.

Loading history...
229
    {
230
        $orderDelivery = OrderDeliveryInformation::getByOrderId($this->id);
231
        return empty($orderDelivery) ? null : $orderDelivery->shippingOption;
232
    }
233
234
    public function getPaymentType()
235
    {
236
        return $this->hasOne(PaymentType::className(), ['id' => 'payment_type_id']);
237
    }
238
239
    public function getTransactions()
240
    {
241
        return $this->hasMany(OrderTransaction::className(), ['order_id' => 'id']);
242
    }
243
244
    public function getUser()
245
    {
246
        return $this->hasOne(User::className(), ['id' => 'user_id']);
247
    }
248
249
    public function getCode()
250
    {
251
        return $this->hasOne(OrderCode::className(), ['order_id'=>'id']);
252
    }
253
254
    /**
255
     * @return Customer|null
0 ignored issues
show
Documentation introduced by
Should the return type not be \yii\db\ActiveQuery?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
256
     */
257
    public function getCustomer()
258
    {
259
        return $this->hasOne(Customer::className(), ['id' => 'customer_id']);
260
    }
261
262
    public function getContragent()
263
    {
264
        return $this->hasOne(Contragent::className(), ['id' => 'contragent_id']);
265
    }
266
267
    public function getManager()
268
    {
269
        return $this->hasOne(User::className(), ['id' => 'manager_id']);
270
    }
271
272
    public function getSpecialPriceObjects()
273
    {
274
        return SpecialPriceObject::find()
275
            ->leftJoin(
276
                SpecialPriceList::tableName(),
277
                SpecialPriceList::tableName() . '.id =' . SpecialPriceObject::tableName() . '.special_price_list_id'
278
            )
279
            ->where(
280
                [
281
                    SpecialPriceObject::tableName() . '.object_model_id' => $this->id,
282
                    SpecialPriceList::tableName() . '.object_id' => $this->object->id
0 ignored issues
show
Bug introduced by
The property object does not seem to exist. Did you mean specialPriceObjects?

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...
283
                ]
284
            )
285
            ->all();
286
    }
287
288
    public function getFullPrice()
289
    {
290
        $fullPrice = $this->total_price;
291
        if (!is_null($this->shippingOption)) {
292
            $fullPrice += $this->shippingOption->cost;
293
        }
294
        return $fullPrice;
295
    }
296
297
    /**
298
     * @return OrderDeliveryInformation|null
0 ignored issues
show
Documentation introduced by
Should the return type not be \yii\db\ActiveQuery?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
299
     */
300
    public function getOrderDeliveryInformation()
301
    {
302
        return $this->hasOne(OrderDeliveryInformation::className(), ['order_id' => 'id']);
303
    }
304
305
    /**
306
     * Первое удаление в корзину, второе из БД
307
     *
308
     * @return bool
309
     */
310
    public function beforeDelete()
311
    {
312
        if (Yii::$app->getModule('shop')->deleteOrdersAbility === 0) {
313
            return false;
314
        }
315
        if (!parent::beforeDelete()) {
316
            return false;
317
        }
318
        if (0 === intval($this->is_deleted)) {
319
            $this->is_deleted = 1;
320
            $this->save();
321
            return false;
322
        }
323
        $customer = $this->getCustomer();
324
        if (0 === intval($customer->user_id)) {
325
            $customer->delete();
326
        }
327
328
        return true;
329
    }
330
331
    /**
332
     * Search tasks
333
     * @param $params
334
     * @return ActiveDataProvider
335
     */
336 View Code Duplication
    public function search($params)
337
    {
338
        /** @var $query \yii\db\ActiveQuery */
339
        $query = self::find();
340
341
        $dataProvider = new ActiveDataProvider(
342
            [
343
                'query' => $query,
344
                'pagination' => [
345
                    'pageSize' => 10,
346
                ],
347
            ]
348
        );
349
        if (!($this->load($params))) {
350
            return $dataProvider;
351
        }
352
        $query->andFilterWhere(['id' => $this->id]);
353
        $query->andFilterWhere(['is_deleted' => $this->is_deleted]);
354
        return $dataProvider;
355
    }
356
357
    /**
358
     * Create a new order.
359
     * @param bool $throwException Throw an exception if a order has not been saved
360
     * @param bool $assignToUser Assign to a current user
361
     * @return Order
0 ignored issues
show
Documentation introduced by
Should the return type not be Order|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
362
     * @throws Exception
363
     */
364
    public static function create($throwException = true, $assignToUser = true, $dummyObject = false)
365
    {
366
        TagDependency::invalidate(Yii::$app->cache, ['Session:' . Yii::$app->session->id]);
367
        $initialOrderStage = OrderStage::getInitialStage();
368
        if (is_null($initialOrderStage)) {
369
            throw new Exception('Initial order stage not found');
370
        }
371
        $model = new static;
372
        $model->loadDefaultValues(false);
373
        $model->user_id = !Yii::$app->user->isGuest && $assignToUser ? Yii::$app->user->id : 0;
374
        $model->order_stage_id = $initialOrderStage->id;
375
        $model->in_cart = 1;
376
        $model->customer_id = 0;
377
        $model->contragent_id = 0;
378
        mt_srand();
379
        $model->hash = md5(mt_rand() . uniqid());
380
        if (false === $dummyObject) {
381
            if (!$model->save()) {
382
                if ($throwException) {
383
                    throw new Exception('Cannot create a new order.');
384
                } else {
385
                    return null;
386
                }
387
            }
388
        }
389
        return $model;
390
    }
391
392
    /**
393
     * Get current order.
394
     * @param bool $create Create order if it does not exist
395
     * @return Order
0 ignored issues
show
Documentation introduced by
Should the return type not be Order|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
396
     * @throws Exception
397
     */
398
    public static function getOrder($create = false)
399
    {
400
        Yii::beginProfile("GetOrder");
401
        if (is_null(self::$order) && Yii::$app->session->has('orderId')) {
402
            self::$order = self::find()
0 ignored issues
show
Documentation Bug introduced by
It seems like self::find()->where(arra...get('orderId')))->one() can also be of type object<yii\db\ActiveRecord> or array. However, the property $order is declared as type object<app\modules\shop\models\Order>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
403
                ->where(['id' => Yii::$app->session->get('orderId')])
404
                ->one();
405
        }
406
        if (is_null(self::$order) && !Yii::$app->user->isGuest) {
407
            self::$order = self::find()
0 ignored issues
show
Documentation Bug introduced by
It seems like self::find()->where(arra...' => SORT_DESC))->one() can also be of type object<yii\db\ActiveRecord> or array. However, the property $order is declared as type object<app\modules\shop\models\Order>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
408
                ->where(['user_id' => Yii::$app->user->id, 'in_cart' => 1])
409
                ->orderBy(['start_date' => SORT_DESC, 'id' => SORT_DESC])
410
                ->one();
411
        }
412
        if ((is_null(self::$order) || is_null(self::$order->stage) || self::$order->in_cart == 0)
413
            && $create === true
414
        ) {
415
            $model = self::create();
416
            self::$order = $model;
417
            Yii::$app->session->set('orderId', $model->id);
418
419
            $sessionOrders = Yii::$app->session->get('orders', []);
420
            $sessionOrders[] = $model->id;
421
            Yii::$app->session->set('orders', $sessionOrders);
422
423
        }
424
        Yii::endProfile("GetOrder");
425
        return self::$order;
0 ignored issues
show
Bug Compatibility introduced by
The expression self::$order; of type null|yii\db\ActiveRecord|array adds the type array to the return on line 425 which is incompatible with the return type documented by app\modules\shop\models\Order::getOrder of type app\modules\shop\models\Order|null.
Loading history...
426
    }
427
428
    public static function clearStaticOrder()
429
    {
430
        self::$order = null;
431
    }
432
433
    /**
434
     * Calculate order total price and items count with all additional markups.
435
     * @param bool $callSave Call save method after calculating.
436
     * @param bool $deleteNotActiveProducts Delete Order Item if product is not active or is not exist.
437
     * @return bool
438
     */
439
    public function calculate($callSave = false, $deleteNotActiveProducts = true)
440
    {
441
        $itemsCount = 0;
442
        foreach ($this->items as $item) {
443
            if (null === OrderItem::findOne(['id' => $item->id])) {
444
                $item->delete();
445
                continue;
446
            }
447
            if ($deleteNotActiveProducts && (null === $item->product || $item->product->active == 0)) {
448
                $item->delete();
449
                continue;
450
            }
451
            if (Yii::$app->getModule('shop')->countChildrenProducts == 1) {
452
                $itemsCount += Yii::$app->getModule('shop')->countUniqueProductsOnly == 1 ? 1 : $item->quantity;
453
            } else {
454
                if ($item->parent_id == 0) {
455
                    $itemsCount += Yii::$app->getModule('shop')->countUniqueProductsOnly == 1 ? 1 : $item->quantity;
456
                }
457
            }
458
        }
459
460
        $event = new OrderCalculateEvent();
461
        $event->order = $this;
462
        $event->price = PriceHelper::getOrderPrice($this, SpecialPriceList::TYPE_CORE);
463
        EventTriggeringHelper::triggerSpecialEvent($event);
464
465
        $this->items_count = $itemsCount;
466
        $this->total_price = PriceHelper::getOrderPrice($this);
467
468
        $event->state = OrderCalculateEvent::AFTER_CALCULATE;
469
        EventTriggeringHelper::triggerSpecialEvent($event);
470
471
        TagDependency::invalidate(Yii::$app->cache, ['Session:' . Yii::$app->session->id]);
472
        return $callSave ? $this->save(true, ['items_count', 'total_price', 'total_price_with_shipping']) : true;
473
    }
474
475
    /**
476
     * @inheritdoc
477
     */
478
    public function beforeSave($insert)
479
    {
480
        $this->calculate();
481
        return parent::beforeSave($insert);
482
    }
483
484
    /**
485
     * @inheritdoc
486
     */
487
    public function afterSave($insert, $changedAttributes)
488
    {
489
        TagDependency::invalidate(Yii::$app->cache, ['Session:' . Yii::$app->session->id]);
490
        parent::afterSave($insert, $changedAttributes);
491
492
        if (!$insert && !empty($changedAttributes['user_id']) && 0 === intval($changedAttributes['user_id'])) {
493
            if (!empty($this->customer)) {
494
                $customer = $this->customer;
495
                $customer->user_id = 0 === intval($customer->user_id) ? $this->user_id : $customer->user_id;
496
                $customer->save();
497
            }
498
        }
499
    }
500
501
    public function afterDelete()
502
    {
503
        self::deleteOrderElements($this);
504
        return parent::afterDelete();
505
    }
506
507
    public static function deleteOrderElements(Order $order)
508
    {
509
        foreach ($order->items as $item) {
510
            $item->delete();
511
        }
512
        if ($order->code !== null) {
513
            $order->code->delete();
514
        }
515
        SpecialPriceObject::deleteAllByObject($order);
516
    }
517
518
    /**
519
     * @param integer|null $checkWith
520
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
521
     */
522
    public function getImmutability($checkWith = null)
523
    {
524
        $stage = $this->stage;
525
        $checkWith = intval($checkWith);
526
        $flag = intval($stage->immutable_by_user)
527
            | (intval($stage->immutable_by_manager) << 1)
528
            | (intval($stage->immutable_by_assigned) << 2);
529
        return $checkWith > 0 ? $checkWith === ($checkWith & $flag) : $flag;
530
    }
531
532
    /**
533
     * @return int
534
     */
535
    public function getOrderState()
536
    {
537
        $stage = $this->stage;
538
        return 1 === ($stage->immutable_by_user & $stage->immutable_by_manager & $stage->immutable_by_assigned)
539
            ? Order::ORDER_STATE_FINISH
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
540
            : Order::ORDER_STATE_IN_PROCESS;
0 ignored issues
show
Coding Style introduced by
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
541
    }
542
}
543