Conditions | 1 |
Paths | 1 |
Total Lines | 153 |
Code Lines | 96 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
25 | public function getContainerDefinition() { |
||
26 | $parameters = array(); |
||
27 | $parameters['service_container.static_event_listeners'] = array(); |
||
28 | $parameters['service_container.plugin_managers'] = array(); |
||
29 | $parameters['service_container.plugin_manager_types'] = array( |
||
30 | 'ctools' => '\Drupal\service_container\Plugin\Discovery\CToolsPluginDiscovery', |
||
31 | ); |
||
32 | |||
33 | $services = array(); |
||
34 | |||
35 | $services['drupal7'] = array( |
||
36 | 'class' => 'Drupal\service_container\Legacy\Drupal7', |
||
37 | ); |
||
38 | |||
39 | $services['service_container'] = array( |
||
40 | 'class' => '\Drupal\service_container\DependencyInjection\Container', |
||
41 | ); |
||
42 | |||
43 | $services['module_handler'] = array( |
||
44 | 'class' => '\Drupal\service_container\Extension\ModuleHandler', |
||
45 | 'arguments' => array(DRUPAL_ROOT, '@drupal7'), |
||
46 | ); |
||
47 | |||
48 | $services['module_installer'] = array( |
||
49 | 'class' => '\Drupal\service_container\Extension\ModuleInstaller', |
||
50 | 'arguments' => array('@drupal7'), |
||
51 | ); |
||
52 | |||
53 | $services['database'] = array( |
||
54 | 'class' => 'Drupal\Core\Database\Connection', |
||
55 | 'factory' => 'Drupal\Core\Database\Database::getConnection', |
||
56 | 'arguments' => array('default'), |
||
57 | ); |
||
58 | |||
59 | $services['flood'] = array( |
||
60 | 'class' => '\Drupal\service_container\Flood\LegacyBackend', |
||
61 | 'arguments' => array('@database', '@drupal7'), |
||
62 | 'tags' => array( |
||
63 | array('name' => 'backend_overridable'), |
||
64 | ), |
||
65 | ); |
||
66 | |||
67 | $services['serialization.phpserialize'] = array( |
||
68 | 'class' => 'Drupal\Component\Serialization\PhpSerialize', |
||
69 | ); |
||
70 | |||
71 | $parameters['factory.keyvalue'] = array(); |
||
72 | $parameters['factory.keyvalue.expirable'] = array(); |
||
73 | $services['keyvalue'] = array( |
||
74 | 'class' => 'Drupal\service_container\KeyValueStore\KeyValueFactory', |
||
75 | 'arguments' => array('@service_container', '%factory.keyvalue%') |
||
76 | ); |
||
77 | $services['keyvalue.database'] = array( |
||
78 | 'class' => 'Drupal\Core\KeyValueStore\KeyValueDatabaseFactory', |
||
79 | 'arguments' => array('@serialization.phpserialize', '@database') |
||
80 | ); |
||
81 | $services['keyvalue.expirable'] = array( |
||
82 | 'class' => '\Drupal\service_container\KeyValueStore\KeyValueExpirableFactory', |
||
83 | 'arguments' => array('@service_container', '%factory.keyvalue.expirable%') |
||
84 | ); |
||
85 | $services['keyvalue.expirable.database'] = array( |
||
86 | 'class' => 'Drupal\service_container\KeyValueStore\KeyValueDatabaseExpirableFactory', |
||
87 | 'arguments' => array('@serialization.phpserialize', '@database'), |
||
88 | 'tags' => array( |
||
89 | array('name' => 'needs_destruction'), |
||
90 | ), |
||
91 | ); |
||
92 | |||
93 | $services['state'] = array( |
||
94 | 'class' => 'Drupal\Core\State\State', |
||
95 | 'arguments' => array('@keyvalue'), |
||
96 | ); |
||
97 | |||
98 | $services['variable'] = array( |
||
99 | 'class' => 'Drupal\service_container\Variable', |
||
100 | 'arguments' => array('@drupal7'), |
||
101 | ); |
||
102 | |||
103 | $services['lock'] = array( |
||
104 | 'class' => 'Drupal\Core\Lock\DatabaseLockBackend', |
||
105 | 'arguments' => array('@database'), |
||
106 | 'tags' => array( |
||
107 | array('name' => 'backend_overridable'), |
||
108 | ), |
||
109 | ); |
||
110 | |||
111 | $services['lock.persistent'] = array( |
||
112 | 'class' => 'Drupal\Core\Lock\PersistentDatabaseLockBackend', |
||
113 | 'arguments' => array('@database'), |
||
114 | 'tags' => array( |
||
115 | array('name' => 'backend_overridable'), |
||
116 | ), |
||
117 | ); |
||
118 | |||
119 | $services['messenger'] = array( |
||
120 | 'class' => 'Drupal\service_container\Messenger\LegacyMessenger', |
||
121 | 'arguments' => array('@drupal7'), |
||
122 | ); |
||
123 | |||
124 | $services['url_generator'] = array( |
||
125 | 'class' => 'Drupal\service_container\UrlGenerator', |
||
126 | 'arguments' => array('@drupal7'), |
||
127 | ); |
||
128 | |||
129 | $services['link_generator'] = array( |
||
130 | 'class' => 'Drupal\service_container\LinkGenerator', |
||
131 | 'arguments' => array('@drupal7'), |
||
132 | ); |
||
133 | |||
134 | $services['current_user'] = array( |
||
135 | 'class' => 'Drupal\service_container\Session\Account', |
||
136 | 'arguments' => array('@drupal7', '@variable'), |
||
137 | ); |
||
138 | |||
139 | // Logging integration. |
||
140 | $services['logger.factory'] = array( |
||
141 | 'class' => 'Drupal\service_container\Logger\LoggerChannelFactory', |
||
142 | 'calls' => array( |
||
143 | array('addLogger', array('@logger.dblog')), |
||
144 | ), |
||
145 | ); |
||
146 | |||
147 | $services['logger.dblog'] = array( |
||
148 | 'class' => 'Drupal\service_container\Logger\WatchdogLogger', |
||
149 | 'arguments' => array('@drupal7'), |
||
150 | 'tags' => array( |
||
151 | array('name' => 'logger'), |
||
152 | ), |
||
153 | ); |
||
154 | |||
155 | $services['logger.channel.default'] = array( |
||
156 | 'class' => 'Drupal\service_container\Logger\LoggerChannel', |
||
157 | 'factory' => array('@logger.factory', 'get'), |
||
158 | 'arguments' => array('system'), |
||
159 | ); |
||
160 | |||
161 | $services['logger.channel.php'] = array( |
||
162 | 'class' => 'Drupal\service_container\Logger\LoggerChannel', |
||
163 | 'factory' => array('@logger.factory', 'get'), |
||
164 | 'arguments' => array('php'), |
||
165 | ); |
||
166 | |||
167 | $services['logger.channel.cron'] = array( |
||
168 | 'class' => 'Drupal\service_container\Logger\LoggerChannel', |
||
169 | 'factory' => array('@logger.factory', 'get'), |
||
170 | 'arguments' => array('cron'), |
||
171 | ); |
||
172 | |||
173 | return array( |
||
174 | 'parameters' => $parameters, |
||
175 | 'services' => $services, |
||
176 | ); |
||
177 | } |
||
178 | |||
400 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.