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 Sonata Project package. |
||
5 | * |
||
6 | * (c) Thomas Rabaix <[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 Sonata\DoctrinePHPCRAdminBundle\Filter; |
||
13 | |||
14 | use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; |
||
15 | use Sonata\CoreBundle\Form\Type\BooleanType; |
||
16 | use Sonata\DoctrinePHPCRAdminBundle\Filter\Filter as BaseFilter; |
||
17 | |||
18 | class BooleanFilter extends BaseFilter |
||
19 | { |
||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | public function filter(ProxyQueryInterface $proxyQuery, $alias, $field, $data) |
||
24 | { |
||
25 | if (!$data || !is_array($data) || !array_key_exists('type', $data) || !array_key_exists('value', $data)) { |
||
26 | return; |
||
27 | } |
||
28 | |||
29 | if (is_array($data['value']) || !in_array($data['value'], array(BooleanType::TYPE_NO, BooleanType::TYPE_YES))) { |
||
30 | return; |
||
31 | } |
||
32 | |||
33 | $where = $this->getWhere($proxyQuery); |
||
0 ignored issues
–
show
|
|||
34 | $where->eq()->field('a.'.$field)->literal($data['value'] == BooleanType::TYPE_YES ? true : false); |
||
35 | |||
36 | // filter is active as we have now modified the query |
||
37 | $this->active = true; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * {@inheritdoc} |
||
42 | */ |
||
43 | public function getDefaultOptions() |
||
44 | { |
||
45 | return array(); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritdoc} |
||
50 | */ |
||
51 | public function getRenderSettings() |
||
52 | { |
||
53 | return array('sonata_type_filter_default', array( |
||
54 | 'field_type' => $this->getFieldType(), |
||
55 | 'field_options' => $this->getFieldOptions(), |
||
56 | 'operator_type' => 'hidden', |
||
57 | 'operator_options' => array(), |
||
58 | 'label' => $this->getLabel(), |
||
59 | )); |
||
60 | } |
||
61 | } |
||
62 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.