webstream-framework /
Database
| 1 | <?php |
||
| 2 | |||
| 3 | namespace WebStream\Database\Driver; |
||
| 4 | |||
| 5 | use Doctrine\DBAL\Configuration; |
||
| 6 | use Doctrine\DBAL\DriverManager; |
||
| 7 | use Doctrine\DBAL\Exception; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Mysql |
||
| 11 | * @author Ryuichi TANAKA. |
||
| 12 | * @since 2013/12/07 |
||
| 13 | * @version 0.4 |
||
| 14 | */ |
||
| 15 | class Mysql extends DatabaseDriver |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * {@inheritdoc} |
||
| 19 | * @throws Exception |
||
| 20 | */ |
||
| 21 | 34 | public function connect() |
|
| 22 | { |
||
| 23 | $params = [ |
||
| 24 | 34 | 'dbname' => $this->config->dbname, |
|
| 25 | 34 | 'user' => $this->config->username, |
|
| 26 | 34 | 'password' => $this->config->password, |
|
| 27 | 34 | 'host' => $this->config->host, |
|
| 28 | 34 | 'port' => $this->config->port, |
|
| 29 | 34 | 'driver' => 'pdo_mysql', |
|
| 30 | 34 | 'charset' => 'utf8' |
|
| 31 | ]; |
||
| 32 | |||
| 33 | 34 | $config = new Configuration([ |
|
|
0 ignored issues
–
show
|
|||
| 34 | 34 | \PDO::ATTR_PERSISTENT => true, |
|
| 35 | \PDO::ATTR_EMULATE_PREPARES => false, |
||
| 36 | \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION, |
||
| 37 | \PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true |
||
| 38 | ]); |
||
| 39 | |||
| 40 | 34 | $this->connection = DriverManager::getConnection($params, $config); |
|
| 41 | 34 | $this->logger->debug(get_class($this) . " connect."); |
|
| 42 | 34 | } |
|
| 43 | } |
||
| 44 |
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. Please note the @ignore annotation hint above.