1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Doctrine\Tests\Mocks; |
||
6 | |||
7 | use Doctrine\DBAL\Driver\Connection; |
||
8 | use Doctrine\DBAL\Driver\ResultStatement; |
||
9 | use Doctrine\DBAL\Driver\Statement; |
||
10 | use Doctrine\DBAL\ParameterType; |
||
11 | |||
12 | /** |
||
13 | * Mock class for DriverConnection. |
||
14 | */ |
||
15 | class DriverConnectionMock implements Connection |
||
16 | { |
||
17 | /** @var Statement */ |
||
18 | private $statementMock; |
||
19 | |||
20 | /** |
||
21 | * @return Statement |
||
22 | */ |
||
23 | public function getStatementMock() |
||
24 | { |
||
25 | return $this->statementMock; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param Statement $statementMock |
||
30 | */ |
||
31 | public function setStatementMock($statementMock) |
||
32 | { |
||
33 | $this->statementMock = $statementMock; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * {@inheritdoc} |
||
38 | */ |
||
39 | public function prepare(string $prepareString) : Statement |
||
40 | { |
||
41 | return $this->statementMock ?: new StatementMock(); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | public function query(string $sql) : ResultStatement |
||
48 | { |
||
49 | return $this->statementMock ?: new StatementMock(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | public function quote($input, $type = ParameterType::STRING) |
||
56 | { |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * {@inheritdoc} |
||
61 | */ |
||
62 | public function exec(string $statement) : int |
||
63 | { |
||
64 | } |
||
0 ignored issues
–
show
|
|||
65 | |||
66 | /** |
||
67 | * {@inheritdoc} |
||
68 | */ |
||
69 | public function lastInsertId($name = null) |
||
70 | { |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * {@inheritdoc} |
||
75 | */ |
||
76 | public function beginTransaction() |
||
77 | { |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | public function commit() |
||
84 | { |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | public function rollBack() |
||
91 | { |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function errorCode() |
||
98 | { |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * {@inheritdoc} |
||
103 | */ |
||
104 | public function errorInfo() |
||
105 | { |
||
106 | } |
||
107 | } |
||
108 |
For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example: