Complex classes like TbActiveForm often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use TbActiveForm, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 15 | class TbActiveForm extends CActiveForm  | 
            ||
| 16 | {
 | 
            ||
| 17 | // Form types.  | 
            ||
| 18 | const TYPE_VERTICAL = 'vertical';  | 
            ||
| 19 | const TYPE_INLINE = 'inline';  | 
            ||
| 20 | const TYPE_HORIZONTAL = 'horizontal';  | 
            ||
| 21 | const TYPE_SEARCH = 'search';  | 
            ||
| 22 | |||
| 23 | // Input classes.  | 
            ||
| 24 | const INPUT_HORIZONTAL = 'bootstrap.widgets.input.TbInputHorizontal';  | 
            ||
| 25 | const INPUT_INLINE = 'bootstrap.widgets.input.TbInputInline';  | 
            ||
| 26 | const INPUT_SEARCH = 'bootstrap.widgets.input.TbInputSearch';  | 
            ||
| 27 | const INPUT_VERTICAL = 'bootstrap.widgets.input.TbInputVertical';  | 
            ||
| 28 | |||
| 29 | /**  | 
            ||
| 30 | * @var string the form type. See class constants.  | 
            ||
| 31 | */  | 
            ||
| 32 | public $type = self::TYPE_VERTICAL;  | 
            ||
| 33 | /**  | 
            ||
| 34 | * @var string input class.  | 
            ||
| 35 | */  | 
            ||
| 36 | public $input;  | 
            ||
| 37 | /**  | 
            ||
| 38 | * @var boolean indicates whether to display errors as blocks.  | 
            ||
| 39 | */  | 
            ||
| 40 | public $inlineErrors;  | 
            ||
| 41 | |||
| 42 | /**  | 
            ||
| 43 | * Initializes the widget.  | 
            ||
| 44 | * This renders the form open tag.  | 
            ||
| 45 | */  | 
            ||
| 46 | 2 | public function init()  | 
            |
| 63 | |||
| 64 | /**  | 
            ||
| 65 | * Renders a checkbox input row.  | 
            ||
| 66 | * @param CModel $model the data model  | 
            ||
| 67 | * @param string $attribute the attribute  | 
            ||
| 68 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 69 | * @return string the generated row  | 
            ||
| 70 | */  | 
            ||
| 71 | public function checkBoxRow($model, $attribute, $htmlOptions = array())  | 
            ||
| 75 | |||
| 76 | /**  | 
            ||
| 77 | * Renders a checkbox list input row.  | 
            ||
| 78 | * @param CModel $model the data model  | 
            ||
| 79 | * @param string $attribute the attribute  | 
            ||
| 80 | * @param array $data the list data  | 
            ||
| 81 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 82 | * @return string the generated row  | 
            ||
| 83 | */  | 
            ||
| 84 | public function checkBoxListRow($model, $attribute, $data = array(), $htmlOptions = array())  | 
            ||
| 88 | |||
| 89 | /**  | 
            ||
| 90 | * Renders a checkbox list inline input row.  | 
            ||
| 91 | * @param CModel $model the data model  | 
            ||
| 92 | * @param string $attribute the attribute  | 
            ||
| 93 | * @param array $data the list data  | 
            ||
| 94 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 95 | * @return string the generated row  | 
            ||
| 96 | */  | 
            ||
| 97 | public function checkBoxListInlineRow($model, $attribute, $data = array(), $htmlOptions = array())  | 
            ||
| 101 | |||
| 102 | /**  | 
            ||
| 103 | * Renders a drop-down list input row.  | 
            ||
| 104 | * @param CModel $model the data model  | 
            ||
| 105 | * @param string $attribute the attribute  | 
            ||
| 106 | * @param array $data the list data  | 
            ||
| 107 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 108 | * @return string the generated row  | 
            ||
| 109 | */  | 
            ||
| 110 | public function dropDownListRow($model, $attribute, $data = array(), $htmlOptions = array())  | 
            ||
| 114 | |||
| 115 | /**  | 
            ||
| 116 | * Renders a file field input row.  | 
            ||
| 117 | * @param CModel $model the data model  | 
            ||
| 118 | * @param string $attribute the attribute  | 
            ||
| 119 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 120 | * @return string the generated row  | 
            ||
| 121 | */  | 
            ||
| 122 | public function fileFieldRow($model, $attribute, $htmlOptions = array())  | 
            ||
| 126 | |||
| 127 | /**  | 
            ||
| 128 | * Renders a password field input row.  | 
            ||
| 129 | * @param CModel $model the data model  | 
            ||
| 130 | * @param string $attribute the attribute  | 
            ||
| 131 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 132 | * @return string the generated row  | 
            ||
| 133 | */  | 
            ||
| 134 | public function passwordFieldRow($model, $attribute, $htmlOptions = array())  | 
            ||
| 138 | |||
| 139 | /**  | 
            ||
| 140 | * Renders a radio button input row.  | 
            ||
| 141 | * @param CModel $model the data model  | 
            ||
| 142 | * @param string $attribute the attribute  | 
            ||
| 143 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 144 | * @return string the generated row  | 
            ||
| 145 | */  | 
            ||
| 146 | public function radioButtonRow($model, $attribute, $htmlOptions = array())  | 
            ||
| 150 | |||
| 151 | /**  | 
            ||
| 152 | * Renders a radio button list input row.  | 
            ||
| 153 | * @param CModel $model the data model  | 
            ||
| 154 | * @param string $attribute the attribute  | 
            ||
| 155 | * @param array $data the list data  | 
            ||
| 156 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 157 | * @return string the generated row  | 
            ||
| 158 | */  | 
            ||
| 159 | public function radioButtonListRow($model, $attribute, $data = array(), $htmlOptions = array())  | 
            ||
| 163 | |||
| 164 | /**  | 
            ||
| 165 | * Renders a radio button list inline input row.  | 
            ||
| 166 | * @param CModel $model the data model  | 
            ||
| 167 | * @param string $attribute the attribute  | 
            ||
| 168 | * @param array $data the list data  | 
            ||
| 169 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 170 | * @return string the generated row  | 
            ||
| 171 | */  | 
            ||
| 172 | public function radioButtonListInlineRow($model, $attribute, $data = array(), $htmlOptions = array())  | 
            ||
| 176 | |||
| 177 | /**  | 
            ||
| 178 | * Renders a text field input row.  | 
            ||
| 179 | * @param CModel $model the data model  | 
            ||
| 180 | * @param string $attribute the attribute  | 
            ||
| 181 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 182 | * @return string the generated row  | 
            ||
| 183 | */  | 
            ||
| 184 | public function textFieldRow($model, $attribute, $htmlOptions = array())  | 
            ||
| 188 | |||
| 189 | /**  | 
            ||
| 190 | * Renders a text area input row.  | 
            ||
| 191 | * @param CModel $model the data model  | 
            ||
| 192 | * @param string $attribute the attribute  | 
            ||
| 193 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 194 | * @return string the generated row  | 
            ||
| 195 | */  | 
            ||
| 196 | 2 | public function textAreaRow($model, $attribute, $htmlOptions = array())  | 
            |
| 200 | |||
| 201 | /**  | 
            ||
| 202 | * Renders a captcha row.  | 
            ||
| 203 | * @param CModel $model the data model  | 
            ||
| 204 | * @param string $attribute the attribute  | 
            ||
| 205 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 206 | * @return string the generated row  | 
            ||
| 207 | * @since 0.9.3  | 
            ||
| 208 | */  | 
            ||
| 209 | public function captchaRow($model, $attribute, $htmlOptions = array())  | 
            ||
| 213 | |||
| 214 | /**  | 
            ||
| 215 | * Renders an uneditable text field row.  | 
            ||
| 216 | * @param CModel $model the data model  | 
            ||
| 217 | * @param string $attribute the attribute  | 
            ||
| 218 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 219 | * @return string the generated row  | 
            ||
| 220 | * @since 0.9.5  | 
            ||
| 221 | */  | 
            ||
| 222 | public function uneditableRow($model, $attribute, $htmlOptions = array())  | 
            ||
| 226 | |||
| 227 | /**  | 
            ||
| 228 | * Renders a checkbox list for a model attribute.  | 
            ||
| 229 | 	 * This method is a wrapper of {@link CHtml::activeCheckBoxList}.
 | 
            ||
| 230 | 	 * Please check {@link CHtml::activeCheckBoxList} for detailed information
 | 
            ||
| 231 | * about the parameters for this method.  | 
            ||
| 232 | * @param CModel $model the data model  | 
            ||
| 233 | * @param string $attribute the attribute  | 
            ||
| 234 | * @param array $data value-label pairs used to generate the check box list.  | 
            ||
| 235 | * @param array $htmlOptions additional HTML options.  | 
            ||
| 236 | * @return string the generated check box list  | 
            ||
| 237 | * @since 0.9.5  | 
            ||
| 238 | */  | 
            ||
| 239 | public function checkBoxList($model, $attribute, $data, $htmlOptions = array())  | 
            ||
| 243 | |||
| 244 | /**  | 
            ||
| 245 | * Renders a radio button list for a model attribute.  | 
            ||
| 246 | 	 * This method is a wrapper of {@link CHtml::activeRadioButtonList}.
 | 
            ||
| 247 | 	 * Please check {@link CHtml::activeRadioButtonList} for detailed information
 | 
            ||
| 248 | * about the parameters for this method.  | 
            ||
| 249 | * @param CModel $model the data model  | 
            ||
| 250 | * @param string $attribute the attribute  | 
            ||
| 251 | * @param array $data value-label pairs used to generate the radio button list.  | 
            ||
| 252 | * @param array $htmlOptions additional HTML options.  | 
            ||
| 253 | * @return string the generated radio button list  | 
            ||
| 254 | * @since 0.9.5  | 
            ||
| 255 | */  | 
            ||
| 256 | public function radioButtonList($model, $attribute, $data, $htmlOptions = array())  | 
            ||
| 260 | |||
| 261 | /**  | 
            ||
| 262 | * Renders an input list.  | 
            ||
| 263 | * @param boolean $checkbox flag that indicates if the list is a checkbox-list.  | 
            ||
| 264 | * @param CModel $model the data model  | 
            ||
| 265 | * @param string $attribute the attribute  | 
            ||
| 266 | * @param array $data value-label pairs used to generate the input list.  | 
            ||
| 267 | * @param array $htmlOptions additional HTML options.  | 
            ||
| 268 | * @return string the generated input list.  | 
            ||
| 269 | * @since 0.9.5  | 
            ||
| 270 | */  | 
            ||
| 271 | 2 | protected function inputsList($checkbox, $model, $attribute, $data, $htmlOptions = array())  | 
            |
| 341 | |||
| 342 | /**  | 
            ||
| 343 | * Displays a summary of validation errors for one or several models.  | 
            ||
| 344 | 	 * This method is very similar to {@link CHtml::errorSummary} except that it also works
 | 
            ||
| 345 | * when AJAX validation is performed.  | 
            ||
| 346 | * @param mixed $models the models whose input errors are to be displayed. This can be either  | 
            ||
| 347 | * a single model or an array of models.  | 
            ||
| 348 | * @param string $header a piece of HTML code that appears in front of the errors  | 
            ||
| 349 | * @param string $footer a piece of HTML code that appears at the end of the errors  | 
            ||
| 350 | * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.  | 
            ||
| 351 | * @return string the error summary. Empty if no errors are found.  | 
            ||
| 352 | * @see CHtml::errorSummary  | 
            ||
| 353 | */  | 
            ||
| 354 | public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array())  | 
            ||
