Skip to content

Commit d044047

Browse files
committed
Merge remote-tracking branch 'vimeo/master'
2 parents 8e93cb6 + 7f247b2 commit d044047

32 files changed

+807
-793
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ PHP MySQL Engine works by providing a subclass of [PDO](https://www.php.net/manu
6060
You can instantiate the subclass as you would `PDO`, and use dependency injection or similar to provide that instance to your application code.
6161

6262
```php
63-
$pdo = new \Vimeo\MysqlEngine\FakePdo($dsn, $user, $password);
63+
// use a class specific to your cuurrent PHP version (APIs changed in major versions)
64+
$pdo = new \Vimeo\MysqlEngine\Php8\FakePdo($dsn, $user, $password);
6465
// currently supported attributes
6566
$pdo->setAttribute(\PDO::ATTR_CASE, \PDO::CASE_LOWER);
6667
$pdo->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);

psalm-baseline.xml

Lines changed: 34 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<files psalm-version="dev-master@665170eadb6cb0728de7f70a52db0b339285f8dc">
2+
<files psalm-version="4.4.1@9fd7a7d885b3a216cff8dec9d8c21a132f275224">
33
<file src="src/DataIntegrity.php">
4-
<MissingClosureParamType occurrences="2">
5-
<code>$field</code>
6-
<code>$key</code>
7-
</MissingClosureParamType>
84
<MissingParamType occurrences="1">
95
<code>$value</code>
106
</MissingParamType>
11-
<MixedArgument occurrences="3">
7+
<MixedArgument occurrences="1">
128
<code>$column_default</code>
13-
<code>$unique_key</code>
14-
<code>$unique_key</code>
159
</MixedArgument>
1610
<MixedArrayOffset occurrences="5">
1711
<code>$existing_row[$field]</code>
@@ -20,38 +14,14 @@
2014
<code>$new_row[$key]</code>
2115
<code>$new_row[$key]</code>
2216
</MixedArrayOffset>
23-
<MixedAssignment occurrences="8">
17+
<MixedAssignment occurrences="4">
2418
<code>$column_default</code>
25-
<code>$index</code>
2619
<code>$key</code>
2720
<code>$row[$column_name]</code>
28-
<code>$unique_key</code>
29-
<code>$unique_keys[$name]</code>
30-
<code>$unique_keys['PRIMARY']</code>
3121
<code>$value</code>
3222
</MixedAssignment>
33-
<MixedPropertyFetch occurrences="3">
34-
<code>$index-&gt;columns</code>
35-
<code>$index-&gt;columns</code>
36-
<code>$index-&gt;type</code>
37-
</MixedPropertyFetch>
38-
</file>
39-
<file src="src/FakePdo.php">
40-
<MissingParamType occurrences="4">
41-
<code>$key</code>
42-
<code>$options</code>
43-
<code>$seqname</code>
44-
<code>$value</code>
45-
</MissingParamType>
46-
<MixedArgument occurrences="2">
47-
<code>$key</code>
48-
<code>$seqname</code>
49-
</MixedArgument>
50-
<PossiblyNullArgument occurrences="1">
51-
<code>$host</code>
52-
</PossiblyNullArgument>
5323
</file>
54-
<file src="src/FakePdoTrait.php">
24+
<file src="src/FakePdoStatementTrait.php">
5525
<ArgumentTypeCoercion occurrences="1">
5626
<code>$class</code>
5727
</ArgumentTypeCoercion>
@@ -91,12 +61,26 @@
9161
<code>$ctor_args</code>
9262
<code>$fetch_argument</code>
9363
<code>$fetch_argument</code>
94-
<code>$this-&gt;conn-&gt;databaseName</code>
95-
<code>$this-&gt;conn-&gt;databaseName</code>
96-
<code>$this-&gt;conn-&gt;databaseName</code>
64+
<code>$this-&gt;conn-&gt;getDatabaseName()</code>
65+
<code>$this-&gt;conn-&gt;getDatabaseName()</code>
66+
<code>$this-&gt;conn-&gt;getDatabaseName()</code>
9767
<code>$this-&gt;fetchConstructorArgs</code>
9868
</PossiblyNullArgument>
9969
</file>
70+
<file src="src/FakePdoTrait.php">
71+
<MissingParamType occurrences="3">
72+
<code>$key</code>
73+
<code>$seqname</code>
74+
<code>$value</code>
75+
</MissingParamType>
76+
<MixedArgument occurrences="2">
77+
<code>$key</code>
78+
<code>$seqname</code>
79+
</MixedArgument>
80+
<PossiblyNullArgument occurrences="1">
81+
<code>$host</code>
82+
</PossiblyNullArgument>
83+
</file>
10084
<file src="src/Parser/CreateTableParser.php">
10185
<ArgumentTypeCoercion occurrences="1">
10286
<code>$these_tokens</code>
@@ -172,13 +156,20 @@
172156
</DocblockTypeContradiction>
173157
</file>
174158
<file src="src/Parser/LimitParser.php">
175-
<PossiblyNullArgument occurrences="3">
176-
<code>$next-&gt;parameterName</code>
159+
<PossiblyNullArgument occurrences="2">
177160
<code>$next-&gt;parameterName</code>
178161
<code>$next-&gt;parameterName</code>
179162
</PossiblyNullArgument>
180163
</file>
181164
<file src="src/Parser/SQLLexer.php">
165+
<ArgumentTypeCoercion occurrences="1">
166+
<code>\PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_OFFSET_CAPTURE</code>
167+
</ArgumentTypeCoercion>
168+
<InvalidArgument occurrences="3">
169+
<code>$tokens</code>
170+
<code>$tokens</code>
171+
<code>$tokens</code>
172+
</InvalidArgument>
182173
<PossiblyNullArrayOffset occurrences="1">
183174
<code>$tokens</code>
184175
</PossiblyNullArrayOffset>
@@ -240,8 +231,9 @@
240231
<code>$stmt-&gt;values</code>
241232
<code>$stmt-&gt;values</code>
242233
</MixedArgumentTypeCoercion>
243-
<PossiblyNullArgument occurrences="4">
244-
<code>$conn-&gt;databaseName</code>
234+
<PossiblyNullArgument occurrences="5">
235+
<code>$conn-&gt;getDatabaseName()</code>
236+
<code>$conn-&gt;getDatabaseName()</code>
245237
<code>$stmt-&gt;decimals</code>
246238
<code>$stmt-&gt;length</code>
247239
<code>$stmt-&gt;length</code>
@@ -347,8 +339,7 @@
347339
</RedundantConditionGivenDocblockType>
348340
</file>
349341
<file src="src/Processor/Expression/Evaluator.php">
350-
<MixedAssignment occurrences="2">
351-
<code>$value</code>
342+
<MixedAssignment occurrences="1">
352343
<code>$value</code>
353344
</MixedAssignment>
354345
<PossiblyNullArgument occurrences="1">
@@ -552,11 +543,6 @@
552543
<code>$rows</code>
553544
</MixedPropertyTypeCoercion>
554545
</file>
555-
<file src="src/Processor/Scope.php">
556-
<MixedPropertyTypeCoercion occurrences="1">
557-
<code>$parameters</code>
558-
</MixedPropertyTypeCoercion>
559-
</file>
560546
<file src="src/Processor/SelectProcessor.php">
561547
<DocblockTypeContradiction occurrences="2">
562548
<code>$result-&gt;grouped_rows === null</code>

src/DataIntegrity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ final class DataIntegrity
77
* @return mixed
88
*/
99
protected static function getDefaultValueForColumn(
10-
FakePdo $conn,
10+
FakePdoInterface $conn,
1111
string $php_type,
1212
bool $nullable,
1313
?string $default,
@@ -57,7 +57,7 @@ protected static function getDefaultValueForColumn(
5757
* @return array<string, mixed>
5858
*/
5959
public static function ensureColumnsPresent(
60-
FakePdo $conn,
60+
FakePdoInterface $conn,
6161
array $row,
6262
Schema\TableDefinition $table_definition
6363
) {
@@ -119,7 +119,7 @@ public static function ensureColumnsPresent(
119119
* @return array<string, mixed>
120120
*/
121121
public static function coerceToSchema(
122-
FakePdo $conn,
122+
FakePdoInterface $conn,
123123
array $row,
124124
Schema\TableDefinition $table_definition
125125
) {

src/FakePdo.php

Lines changed: 0 additions & 161 deletions
This file was deleted.

src/FakePdoInterface.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
namespace Vimeo\MysqlEngine;
3+
4+
interface FakePdoInterface
5+
{
6+
public function getServer(): Server;
7+
8+
public function setLastInsertId(string $last_insert_id): void;
9+
10+
public function getDatabaseName(): ?string;
11+
12+
public function shouldStringifyResult(): bool;
13+
14+
public function shouldLowercaseResultKeys(): bool;
15+
16+
/**
17+
* @param string $seqname
18+
*/
19+
public function lastInsertId($seqname = null) : string;
20+
}

0 commit comments

Comments
 (0)