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 |
||
10 | class Transaction extends BaseEventEmitter implements TransactionInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var ConnectorInterface |
||
14 | */ |
||
15 | protected $connector; |
||
16 | |||
17 | /** |
||
18 | * @var bool |
||
19 | */ |
||
20 | protected $open; |
||
21 | |||
22 | /** |
||
23 | * @param ConnectorInterface $connector |
||
24 | * @param EventEmitterInterface $emitter |
||
25 | */ |
||
26 | public function __construct(ConnectorInterface $connector, EventEmitterInterface $emitter) |
||
32 | |||
33 | /** |
||
34 | * @override |
||
35 | * @inheritDoc |
||
36 | */ |
||
37 | public function isOpen() |
||
41 | |||
42 | /** |
||
43 | * @override |
||
44 | * @inheritDoc |
||
45 | */ |
||
46 | public function query($sql, array $sqlParams = []) |
||
50 | |||
51 | /** |
||
52 | * @override |
||
53 | * @inheritDoc |
||
54 | */ |
||
55 | public function execute($sql, array $sqlParams = []) |
||
59 | |||
60 | public function begin() |
||
74 | |||
75 | /** |
||
76 | * @override |
||
77 | * @inheritDoc |
||
78 | */ |
||
79 | View Code Duplication | public function commit() |
|
89 | |||
90 | /** |
||
91 | * @override |
||
92 | * @inheritDoc |
||
93 | */ |
||
94 | View Code Duplication | public function rollback() |
|
104 | } |
||
105 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.