Completed
Push — 4.0 ( 87d096...bcc1be )
by Kiyotaka
05:44 queued 11s
created

src/Eccube/Service/PurchaseFlow/ValidatorTrait.php (2 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.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\Service\PurchaseFlow;
15
16
use Eccube\Entity\ProductClass;
17
18
trait ValidatorTrait
19
{
20
    /**
21
     * @param ProductClass $ProductClass
22
     * @param $errorCode
23
     *
24
     * @throws InvalidItemException
25
     */
26 56
    protected function throwInvalidItemException($errorCode, ProductClass $ProductClass = null, $warning = false)
27
    {
28 56
        if ($ProductClass) {
29 29
            $productName = $ProductClass->getProduct()->getName();
30 29
            if ($ProductClass->hasClassCategory1()) {
31 29
                $productName .= ' - '.$ProductClass->getClassCategory1()->getName();
32
            }
33 29
            if ($ProductClass->hasClassCategory2()) {
34 17
                $productName .= ' - '.$ProductClass->getClassCategory2()->getName();
35
            }
36
37 29
            throw new InvalidItemException(trans($errorCode, ['%product%' => $productName]), null, $warning);
0 ignored issues
show
null is of type null, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
38
        }
39 27
        throw new InvalidItemException(trans($errorCode), null, $warning);
0 ignored issues
show
null is of type null, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40
    }
41
}
42