| 361 | |||
| 362 | /**  | 
            ||
| 363 | * Displays the first validation error for a model attribute.  | 
            ||
| 364 | * @param CModel $model the data model  | 
            ||
| 365 | * @param string $attribute the attribute name  | 
            ||
| 366 | * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.  | 
            ||
| 367 | * @param boolean $enableAjaxValidation whether to enable AJAX validation for the specified attribute.  | 
            ||
| 368 | * @param boolean $enableClientValidation whether to enable client-side validation for the specified attribute.  | 
            ||
| 369 | * @return string the validation result (error display or success message).  | 
            ||
| 370 | */  | 
            ||
| 371 | 2 | public function error($model, $attribute, $htmlOptions = array(), $enableAjaxValidation = true, $enableClientValidation = true)  | 
            |
| 461 | |||
| 462 | /**  | 
            ||
| 463 | * Displays the first validation error for a model attribute.  | 
            ||
| 464 | * @param CModel $model the data model  | 
            ||
| 465 | * @param string $attribute the attribute name  | 
            ||
| 466 | * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.  | 
            ||
| 467 | * @return string the error display. Empty if no errors are found.  | 
            ||
| 468 | * @see CModel::getErrors  | 
            ||
| 469 | * @see errorMessageCss  | 
            ||
| 470 | */  | 
            ||
| 471 | 2 | protected static function renderError($model, $attribute, $htmlOptions = array())  | 
            |
| 477 | |||
| 478 | /**  | 
            ||
| 479 | * Creates an input row of a specific type.  | 
            ||
| 480 | * @param string $type the input type  | 
            ||
| 481 | * @param CModel $model the data model  | 
            ||
| 482 | * @param string $attribute the attribute  | 
            ||
| 483 | * @param array $data the data for list inputs  | 
            ||
| 484 | * @param array $htmlOptions additional HTML attributes  | 
            ||
| 485 | * @return string the generated row  | 
            ||
| 486 | */  | 
            ||
| 487 | 2 | public function inputRow($type, $model, $attribute, $data = null, $htmlOptions = array())  | 
            |
| 500 | |||
| 501 | /**  | 
            ||
| 502 | * Returns the input widget class name suitable for the form.  | 
            ||
| 503 | * @return string the class name  | 
            ||
| 504 | */  | 
            ||
| 505 | protected function getInputClassName()  | 
            ||
| 532 | }  | 
            ||
| 533 | 
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.