Conditions | 1 |
Paths | 1 |
Total Lines | 60 |
Code Lines | 48 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | 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 |
||
122 | protected function addForeignKeys() |
||
123 | { |
||
124 | $this->addForeignKey( |
||
125 | $this->db->getForeignKeyName('{{%cacheflag_flags}}', 'sectionId'), |
||
126 | '{{%cacheflag_flags}}', |
||
127 | 'sectionId', |
||
128 | '{{%sections}}', |
||
129 | 'id', |
||
130 | 'CASCADE', |
||
131 | 'CASCADE' |
||
132 | ); |
||
133 | |||
134 | $this->addForeignKey( |
||
135 | $this->db->getForeignKeyName('{{%cacheflag_flags}}', 'categoryGroupId'), |
||
136 | '{{%cacheflag_flags}}', |
||
137 | 'categoryGroupId', |
||
138 | '{{%categorygroups}}', |
||
139 | 'id', |
||
140 | 'CASCADE', |
||
141 | 'CASCADE' |
||
142 | ); |
||
143 | |||
144 | $this->addForeignKey( |
||
145 | $this->db->getForeignKeyName('{{%cacheflag_flags}}', 'tagGroupId'), |
||
146 | '{{%cacheflag_flags}}', |
||
147 | 'tagGroupId', |
||
148 | '{{%taggroups}}', |
||
149 | 'id', |
||
150 | 'CASCADE', |
||
151 | 'CASCADE' |
||
152 | ); |
||
153 | |||
154 | $this->addForeignKey( |
||
155 | $this->db->getForeignKeyName('{{%cacheflag_flags}}', 'userGroupId'), |
||
156 | '{{%cacheflag_flags}}', |
||
157 | 'userGroupId', |
||
158 | '{{%usergroups}}', |
||
159 | 'id', |
||
160 | 'CASCADE', |
||
161 | 'CASCADE' |
||
162 | ); |
||
163 | |||
164 | $this->addForeignKey( |
||
165 | $this->db->getForeignKeyName('{{%cacheflag_flags}}', 'volumeId'), |
||
166 | '{{%cacheflag_flags}}', |
||
167 | 'volumeId', |
||
168 | '{{%volumes}}', |
||
169 | 'id', |
||
170 | 'CASCADE', |
||
171 | 'CASCADE' |
||
172 | ); |
||
173 | |||
174 | $this->addForeignKey( |
||
175 | $this->db->getForeignKeyName('{{%cacheflag_flags}}', 'globalSetId'), |
||
176 | '{{%cacheflag_flags}}', |
||
177 | 'globalSetId', |
||
178 | '{{%globalsets}}', |
||
179 | 'id', |
||
180 | 'CASCADE', |
||
181 | 'CASCADE' |
||
182 | ); |
||
201 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.