Completed
Push — master ( eb83f4...bb238e )
by Maximilian
14s
created

src/Form/Type/ChoiceFieldMaskType.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 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\Form\Type;
13
14
use Symfony\Component\Form\AbstractType;
15
use Symfony\Component\Form\FormInterface;
16
use Symfony\Component\Form\FormView;
17
use Symfony\Component\OptionsResolver\OptionsResolver;
18
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
19
20
class ChoiceFieldMaskType extends AbstractType
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25
    public function buildView(FormView $view, FormInterface $form, array $options)
26
    {
27
        $allFieldNames = array();
28
        foreach ($options['map'] as $value => $fieldNames) {
29
            foreach ($fieldNames as $fieldName) {
30
                $allFieldNames[$fieldName] = $fieldName;
31
            }
32
        }
33
        $allFieldNames = array_values($allFieldNames);
34
35
        $view->vars['all_fields'] = $allFieldNames;
36
        $view->vars['map'] = $options['map'];
37
        parent::buildView($view, $form, $options);
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     *
43
     * @todo Remove when Symfony <2.8 is no longer supported
44
     */
45
    public function setDefaultOptions(OptionsResolverInterface $resolver)
46
    {
47
        $this->configureOptions($resolver);
0 ignored issues
show
$resolver is of type object<Symfony\Component...tionsResolverInterface>, but the function expects a object<Symfony\Component...solver\OptionsResolver>.

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...
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function configureOptions(OptionsResolver $resolver)
54
    {
55
        $resolver->setDefaults(array(
56
            'map' => array(),
57
        ));
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getParent()
64
    {
65
        return 'choice';
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     *
71
     * @todo Remove when Symfony <2.8 is no longer supported
72
     */
73
    public function getName()
74
    {
75
        return $this->getBlockPrefix();
76
    }
77
78
    /**
79
     * {@inheritdoc}
80
     */
81
    public function getBlockPrefix()
82
    {
83
        return 'choice_field_mask';
84
    }
85
}
86