1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Doctrine\Tests\Mocks; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Connection; |
6
|
|
|
use Doctrine\DBAL\Driver; |
7
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
8
|
|
|
use Doctrine\DBAL\Schema\AbstractSchemaManager; |
9
|
|
|
use Throwable; |
10
|
|
|
|
11
|
|
|
class DriverMock implements Driver |
12
|
|
|
{ |
13
|
|
|
/** @var DatabasePlatformMock */ |
14
|
|
|
private $platformMock; |
15
|
|
|
|
16
|
|
|
/** @var AbstractSchemaManager */ |
17
|
|
|
private $schemaManagerMock; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* {@inheritDoc} |
21
|
|
|
*/ |
22
|
|
|
public function connect(array $params, $username = null, $password = null, array $driverOptions = []) |
23
|
|
|
{ |
24
|
|
|
return new DriverConnectionMock(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function getDatabasePlatform() |
28
|
|
|
{ |
29
|
|
|
if (! $this->platformMock) { |
30
|
|
|
$this->platformMock = new DatabasePlatformMock(); |
31
|
|
|
} |
32
|
|
|
return $this->platformMock; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function getSchemaManager(Connection $conn) |
36
|
|
|
{ |
37
|
|
|
if ($this->schemaManagerMock === null) { |
38
|
|
|
return new SchemaManagerMock($conn); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return $this->schemaManagerMock; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function setDatabasePlatform(AbstractPlatform $platform) |
45
|
|
|
{ |
46
|
|
|
$this->platformMock = $platform; |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function setSchemaManager(AbstractSchemaManager $sm) |
50
|
|
|
{ |
51
|
|
|
$this->schemaManagerMock = $sm; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getName() |
55
|
|
|
{ |
56
|
|
|
return 'mock'; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getDatabase(Connection $conn) |
60
|
|
|
{ |
61
|
|
|
return; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function convertExceptionCode(Throwable $exception) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
return 0; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
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 given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.