Completed
Push — master ( a8e426...cdcd92 )
by Simonas
62:46
created

Filter/Helper/SortAwareTrait.php (1 issue)

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 the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\FilterManagerBundle\Filter\Helper;
13
14
/**
15
 * This trait defines methods for choices sorting.
16
 */
17
trait SortAwareTrait
18
{
19
    use OptionsAwareTrait;
20
21
    /**
22
     * @var string $default
23
     * @return string
24
     */
25
    public function getSortType($default = '_count')
26
    {
27
        return $this->getOption('sort_type', $default);
28
    }
29
30
    /**
31
     * @var string $default
32
     * @return string
33
     */
34
    public function getSortOrder($default = 'asc')
35
    {
36
        return $this->getOption('sort_order', $default);
37
    }
38
39
    /**
40
     * @var array $default
41
     * @return array
42
     */
43
    public function getSortPriority($default = [])
44
    {
45
        return $this->getOption('sort_priority', $default);
0 ignored issues
show
$default is of type array, but the function expects a string|null.

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...
46
    }
47
}
48