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\Form\Type; |
||
15 | |||
16 | use Eccube\Common\EccubeConfig; |
||
17 | use Eccube\Form\Type\Master\PrefType; |
||
18 | use Symfony\Component\Form\AbstractType; |
||
19 | use Symfony\Component\Form\Extension\Core\Type\TextType; |
||
20 | use Symfony\Component\Form\FormBuilderInterface; |
||
21 | use Symfony\Component\Form\FormInterface; |
||
22 | use Symfony\Component\Form\FormView; |
||
23 | use Symfony\Component\OptionsResolver\OptionsResolver; |
||
24 | use Symfony\Component\Validator\Constraints as Assert; |
||
25 | |||
26 | class AddressType extends AbstractType |
||
27 | { |
||
28 | /** |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $config; |
||
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | * |
||
36 | * AddressType constructor. |
||
37 | * |
||
38 | * @param EccubeConfig $eccubeConfig |
||
39 | */ |
||
40 | public function __construct(EccubeConfig $eccubeConfig) |
||
41 | { |
||
42 | $this->config = $eccubeConfig; |
||
0 ignored issues
–
show
|
|||
43 | 151 | } |
|
44 | |||
45 | 151 | /** |
|
46 | * {@inheritdoc} |
||
47 | */ |
||
48 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
49 | { |
||
50 | $options['pref_options']['required'] = $options['required']; |
||
51 | 151 | $options['addr01_options']['required'] = $options['required']; |
|
52 | $options['addr02_options']['required'] = $options['required']; |
||
53 | 151 | ||
54 | 151 | // required の場合は NotBlank も追加する |
|
55 | 151 | if ($options['required']) { |
|
56 | $options['pref_options']['constraints'] = array_merge([ |
||
57 | new Assert\NotBlank([]), |
||
58 | 151 | ], $options['pref_options']['constraints']); |
|
59 | 111 | ||
60 | 111 | $options['addr01_options']['constraints'] = array_merge([ |
|
61 | 111 | new Assert\NotBlank([]), |
|
62 | ], $options['addr01_options']['constraints']); |
||
63 | 111 | ||
64 | 111 | $options['addr02_options']['constraints'] = array_merge([ |
|
65 | 111 | new Assert\NotBlank([]), |
|
66 | ], $options['addr02_options']['constraints']); |
||
67 | 111 | } |
|
68 | 111 | ||
69 | 111 | View Code Duplication | if (!isset($options['options']['error_bubbling'])) { |
70 | $options['options']['error_bubbling'] = $options['error_bubbling']; |
||
71 | } |
||
72 | 151 | ||
73 | 151 | $builder |
|
74 | ->add($options['pref_name'], PrefType::class, array_merge_recursive($options['options'], $options['pref_options'])) |
||
75 | ->add($options['addr01_name'], TextType::class, array_merge_recursive($options['options'], $options['addr01_options'])) |
||
76 | ->add($options['addr02_name'], TextType::class, array_merge_recursive($options['options'], $options['addr02_options'])) |
||
77 | 151 | ; |
|
78 | 151 | ||
79 | 151 | $builder->setAttribute('pref_name', $options['pref_name']); |
|
80 | $builder->setAttribute('addr01_name', $options['addr01_name']); |
||
81 | $builder->setAttribute('addr02_name', $options['addr02_name']); |
||
82 | 151 | } |
|
83 | 151 | ||
84 | 151 | /** |
|
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public function buildView(FormView $view, FormInterface $form, array $options) |
||
88 | { |
||
89 | $builder = $form->getConfig(); |
||
90 | 23 | $view->vars['pref_name'] = $builder->getAttribute('pref_name'); |
|
91 | $view->vars['addr01_name'] = $builder->getAttribute('addr01_name'); |
||
92 | 23 | $view->vars['addr02_name'] = $builder->getAttribute('addr02_name'); |
|
93 | 23 | } |
|
94 | 23 | ||
95 | 23 | /** |
|
96 | * {@inheritdoc} |
||
97 | */ |
||
98 | public function configureOptions(OptionsResolver $resolver) |
||
99 | { |
||
100 | $resolver->setDefaults([ |
||
101 | 151 | 'options' => [], |
|
102 | 'pref_options' => ['constraints' => [], 'attr' => ['class' => 'p-region-id']], |
||
103 | 151 | 'addr01_options' => [ |
|
104 | 151 | 'constraints' => [ |
|
105 | 151 | new Assert\Length(['max' => $this->config['eccube_address1_len']]), |
|
106 | ], |
||
107 | 'attr' => [ |
||
108 | 'class' => 'p-locality p-street-address', |
||
109 | 151 | 'placeholder' => 'common.address_sample_01', |
|
110 | ], |
||
111 | ], |
||
112 | 'addr02_options' => [ |
||
113 | 'constraints' => [ |
||
114 | new Assert\Length(['max' => $this->config['eccube_address2_len']]), |
||
115 | 151 | ], |
|
116 | 'attr' => [ |
||
117 | 'class' => 'p-extended-address', |
||
118 | 'placeholder' => 'common.address_sample_02', |
||
119 | 151 | ], |
|
120 | 151 | ], |
|
121 | 151 | 'pref_name' => 'pref', |
|
122 | 'addr01_name' => 'addr01', |
||
123 | 'addr02_name' => 'addr02', |
||
124 | 'error_bubbling' => false, |
||
125 | 'inherit_data' => true, |
||
126 | 'trim' => true, |
||
127 | ]); |
||
128 | 23 | } |
|
129 | |||
130 | 23 | public function getBlockPrefix() |
|
131 | { |
||
132 | return 'address'; |
||
133 | } |
||
134 | } |
||
135 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..