1 | <?php |
||
2 | /* |
||
3 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||
4 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||
5 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||
6 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||
7 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||
8 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||
9 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
10 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
11 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
12 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||
13 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
14 | * |
||
15 | * This software consists of voluntary contributions made by many individuals |
||
16 | * and is licensed under the MIT license. For more information, see |
||
17 | * <http://www.doctrine-project.org>. |
||
18 | */ |
||
19 | |||
20 | namespace Doctrine\DBAL\Driver\PDOSqlite; |
||
21 | |||
22 | use Doctrine\DBAL\DBALException; |
||
23 | use Doctrine\DBAL\Driver\AbstractSQLiteDriver; |
||
24 | use Doctrine\DBAL\Driver\PDOConnection; |
||
25 | use PDOException; |
||
26 | |||
27 | /** |
||
28 | * The PDO Sqlite driver. |
||
29 | * |
||
30 | * @since 2.0 |
||
31 | */ |
||
32 | class Driver extends AbstractSQLiteDriver |
||
33 | { |
||
34 | /** |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $_userDefinedFunctions = [ |
||
38 | 'sqrt' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfSqrt'], 'numArgs' => 1], |
||
39 | 'mod' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfMod'], 'numArgs' => 2], |
||
40 | 'locate' => ['callback' => ['Doctrine\DBAL\Platforms\SqlitePlatform', 'udfLocate'], 'numArgs' => -1], |
||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 47 | public function connect(array $params, $username = null, $password = null, array $driverOptions = []) |
|
47 | { |
||
48 | 47 | if (isset($driverOptions['userDefinedFunctions'])) { |
|
49 | $this->_userDefinedFunctions = array_merge( |
||
50 | $this->_userDefinedFunctions, $driverOptions['userDefinedFunctions']); |
||
51 | unset($driverOptions['userDefinedFunctions']); |
||
52 | } |
||
53 | |||
54 | try { |
||
55 | 47 | $pdo = new PDOConnection( |
|
56 | 47 | $this->_constructPdoDsn($params), |
|
57 | 47 | $username, |
|
58 | 47 | $password, |
|
59 | 47 | $driverOptions |
|
60 | ); |
||
61 | 1 | } catch (PDOException $ex) { |
|
62 | 1 | throw DBALException::driverException($this, $ex); |
|
63 | } |
||
64 | |||
65 | 46 | foreach ($this->_userDefinedFunctions as $fn => $data) { |
|
66 | 46 | $pdo->sqliteCreateFunction($fn, $data['callback'], $data['numArgs']); |
|
0 ignored issues
–
show
|
|||
67 | } |
||
68 | |||
69 | 46 | return $pdo; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * Constructs the Sqlite PDO DSN. |
||
74 | * |
||
75 | * @param array $params |
||
76 | * |
||
77 | * @return string The DSN. |
||
78 | */ |
||
79 | 47 | protected function _constructPdoDsn(array $params) |
|
80 | { |
||
81 | 47 | $dsn = 'sqlite:'; |
|
82 | 47 | if (isset($params['path'])) { |
|
83 | 4 | $dsn .= $params['path']; |
|
84 | 44 | } elseif (isset($params['memory'])) { |
|
85 | 44 | $dsn .= ':memory:'; |
|
86 | } |
||
87 | |||
88 | 47 | return $dsn; |
|
89 | } |
||
90 | |||
91 | /** |
||
92 | * {@inheritdoc} |
||
93 | */ |
||
94 | 7 | public function getName() |
|
95 | { |
||
96 | 7 | return 'pdo_sqlite'; |
|
97 | } |
||
98 | } |
||
99 |
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.