Completed
Push — master ( f3ba17...48df0d )
by Simonas
29:24 queued 19:17
created

src/SearchEndpoint/FilterEndpoint.php (2 issues)

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\ElasticsearchDSL\SearchEndpoint;
13
14
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
15
16
/**
17
 * Search filter dsl endpoint.
18
 */
19 View Code Duplication
class FilterEndpoint extends QueryEndpoint
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * Endpoint name
23
     */
24
    const NAME = 'filter';
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
30
    {
31
        if (!$this->getBool()) {
32
            return null;
33
        }
34
35
        $this->addReference('filter_query', $this->getBool());
0 ignored issues
show
$this->getBool() is of type object<ONGR\ElasticsearchDSL\Query\BoolQuery>, but the function expects a array|string|object<stdClass>.

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...
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function getOrder()
42
    {
43
        return 1;
44
    }
45
}
46