This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Agavi\Database; |
||
3 | |||
4 | // +---------------------------------------------------------------------------+ |
||
5 | // | This file is part of the Agavi package. | |
||
6 | // | Copyright (c) 2005-2011 the Agavi Project. | |
||
7 | // | Based on the Mojavi3 MVC Framework, Copyright (c) 2003-2005 Sean Kerr. | |
||
8 | // | | |
||
9 | // | For the full copyright and license information, please view the LICENSE | |
||
10 | // | file that was distributed with this source code. You can also view the | |
||
11 | // | LICENSE file online at http://www.agavi.org/LICENSE.txt | |
||
12 | // | vi: set noexpandtab: | |
||
13 | // | Local Variables: | |
||
14 | // | indent-tabs-mode: t | |
||
15 | // | End: | |
||
16 | // +---------------------------------------------------------------------------+ |
||
17 | |||
18 | use Agavi\Exception\DatabaseException; |
||
19 | use Agavi\Exception\InitializationException; |
||
20 | use Agavi\Util\ParameterHolder; |
||
21 | |||
22 | /** |
||
23 | * AgaviDatabase is a base abstraction class that allows you to setup any type |
||
24 | * of database connection via a configuration file. |
||
25 | * |
||
26 | * @package agavi |
||
27 | * @subpackage database |
||
28 | * |
||
29 | * @author Sean Kerr <[email protected]> |
||
30 | * @author David Zülke <[email protected]> |
||
31 | * @copyright Authors |
||
32 | * @copyright The Agavi Project |
||
33 | * |
||
34 | * @since 0.9.0 |
||
35 | * |
||
36 | * @version $Id$ |
||
37 | */ |
||
38 | abstract class Database extends ParameterHolder |
||
39 | { |
||
40 | /** |
||
41 | * @var DatabaseManager An AgaviDatabaseManager instance. |
||
42 | */ |
||
43 | protected $databaseManager = null; |
||
44 | |||
45 | /** |
||
46 | * @var mixed A database connection. |
||
47 | */ |
||
48 | protected $connection = null; |
||
49 | |||
50 | /** |
||
51 | * @var string The name of the database. |
||
52 | */ |
||
53 | private $name = null; |
||
54 | |||
55 | /** |
||
56 | * @var mixed A database resource. |
||
57 | */ |
||
58 | protected $resource = null; |
||
59 | |||
60 | /** |
||
61 | * Connect to the database. |
||
62 | * |
||
63 | * @throws <b>AgaviDatabaseException</b> If a connection could not be |
||
64 | * created. |
||
65 | * |
||
66 | * @author Sean Kerr <[email protected]> |
||
67 | * @since 0.9.0 |
||
68 | */ |
||
69 | abstract protected function connect(); |
||
70 | |||
71 | /** |
||
72 | * Retrieve the Database Manager instance for this implementation. |
||
73 | * |
||
74 | * @return DatabaseManager A Database Manager instance. |
||
75 | * |
||
76 | * @author David Zülke <[email protected]> |
||
77 | * @since 0.11.0 |
||
78 | */ |
||
79 | public function getDatabaseManager() |
||
80 | { |
||
81 | return $this->databaseManager; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Retrieve the name of this database connection. |
||
86 | * |
||
87 | * @return string The name of the database. |
||
88 | * |
||
89 | * @author David Zülke <[email protected]> |
||
90 | * @since 0.11.0 |
||
91 | */ |
||
92 | public function getName() |
||
93 | { |
||
94 | return $this->name; |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Retrieve the database connection associated with this Database |
||
99 | * implementation. |
||
100 | * |
||
101 | * When this is executed on a Database implementation that isn't an |
||
102 | * abstraction layer, a copy of the resource will be returned. |
||
103 | * |
||
104 | * @return mixed A database connection. |
||
105 | * |
||
106 | * @throws DatabaseException If a connection could not be retrieved. |
||
107 | * |
||
108 | * @author Sean Kerr <[email protected]> |
||
109 | * @since 0.9.0 |
||
110 | */ |
||
111 | public function getConnection() |
||
112 | { |
||
113 | if ($this->connection === null) { |
||
114 | $this->connect(); |
||
115 | } |
||
116 | |||
117 | return $this->connection; |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Retrieve a raw database resource associated with this Database |
||
122 | * implementation. |
||
123 | * |
||
124 | * @return mixed A database resource. |
||
125 | * |
||
126 | * @throws <b>AgaviDatabaseException</b> If no resource could be retrieved |
||
127 | * |
||
128 | * @author Sean Kerr <[email protected]> |
||
129 | * @since 0.9.0 |
||
130 | */ |
||
131 | public function getResource() |
||
132 | { |
||
133 | if ($this->resource === null) { |
||
134 | $this->connect(); |
||
135 | } |
||
136 | |||
137 | return $this->resource; |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * Initialize this Database. |
||
142 | * |
||
143 | * @param DatabaseManager $databaseManager The database manager of this instance. |
||
144 | * @param array $parameters An assoc array of initialization params. |
||
145 | * |
||
146 | * @throws InitializationException If an error occurs while initializing this Database. |
||
147 | * |
||
148 | * @author David Zülke <[email protected]> |
||
149 | * @author Sean Kerr <[email protected]> |
||
150 | * @since 0.9.0 |
||
151 | */ |
||
152 | public function initialize(DatabaseManager $databaseManager, array $parameters = array()) |
||
153 | { |
||
154 | $this->databaseManager = $databaseManager; |
||
155 | |||
156 | $this->setParameters($parameters); |
||
157 | |||
158 | $this->name = $databaseManager->getDatabaseName($this); |
||
0 ignored issues
–
show
|
|||
159 | } |
||
160 | |||
161 | /** |
||
162 | * Do any necessary startup work after initialization. |
||
163 | * |
||
164 | * This method is not called directly after initialize(). |
||
165 | * It is called during the startup() of the database manager. |
||
166 | * |
||
167 | * @author David Zülke <[email protected]> |
||
168 | * @since 0.11.0 |
||
169 | */ |
||
170 | public function startup() |
||
171 | { |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Execute the shutdown procedure. |
||
176 | * |
||
177 | * @throws <b>AgaviDatabaseException</b> If an error occurs while shutting |
||
178 | * down this database. |
||
179 | * |
||
180 | * @author Sean Kerr <[email protected]> |
||
181 | * @since 0.9.0 |
||
182 | */ |
||
183 | abstract public function shutdown(); |
||
184 | } |
||
185 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.