1 | <?php |
||
16 | class CacheableDatabase |
||
17 | { |
||
18 | /** |
||
19 | * MySQL database access |
||
20 | * @var mysqli |
||
21 | */ |
||
22 | protected $sql; |
||
23 | |||
24 | /** |
||
25 | * Caching for queried data |
||
26 | * @var HierarchicalSimpleCache |
||
27 | */ |
||
28 | protected $cache; |
||
29 | |||
30 | /** |
||
31 | * Construct a CacheableDatabase object |
||
32 | * |
||
33 | * Note that the cache is instantiated just in time, and will not be created |
||
34 | * until its first use. |
||
35 | * |
||
36 | * @param mysqli|Toolbox|CacheableDatabase $databaseProvider An object |
||
37 | * containing a mysqli object that can be reused |
||
38 | * |
||
39 | * @throws SnapshotException `SnapshotException::MYSQL` If a valid mysqli |
||
40 | * database object cannot be extracted from the `$databaseProvider` |
||
41 | */ |
||
42 | public function __construct($databaseProvider) |
||
62 | |||
63 | /** |
||
64 | * MySQL access |
||
65 | * |
||
66 | * @return mysqli |
||
67 | */ |
||
68 | protected function getMySql() |
||
72 | |||
73 | /** |
||
74 | * Cache access |
||
75 | * |
||
76 | * @return HierarchicalSimpleCache |
||
77 | */ |
||
78 | protected function getCache() |
||
89 | } |
||
90 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: