Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 30 | class SymfonyAdaptor extends AbstractAdaptor |
||
| 31 | { |
||
| 32 | protected $locator; |
||
| 33 | protected $context; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * FastRouteAdaptor constructor. |
||
| 37 | * |
||
| 38 | * @param SerializerInterface $serializer |
||
| 39 | * @param array $options |
||
| 40 | * @throws RouterException |
||
| 41 | */ |
||
| 42 | public function __construct(SerializerInterface $serializer, array $options = []) |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Return RouterResponse for given route. |
||
| 61 | * |
||
| 62 | * @param RouteCollectionInterface $routes |
||
| 63 | * @param string $method |
||
| 64 | * @param string $requestTarget |
||
| 65 | * @return RouterResponse |
||
| 66 | * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException |
||
| 67 | * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedException |
||
| 68 | */ |
||
| 69 | public function match(RouteCollectionInterface $routes, $method, $requestTarget) |
||
| 87 | |||
| 88 | public function createSymfonyRouteCollection(RouteCollectionInterface $routes) |
||
| 107 | |||
| 108 | /** |
||
| 109 | * Unserialize any cached content and return RouterResponse. |
||
| 110 | * |
||
| 111 | * @param $dispatchResponse |
||
| 112 | * @return RouterResponse |
||
| 113 | */ |
||
| 114 | View Code Duplication | public function createRouterResponse($dispatchResponse) |
|
| 130 | |||
| 131 | View Code Duplication | public function createFastRouteHandler(RouteInterface $route) |
|
| 146 | |||
| 147 | /** |
||
| 148 | * Check if Cache Enabled and whether too skip adding routes. |
||
| 149 | * |
||
| 150 | * @return boolean |
||
| 151 | */ |
||
| 152 | public function isCached() |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @inheritdoc |
||
| 159 | */ |
||
| 160 | public function getCachedRoutes($context = '') |
||
| 164 | } |
||
| 165 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.