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 |
||
29 | class SymfonyAdaptor extends AbstractAdaptor |
||
30 | { |
||
31 | protected $locator; |
||
32 | protected $context; |
||
33 | |||
34 | /** |
||
35 | * FastRouteAdaptor constructor. |
||
36 | * |
||
37 | * @param SerializerInterface $serializer |
||
38 | * @param array $options |
||
39 | * @throws RouterException |
||
40 | */ |
||
41 | public function __construct(SerializerInterface $serializer, array $options = []) |
||
57 | |||
58 | /** |
||
59 | * Return RouterResponse for given route. |
||
60 | * |
||
61 | * @param RouteCollectionInterface $routes |
||
62 | * @param string $method |
||
63 | * @param string $requestTarget |
||
64 | * @return RouterResponse |
||
65 | * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException |
||
66 | * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedException |
||
67 | */ |
||
68 | public function match(RouteCollectionInterface $routes, $method, $requestTarget) |
||
86 | |||
87 | public function createSymfonyRouteCollection(RouteCollectionInterface $routes) |
||
106 | |||
107 | /** |
||
108 | * Unserialize any cached content and return RouterResponse. |
||
109 | * |
||
110 | * @param $dispatchResponse |
||
111 | * @return RouterResponse |
||
112 | */ |
||
113 | View Code Duplication | public function createRouterResponse($dispatchResponse) |
|
129 | |||
130 | View Code Duplication | public function createFastRouteHandler(RouteInterface $route) |
|
145 | |||
146 | /** |
||
147 | * Check if Cache Enabled and whether too skip adding routes. |
||
148 | * |
||
149 | * @return boolean |
||
150 | */ |
||
151 | public function isCached() |
||
155 | |||
156 | /** |
||
157 | * @inheritdoc |
||
158 | */ |
||
159 | public function getCachedRoutes($context = '') |
||
163 | } |
||
164 |
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.