1 | <?php |
||
10 | class Zend2 implements AdapterInterface |
||
11 | { |
||
12 | private $connection; |
||
13 | private $options; |
||
14 | |||
15 | /** |
||
16 | * @param Options $options |
||
17 | * @param DbAdapter $connection |
||
18 | */ |
||
19 | 9 | public function __construct(Options $options, DbAdapter $connection) |
|
24 | |||
25 | /** |
||
26 | * @return DbAdapter |
||
27 | */ |
||
28 | 7 | private function getConnection(): DbAdapter |
|
32 | |||
33 | /** |
||
34 | * @return Options |
||
35 | */ |
||
36 | 1 | public function getOptions(): Options |
|
40 | |||
41 | 4 | public function beginTransaction(): void |
|
48 | |||
49 | 2 | public function commitTransaction(): void |
|
56 | |||
57 | 2 | public function rollbackTransaction(): void |
|
64 | |||
65 | 4 | public function isInTransaction(): bool |
|
72 | |||
73 | 1 | public function canHandleNestedTransaction(): bool |
|
77 | |||
78 | 1 | public function quoteIdentifier(string $columnName): string |
|
84 | |||
85 | 1 | public function executeInsertSQL(string $sql, array $params = array()) |
|
86 | { |
||
87 | 1 | $options = $this->getOptions(); |
|
88 | 1 | $this->executeSQL($sql, $params); |
|
89 | |||
90 | 1 | if (array_key_exists($options->getIdColumnName(), $params)) { |
|
91 | return $params[$options->getIdColumnName()]; |
||
92 | } else { |
||
93 | 1 | $lastGeneratedValue = $this->getConnection() |
|
94 | 1 | ->getDriver() |
|
95 | 1 | ->getLastGeneratedValue($options->getSequenceName()); |
|
|
|||
96 | |||
97 | 1 | return $lastGeneratedValue; |
|
98 | } |
||
99 | } |
||
100 | |||
101 | 2 | public function executeSQL(string $sql, array $params = array()): void |
|
106 | |||
107 | 2 | public function executeSelectSQL(string $sql, array $params = array()): array |
|
113 | } |
||
114 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.