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 |
||
17 | final class SimpleCacheSessionHandler implements \SessionHandlerInterface, LoggerAwareInterface |
||
18 | { |
||
19 | use LoggerAwareTrait; |
||
20 | |||
21 | /** |
||
22 | * @var CacheInterface |
||
23 | */ |
||
24 | private $cache; |
||
25 | |||
26 | /** |
||
27 | * @param CacheInterface $cache |
||
28 | * @param LoggerInterface|null $logger |
||
29 | */ |
||
30 | 13 | public function __construct(CacheInterface $cache, LoggerInterface $logger = null) |
|
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | 1 | public function close() |
|
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 3 | View Code Duplication | public function destroy($session_id) |
64 | |||
65 | /** |
||
66 | * {@inheritdoc} |
||
67 | */ |
||
68 | 1 | public function gc($maxlifetime) |
|
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | 1 | public function open($save_path, $name) |
|
80 | |||
81 | /** |
||
82 | * {@inheritdoc} |
||
83 | */ |
||
84 | 2 | public function read($session_id) |
|
101 | |||
102 | /** |
||
103 | * {@inheritdoc} |
||
104 | */ |
||
105 | 3 | View Code Duplication | public function write($session_id, $session_data) |
122 | } |
||
123 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.