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 |
||
40 | class ScramblePrivateProperty extends ScramblerVisitor |
||
41 | { |
||
42 | use TrackingRenamerTrait; |
||
43 | use SkipTrait; |
||
44 | |||
45 | /** |
||
46 | * Constructor |
||
47 | * |
||
48 | * @param StringScrambler $scrambler |
||
49 | * @return void |
||
|
|||
50 | **/ |
||
51 | public function __construct(StringScrambler $scrambler) |
||
55 | |||
56 | /** |
||
57 | * Before node traversal |
||
58 | * |
||
59 | * @param Node[] $nodes |
||
60 | * @return array |
||
61 | **/ |
||
62 | public function beforeTraverse(array $nodes) |
||
70 | |||
71 | /** |
||
72 | * Check all variable nodes |
||
73 | * |
||
74 | * @param Node $node |
||
75 | * @return void |
||
76 | **/ |
||
77 | public function enterNode(Node $node) |
||
91 | |||
92 | /** |
||
93 | * Recursively scan for private method definitions and rename them |
||
94 | * |
||
95 | * @param Node[] $nodes |
||
96 | * @return void |
||
97 | **/ |
||
98 | View Code Duplication | private function scanPropertyDefinitions(array $nodes) |
|
121 | } |
||
122 |
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.