1 | <?php |
||
8 | class DbContext { |
||
9 | |||
10 | private $container; |
||
11 | private $config; |
||
12 | private $driver; |
||
13 | |||
14 | 33 | public function __construct(Container $container, array $config) { |
|
15 | 33 | $container->bind(Driver::class) |
|
16 | 33 | ->to(self::getDriverClassName($config['driver'])); |
|
17 | 33 | $this->container = $container; |
|
18 | 33 | $this->config = $config; |
|
19 | 33 | } |
|
20 | |||
21 | /** |
||
22 | * |
||
23 | * @return Driver |
||
24 | */ |
||
25 | 33 | public function getDriver() { |
|
26 | 33 | if(is_null($this->driver)) { |
|
27 | 33 | $this->driver = $this->container->resolve(Driver::class, ['config' => $this->config]); |
|
28 | } |
||
29 | 31 | return $this->driver; |
|
30 | } |
||
31 | |||
32 | 33 | public static function getDriverClassName($driver) { |
|
40 | |||
41 | public function query($query, $bindData = false) { |
||
42 | return $this->getDriver()->query($query, $bindData); |
||
44 | |||
45 | } |
||
46 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: