Completed
Push — experimental/sf ( ebd3d7...b1938d )
by chihiro
112:14 queued 104:47
created

OrderController   A

Complexity

Total Complexity 36

Size/Duplication

Total Lines 485
Duplicated Lines 1.65 %

Coupling/Cohesion

Components 1
Dependencies 28

Test Coverage

Coverage 69.68%

Importance

Changes 0
Metric Value
dl 8
loc 485
rs 9.52
c 0
b 0
f 0
ccs 131
cts 188
cp 0.6968
wmc 36
lcom 1
cbo 28

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 23 1
C index() 0 124 10
A bulkDelete() 0 19 3
B exportOrder() 0 76 6
C bulkOrderStatus() 8 74 10
B updateTrackingNumber() 0 42 6

How to fix   Duplicated Code   

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:

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Controller\Admin\Order;
15
16
use Eccube\Common\Constant;
17
use Eccube\Controller\AbstractController;
18
use Eccube\Entity\Csv;
19
use Eccube\Entity\Master\CsvType;
20
use Eccube\Entity\OrderItem;
21
use Eccube\Event\EccubeEvents;
22
use Eccube\Event\EventArgs;
23
use Eccube\Form\Type\Admin\SearchOrderType;
24
use Eccube\Repository\CustomerRepository;
25
use Eccube\Repository\Master\OrderStatusRepository;
26
use Eccube\Repository\Master\PageMaxRepository;
27
use Eccube\Repository\Master\ProductStatusRepository;
28
use Eccube\Repository\Master\SexRepository;
29
use Eccube\Repository\OrderRepository;
30
use Eccube\Repository\PaymentRepository;
31
use Eccube\Service\CsvExportService;
32
use Eccube\Util\FormUtil;
33
use Knp\Component\Pager\PaginatorInterface;
34
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
35
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
36
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
37
use Symfony\Component\HttpFoundation\Response;
38
use Symfony\Component\HttpFoundation\Request;
39
use Symfony\Component\HttpFoundation\StreamedResponse;
40
use Eccube\Entity\Master\OrderStatus;
41
use Symfony\Component\HttpFoundation\RedirectResponse;
42
use Eccube\Entity\Order;
43
use Eccube\Entity\Shipping;
44
use Eccube\Service\PurchaseFlow\PurchaseContext;
45
use Eccube\Service\PurchaseFlow\PurchaseFlow;
46
use Eccube\Service\PurchaseFlow\PurchaseException;
47
use Symfony\Component\Validator\Constraints as Assert;
48
use Symfony\Component\Validator\Validator\ValidatorInterface;
49
50
class OrderController extends AbstractController
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
51
{
52
    /**
53
     * @var PurchaseFlow
54
     */
55
    protected $purchaseFlow;
56
57
    /**
58
     * @var CsvExportService
59
     */
60
    protected $csvExportService;
61
62
    /**
63
     * @var CustomerRepository
64
     */
65
    protected $customerRepository;
66
67
    /**
68
     * @var PaymentRepository
69
     */
70
    protected $paymentRepository;
71
72
    /**
73
     * @var SexRepository
74
     */
75
    protected $sexRepository;
76
77
    /**
78
     * @var OrderStatusRepository
79
     */
80
    protected $orderStatusRepository;
81
82
    /**
83
     * @var PageMaxRepository
84
     */
85
    protected $pageMaxRepository;
86
87
    /**
88
     * @var ProductStatusRepository
89
     */
90
    protected $productStatusRepository;
91
92
    /**
93
     * @var OrderRepository
94
     */
95
    protected $orderRepository;
96
97
    /**
98
     * @var ValidatorInterface
99
     */
100
    protected $validator;
101
102
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$validator" missing
Loading history...
103
     * OrderController constructor.
104
     *
105
     * @param PurchaseFlow $orderPurchaseFlow
0 ignored issues
show
introduced by
Expected 12 spaces after parameter type; 1 found
Loading history...
106
     * @param CsvExportService $csvExportService
0 ignored issues
show
introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
107
     * @param CustomerRepository $customerRepository
0 ignored issues
show
introduced by
Expected 6 spaces after parameter type; 1 found
Loading history...
108
     * @param PaymentRepository $paymentRepository
0 ignored issues
show
introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
109
     * @param SexRepository $sexRepository
0 ignored issues
show
introduced by
Expected 11 spaces after parameter type; 1 found
Loading history...
110
     * @param OrderStatusRepository $orderStatusRepository
0 ignored issues
show
introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
111
     * @param PageMaxRepository $pageMaxRepository
0 ignored issues
show
introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
112
     * @param ProductStatusRepository $productStatusRepository
113
     * @param OrderRepository $orderRepository
0 ignored issues
show
introduced by
Expected 9 spaces after parameter type; 1 found
Loading history...
114
     */
115 14
    public function __construct(
116
        PurchaseFlow $orderPurchaseFlow,
117
        CsvExportService $csvExportService,
118
        CustomerRepository $customerRepository,
119
        PaymentRepository $paymentRepository,
120
        SexRepository $sexRepository,
121
        OrderStatusRepository $orderStatusRepository,
122
        PageMaxRepository $pageMaxRepository,
123
        ProductStatusRepository $productStatusRepository,
124
        OrderRepository $orderRepository,
125
        ValidatorInterface $validator
126
    ) {
127 14
        $this->purchaseFlow = $orderPurchaseFlow;
128 14
        $this->csvExportService = $csvExportService;
129 14
        $this->customerRepository = $customerRepository;
130 14
        $this->paymentRepository = $paymentRepository;
131 14
        $this->sexRepository = $sexRepository;
132 14
        $this->orderStatusRepository = $orderStatusRepository;
133 14
        $this->pageMaxRepository = $pageMaxRepository;
134 14
        $this->productStatusRepository = $productStatusRepository;
135 14
        $this->orderRepository = $orderRepository;
136 14
        $this->validator = $validator;
137
    }
138
139
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$request" missing
Loading history...
introduced by
Doc comment for parameter "$page_no" missing
Loading history...
introduced by
Doc comment for parameter "$paginator" missing
Loading history...
140
     * 受注一覧画面.
141
     *
142
     * - 検索条件, ページ番号, 表示件数はセッションに保持されます.
143
     * - クエリパラメータでresume=1が指定された場合、検索条件, ページ番号, 表示件数をセッションから復旧します.
144
     * - 各データの, セッションに保持するアクションは以下の通りです.
145
     *   - 検索ボタン押下時
146
     *      - 検索条件をセッションに保存します
147
     *      - ページ番号は1で初期化し、セッションに保存します。
148
     *   - 表示件数変更時
149
     *      - クエリパラメータpage_countをセッションに保存します。
150
     *      - ただし, mtb_page_maxと一致しない場合, eccube_default_page_countが保存されます.
151
     *   - ページング時
152
     *      - URLパラメータpage_noをセッションに保存します.
153
     *   - 初期表示
154
     *      - 検索条件は空配列, ページ番号は1で初期化し, セッションに保存します.
155
     *
156
     * @Route("/%eccube_admin_route%/order", name="admin_order")
157
     * @Route("/%eccube_admin_route%/order/page/{page_no}", requirements={"page_no" = "\d+"}, name="admin_order_page")
158
     * @Template("@admin/Order/index.twig")
159
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
160 8
    public function index(Request $request, $page_no = null, PaginatorInterface $paginator)
0 ignored issues
show
Coding Style introduced by
Parameters which have default values should be placed at the end.

If you place a parameter with a default value before a parameter with a default value, the default value of the first parameter will never be used as it will always need to be passed anyway:

// $a must always be passed; it's default value is never used.
function someFunction($a = 5, $b) { }
Loading history...
161
    {
162 8
        $builder = $this->formFactory
163 8
            ->createBuilder(SearchOrderType::class);
164
165 8
        $event = new EventArgs(
166
            [
167 8
                'builder' => $builder,
168
            ],
169 8
            $request
170
        );
171 8
        $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_INITIALIZE, $event);
172
173 8
        $searchForm = $builder->getForm();
174
175
        /**
176
         * ページの表示件数は, 以下の順に優先される.
177
         * - リクエストパラメータ
178
         * - セッション
179
         * - デフォルト値
180
         * また, セッションに保存する際は mtb_page_maxと照合し, 一致した場合のみ保存する.
181
         **/
182 8
        $page_count = $this->session->get('eccube.admin.order.search.page_count',
183 8
                $this->eccubeConfig->get('eccube_default_page_count'));
184
185 8
        $page_count_param = (int) $request->get('page_count');
186 8
        $pageMaxis = $this->pageMaxRepository->findAll();
187
188 8
        if ($page_count_param) {
189 1
            foreach ($pageMaxis as $pageMax) {
190 1
                if ($page_count_param == $pageMax->getName()) {
191
                    $page_count = $pageMax->getName();
192
                    $this->session->set('eccube.admin.order.search.page_count', $page_count);
193 1
                    break;
194
                }
195
            }
196
        }
197
198 8
        if ('POST' === $request->getMethod()) {
199 6
            $searchForm->handleRequest($request);
200
201 6
            if ($searchForm->isValid()) {
202
                /**
203
                 * 検索が実行された場合は, セッションに検索条件を保存する.
204
                 * ページ番号は最初のページ番号に初期化する.
205
                 */
206 5
                $page_no = 1;
207 5
                $searchData = $searchForm->getData();
208
209
                // 検索条件, ページ番号をセッションに保持.
210 5
                $this->session->set('eccube.admin.order.search', FormUtil::getViewData($searchForm));
211 5
                $this->session->set('eccube.admin.order.search.page_no', $page_no);
212
            } else {
213
                // 検索エラーの際は, 詳細検索枠を開いてエラー表示する.
214
                return [
215 6
                    'searchForm' => $searchForm->createView(),
216
                    'pagination' => [],
217 1
                    'pageMaxis' => $pageMaxis,
218 1
                    'page_no' => $page_no,
219 1
                    'page_count' => $page_count,
220
                    'has_errors' => true,
221
                ];
222
            }
223
        } else {
224 3
            if (null !== $page_no || $request->get('resume')) {
225
                /*
226
                 * ページ送りの場合または、他画面から戻ってきた場合は, セッションから検索条件を復旧する.
227
                 */
228 1
                if ($page_no) {
229
                    // ページ送りで遷移した場合.
230 1
                    $this->session->set('eccube.admin.order.search.page_no', (int) $page_no);
231
                } else {
232
                    // 他画面から遷移した場合.
233
                    $page_no = $this->session->get('eccube.admin.order.search.page_no', 1);
234
                }
235 1
                $viewData = $this->session->get('eccube.admin.order.search', []);
236 1
                $searchData = FormUtil::submitAndGetData($searchForm, $viewData);
237
            } else {
238
                /**
239
                 * 初期表示の場合.
240
                 */
241 2
                $page_no = 1;
242 2
                $viewData = [];
243
244 2
                if ($statusId = (int) $request->get('order_status_id')) {
245
                    $viewData = ['status' => $statusId];
246
                }
247
248 2
                $searchData = FormUtil::submitAndGetData($searchForm, $viewData);
249
250
                // セッション中の検索条件, ページ番号を初期化.
251 2
                $this->session->set('eccube.admin.order.search', $viewData);
252 2
                $this->session->set('eccube.admin.order.search.page_no', $page_no);
253
            }
254
        }
255
256 8
        $qb = $this->orderRepository->getQueryBuilderBySearchDataForAdmin($searchData);
257
258 8
        $event = new EventArgs(
259
            [
260 8
                'qb' => $qb,
261 8
                'searchData' => $searchData,
262
            ],
263 8
            $request
264
        );
265
266 8
        $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_ORDER_INDEX_SEARCH, $event);
267
268 8
        $pagination = $paginator->paginate(
269 8
            $qb,
270 8
            $page_no,
271 8
            $page_count
272
        );
273
274
        return [
275 8
            'searchForm' => $searchForm->createView(),
276 8
            'pagination' => $pagination,
277 8
            'pageMaxis' => $pageMaxis,
278 8
            'page_no' => $page_no,
279 8
            'page_count' => $page_count,
280
            'has_errors' => false,
281 8
            'OrderStatuses' => $this->orderStatusRepository->findBy([], ['sort_no' => 'ASC']),
282
        ];
283
    }
284
285
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$request" missing
Loading history...
286
     * @Method("POST")
287
     * @Route("/%eccube_admin_route%/order/bulk_delete", name="admin_order_bulk_delete")
288
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
289 1
    public function bulkDelete(Request $request)
290
    {
291 1
        $this->isTokenValid();
292 1
        $ids = $request->get('ids');
293 1
        foreach ($ids as $order_id) {
294 1
            $Order = $this->orderRepository
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $Order is correct as $this->orderRepository->find($order_id) (which targets Doctrine\ORM\EntityRepository::find()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

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.

Loading history...
295 1
                ->find($order_id);
296 1
            if ($Order) {
297 1
                $this->entityManager->remove($Order);
298 1
                log_info('受注削除', [$Order->getId()]);
299
            }
300
        }
301
302 1
        $this->entityManager->flush();
303
304 1
        $this->addSuccess('admin.order.delete.complete', 'admin');
305
306 1
        return $this->redirect($this->generateUrl('admin_order', ['resume' => Constant::ENABLED]));
307
    }
308
309
    /**
310
     * 受注CSVの出力.
311
     *
312
     * @Route("/%eccube_admin_route%/order/export/order", name="admin_order_export_order")
313
     *
314
     * @param Request $request
315
     *
316
     * @return StreamedResponse
317
     */
318 1
    public function exportOrder(Request $request)
319
    {
320
        // タイムアウトを無効にする.
321 1
        set_time_limit(0);
322
323
        // sql loggerを無効にする.
324 1
        $em = $this->entityManager;
325 1
        $em->getConfiguration()->setSQLLogger(null);
326
327 1
        $response = new StreamedResponse();
328 1
        $response->setCallback(function () use ($request) {
329
            // CSV種別を元に初期化.
330 1
            $this->csvExportService->initCsvType(CsvType::CSV_TYPE_ORDER);
331
332
            // ヘッダ行の出力.
333
            $this->csvExportService->exportHeader();
334
335
            // 受注データ検索用のクエリビルダを取得.
336
            $qb = $this->csvExportService
337
                ->getOrderQueryBuilder($request);
338
339
            // データ行の出力.
340
            $this->csvExportService->setExportQueryBuilder($qb);
341
            $this->csvExportService->exportData(function ($entity, $csvService) use ($request) {
342
                $Csvs = $csvService->getCsvs();
343
344
                $Order = $entity;
345
                $OrderItems = $Order->getOrderItems();
346
347
                foreach ($OrderItems as $OrderItem) {
348
                    $ExportCsvRow = new \Eccube\Entity\ExportCsvRow();
349
350
                    // CSV出力項目と合致するデータを取得.
351
                    foreach ($Csvs as $Csv) {
352
                        // 受注データを検索.
353
                        $ExportCsvRow->setData($csvService->getData($Csv, $Order));
354
                        if ($ExportCsvRow->isDataNull()) {
355
                            // 受注データにない場合は, 受注明細を検索.
356
                            $ExportCsvRow->setData($csvService->getData($Csv, $OrderItem));
357
                        }
358
                        if ($ExportCsvRow->isDataNull() && $Shipping = $OrderItem->getShipping()) {
359
                            // 受注明細データにない場合は, 出荷を検索.
360
                            $ExportCsvRow->setData($csvService->getData($Csv, $Shipping));
361
                        }
362
363
                        $event = new EventArgs(
364
                            [
365
                                'csvService' => $csvService,
366
                                'Csv' => $Csv,
367
                                'OrderItem' => $OrderItem,
368
                                'ExportCsvRow' => $ExportCsvRow,
369
                            ],
370
                            $request
371
                        );
372
                        $this->eventDispatcher->dispatch(EccubeEvents::ADMIN_ORDER_CSV_EXPORT_ORDER, $event);
373
374
                        $ExportCsvRow->pushData();
375
                    }
376
377
                    //$row[] = number_format(memory_get_usage(true));
378
                    // 出力.
379
                    $csvService->fputcsv($ExportCsvRow->getRow());
380
                }
381
            });
382 1
        });
383
384 1
        $now = new \DateTime();
385 1
        $filename = 'order_'.$now->format('YmdHis').'.csv';
386 1
        $response->headers->set('Content-Type', 'application/octet-stream');
387 1
        $response->headers->set('Content-Disposition', 'attachment; filename='.$filename);
388 1
        $response->send();
389
390
        log_info('受注CSV出力ファイル名', [$filename]);
391
392
        return $response;
393
    }
394
395
    /**
396
     * Bulk action to order status
397
     *
398
     * @Method("POST")
399
     * @Route("/%eccube_admin_route%/order/bulk/order-status/{id}", requirements={"id" = "\d+"}, name="admin_order_bulk_order_status")
400
     *
401
     * @param Request $request
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
402
     * @param OrderStatus $OrderStatus
403
     *
404
     * @return RedirectResponse
405
     */
406 2
    public function bulkOrderStatus(Request $request, OrderStatus $OrderStatus)
407
    {
408 2
        $this->isTokenValid();
409
410
        /** @var Order[] $Orders */
411 2
        $Orders = $this->orderRepository->findBy(['id' => $request->get('ids')]);
412
413 2
        $count = 0;
414 2
        foreach ($Orders as $Order) {
415
            try {
416
                // TODO: should support event for plugin customize
417
                // 編集前の受注情報を保持
418 2
                $OriginOrder = clone $Order;
419
420 2
                $Order->setOrderStatus($OrderStatus);
421
422 2
                $purchaseContext = new PurchaseContext($OriginOrder, $OriginOrder->getCustomer());
423
424 2
                $flowResult = $this->purchaseFlow->validate($Order, $purchaseContext);
425 2
                if ($flowResult->hasWarning()) {
426
                    foreach ($flowResult->getWarning() as $warning) {
427
                        $msg = $this->translator->trans('admin.order.index.bulk_warning', [
428
                          '%orderId%' => $Order->getId(),
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 28 spaces, but found 26.
Loading history...
429
                          '%message%' => $warning->getMessage(),
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 28 spaces, but found 26.
Loading history...
430
                        ]);
431
                        $this->addWarning($msg, 'admin');
432
                    }
433
                }
434
435 2
                if ($flowResult->hasError()) {
436
                    foreach ($flowResult->getErrors() as $error) {
437
                        $msg = $this->translator->trans('admin.order.index.bulk_error', [
438
                          '%orderId%' => $Order->getId(),
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 28 spaces, but found 26.
Loading history...
439
                          '%message%' => $error->getMessage(),
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 28 spaces, but found 26.
Loading history...
440
                        ]);
441
                        $this->addError($msg, 'admin');
442
                    }
443
                    continue;
444
                }
445
446
                try {
447 2
                    $this->purchaseFlow->commit($Order, $purchaseContext);
448
                } catch (PurchaseException $e) {
449
                    $msg = $this->translator->trans('admin.order.index.bulk_error', [
450
                      '%orderId%' => $Order->getId(),
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 24 spaces, but found 22.
Loading history...
451
                      '%message%' => $e->getMessage(),
0 ignored issues
show
Coding Style introduced by
This line of the multi-line function call does not seem to be indented correctly. Expected 24 spaces, but found 22.
Loading history...
452
                    ]);
453
                    $this->addError($msg, 'admin');
454
                    continue;
455
                }
456
457 2
                $this->orderRepository->save($Order);
458
459 2
                $count++;
460
            } catch (\Exception $e) {
461 2
                $this->addError('#'.$Order->getId().': '.$e->getMessage(), 'admin');
462
            }
463
        }
464
        try {
465 2 View Code Duplication
            if ($count) {
466 2
                $this->entityManager->flush();
467 2
                $msg = $this->translator->trans('admin.order.index.bulk_order_status_success_count', [
468 2
                    '%count%' => $count,
469 2
                    '%status%' => $OrderStatus->getName(),
470
                ]);
471 2
                $this->addSuccess($msg, 'admin');
472
            }
473
        } catch (\Exception $e) {
474
            log_error('Bulk order status error', [$e]);
475
            $this->addError('admin.flash.register_failed', 'admin');
476
        }
477
478 2
        return $this->redirectToRoute('admin_order', ['resume' => Constant::ENABLED]);
479
    }
480
481
    /**
482
     * Update to Tracking number.
483
     *
484
     * @Method("PUT")
485
     * @Route("/%eccube_admin_route%/shipping/{id}/tracking_number", requirements={"id" = "\d+"}, name="admin_shipping_update_tracking_number")
486
     *
487
     * @param Request $request
0 ignored issues
show
introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
488
     * @param Shipping $shipping
489
     *
490
     * @return Response
491
     */
492 2
    public function updateTrackingNumber(Request $request, Shipping $shipping)
493
    {
494 2
        if (!($request->isXmlHttpRequest() && $this->isTokenValid())) {
495
            return $this->json(['status' => 'NG'], 400);
496
        }
497
498 2
        $trackingNumber = mb_convert_kana($request->get('tracking_number'), 'a', 'utf-8');
499
        /** @var \Symfony\Component\Validator\ConstraintViolationListInterface $errors */
500 2
        $errors = $this->validator->validate(
501 2
            $trackingNumber,
502
            [
503 2
                new Assert\Length(['max' => $this->eccubeConfig['eccube_stext_len']]),
504 2
                new Assert\Regex(
505 2
                    ['pattern' => '/^[0-9a-zA-Z-]+$/u', 'message' => trans('form.type.admin.nottrackingnumberstyle')]
506
                ),
507
            ]
508
        );
509
510 2
        if ($errors->count() != 0) {
511 1
            log_info('送り状番号入力チェックエラー');
512 1
            $messages = [];
513
            /** @var \Symfony\Component\Validator\ConstraintViolationInterface $error */
514 1
            foreach ($errors as $error) {
515 1
                $messages[] = $error->getMessage();
516
            }
517
518 1
            return $this->json(['status' => 'NG', 'messages' => $messages], 400);
519
        }
520
521
        try {
522 1
            $shipping->setTrackingNumber($trackingNumber);
523 1
            $this->entityManager->flush($shipping);
0 ignored issues
show
Unused Code introduced by
The call to EntityManagerInterface::flush() has too many arguments starting with $shipping.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
524 1
            log_info('送り状番号変更処理完了', [$shipping->getId()]);
525 1
            $message = ['status' => 'OK', 'shipping_id' => $shipping->getId(), 'tracking_number' => $trackingNumber];
526
527 1
            return $this->json($message);
528
        } catch (\Exception $e) {
529
            log_error('予期しないエラー', [$e->getMessage()]);
530
531
            return $this->json(['status' => 'NG'], 500);
532
        }
533
    }
534
}
535