1 | <?php |
||
21 | abstract class WidgetBase extends PluginBase implements WidgetInterface, ContainerFactoryPluginInterface { |
||
22 | |||
23 | /** |
||
24 | * Plugin id. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * Plugin uuid. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $uuid; |
||
36 | /** |
||
37 | * Plugin label. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $label; |
||
42 | |||
43 | /** |
||
44 | * Plugin weight. |
||
45 | * |
||
46 | * @var int |
||
47 | */ |
||
48 | protected $weight; |
||
49 | |||
50 | /** |
||
51 | * Event dispatcher service. |
||
52 | * |
||
53 | * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface |
||
54 | */ |
||
55 | protected $eventDispatcher; |
||
56 | |||
57 | /** |
||
58 | * Entity manager service. |
||
59 | * |
||
60 | * @var \Drupal\Core\Entity\EntityManagerInterface |
||
61 | */ |
||
62 | protected $entityManager; |
||
63 | |||
64 | /** |
||
65 | * Constructs widget plugin. |
||
66 | * |
||
67 | * @param array $configuration |
||
68 | * A configuration array containing information about the plugin instance. |
||
69 | * @param string $plugin_id |
||
70 | * The plugin_id for the plugin instance. |
||
71 | * @param mixed $plugin_definition |
||
72 | * The plugin implementation definition. |
||
73 | * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher |
||
74 | * Event dispatcher service. |
||
75 | */ |
||
76 | public function __construct(array $configuration, $plugin_id, $plugin_definition, EventDispatcherInterface $event_dispatcher, EntityManagerInterface $entity_manager) { |
||
82 | |||
83 | /** |
||
84 | * {@inheritdoc} |
||
85 | */ |
||
86 | public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | public function defaultConfiguration() { |
||
102 | |||
103 | /** |
||
104 | * {@inheritdoc} |
||
105 | */ |
||
106 | public function getConfiguration() { |
||
115 | |||
116 | /** |
||
117 | * {@inheritdoc} |
||
118 | */ |
||
119 | public function setConfiguration(array $configuration) { |
||
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | public function calculateDependencies() { |
||
141 | |||
142 | /** |
||
143 | * {@inheritdoc} |
||
144 | */ |
||
145 | public function id() { |
||
148 | |||
149 | /** |
||
150 | * {@inheritdoc} |
||
151 | */ |
||
152 | public function uuid() { |
||
155 | |||
156 | /** |
||
157 | * {@inheritdoc} |
||
158 | */ |
||
159 | public function label() { |
||
162 | |||
163 | /** |
||
164 | * {@inheritdoc} |
||
165 | */ |
||
166 | public function getWeight() { |
||
169 | |||
170 | /** |
||
171 | * {@inheritdoc} |
||
172 | */ |
||
173 | public function setWeight($weight) { |
||
177 | |||
178 | /** |
||
179 | * {@inheritdoc} |
||
180 | */ |
||
181 | public function validate(array &$form, FormStateInterface $form_state) {} |
||
182 | |||
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | public function runWidgetValidators(array $entities, $validators = []) { |
||
197 | |||
198 | /** |
||
199 | * {@inheritdoc} |
||
200 | */ |
||
201 | public function submit(array &$element, array &$form, FormStateInterface $form_state) {} |
||
202 | |||
203 | /** |
||
204 | * Dispatches event that informs all subscribers about new selected entities. |
||
205 | * |
||
206 | * @param array $entities |
||
207 | * Array of entities. |
||
208 | */ |
||
209 | protected function selectEntities(array $entities, FormStateInterface $form_state) { |
||
221 | } |
||
222 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.