| Conditions | 1 |
| Paths | 1 |
| Total Lines | 71 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 69 | public function indexAction() |
||
| 70 | { |
||
| 71 | |||
| 72 | $result = $this->pagination([ |
||
| 73 | 'params' => ['Jobs_Board', ['q', 'page' => 1, 'l', 'd']], |
||
| 74 | 'form' => ['as' => 'filterForm', 'Jobs/JobboardSearch'], |
||
| 75 | 'paginator' => ['as' => 'jobs', 'Jobs/Board'] |
||
| 76 | ]); |
||
| 77 | // /* @var \Zend\Http\Request $request */ |
||
| 78 | // $request = $this->getRequest(); |
||
| 79 | // $params = $request->getQuery(); |
||
| 80 | // $jsonFormat = 'json' == $request->getQuery()->get('format'); |
||
| 81 | // $event = $this->getEvent(); |
||
| 82 | // $routeMatch = $event->getRouteMatch(); |
||
| 83 | // $matchedRouteName = $routeMatch->getMatchedRouteName(); |
||
| 84 | // $url = $this->url()->fromRoute($matchedRouteName, array(), array('force_canonical' => true)); |
||
| 85 | // |
||
| 86 | // if (!$jsonFormat && !$request->isXmlHttpRequest()) { |
||
| 87 | // $session = new Session('Jobs\Index'); |
||
| 88 | // $sessionKey = $this->auth()->isLoggedIn() ? 'userParams' : 'guestParams'; |
||
| 89 | // $sessionParams = $session[$sessionKey]; |
||
| 90 | // if ($sessionParams) { |
||
| 91 | // foreach ($sessionParams as $key => $value) { |
||
| 92 | // $params->set($key, $params->get($key, $value)); |
||
| 93 | // } |
||
| 94 | // } |
||
| 95 | // $session[$sessionKey] = $params->toArray(); |
||
| 96 | // |
||
| 97 | // $this->searchForm->bind($params); |
||
| 98 | // } |
||
| 99 | // |
||
| 100 | // $params = $params->get('params', []); |
||
| 101 | // |
||
| 102 | // if (isset($params['l']['data']) && |
||
| 103 | // isset($params['l']['name']) && |
||
| 104 | // !empty($params['l']['name'])) { |
||
| 105 | // /* @var \Geo\Form\GeoText $geoText */ |
||
| 106 | // $geoText = $this->searchForm->get('params')->get('l'); |
||
| 107 | // |
||
| 108 | // $geoText->setValue($params['l']); |
||
| 109 | // $params['location'] = $geoText->getValue('entity'); |
||
| 110 | // } |
||
| 111 | // |
||
| 112 | // if (!isset($params['sort'])) { |
||
| 113 | // $params['sort']='-date'; |
||
| 114 | // } |
||
| 115 | // |
||
| 116 | // $this->searchForm->setAttribute('action', $url); |
||
| 117 | |||
| 118 | $params['by'] = "guest"; |
||
| 119 | |||
| 120 | // $paginator = $this->paginator('Jobs/Board', $params); |
||
| 121 | |||
| 122 | // $options = $this->searchForm->getOptions(); |
||
| 123 | // $options['showButtons'] = false; |
||
| 124 | // $this->searchForm->setOptions($options); |
||
| 125 | $organizationImageCache = $this->serviceLocator->get('Organizations\ImageFileCache\Manager'); |
||
| 126 | |||
| 127 | $result['organizationImageCache'] = $organizationImageCache; |
||
| 128 | |||
| 129 | return $result; |
||
| 130 | $return = array( |
||
| 131 | 'by' => $params['by'], |
||
| 132 | 'jobs' => $paginator, |
||
| 133 | 'filterForm' => $this->searchForm, |
||
| 134 | 'organizationImageCache' => $organizationImageCache |
||
| 135 | ); |
||
| 136 | $model = new ViewModel($return); |
||
| 137 | |||
| 138 | return $model; |
||
| 139 | } |
||
| 140 | } |
||
| 141 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.