Skip to content

Commit 1d30e2d

Browse files
committed
fix impl
1 parent 494c548 commit 1d30e2d

5 files changed

+41
-10
lines changed

tests/rules/SyntaxErrorInQueryFunctionRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,18 @@ public function getExpectedErrors(): array
103103
default: throw new \RuntimeException(sprintf('Unsupported DBA_REFLECTOR %s', $dbaReflector));
104104
}
105105
}
106+
107+
public function testMysqliExecuteQuery(): void
108+
{
109+
if (\PHP_VERSION_ID < 80200) {
110+
self::markTestSkipped('Test requires PHP 8.2.');
111+
}
112+
113+
$this->analyse([__DIR__.'/data/mysqli_execute_query.php'], [
114+
[
115+
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
116+
11,
117+
],
118+
]);
119+
}
106120
}

tests/rules/SyntaxErrorInQueryMethodRuleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,18 @@ public function testSyntaxErrorInQueryRule(): void
217217

218218
$this->analyse([__DIR__.'/data/syntax-error-in-query-method.php'], $expected);
219219
}
220+
221+
public function testMysqliExecuteQuery(): void
222+
{
223+
if (\PHP_VERSION_ID < 80200) {
224+
self::markTestSkipped('Test requires PHP 8.2.');
225+
}
226+
227+
$this->analyse([__DIR__.'/data/mysqli_execute_query.php'], [
228+
[
229+
"Query error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL/MariaDB server version for the right syntax to use near 'freigabe1u1 FROM ada LIMIT 0' at line 1 (1064).",
230+
9,
231+
],
232+
]);
233+
}
220234
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace MysqliExecuteQuery;
4+
5+
class Foo
6+
{
7+
public function syntaxError(\mysqli $mysqli)
8+
{
9+
$mysqli->execute_query('SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada');
10+
11+
mysqli_execute_query($mysqli, 'SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada');
12+
}
13+
}

tests/rules/data/syntax-error-in-query-function.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,4 @@ public function conditionalSyntaxError(\mysqli $mysqli)
3838

3939
mysqli_query($mysqli, $query);
4040
}
41-
42-
public function mysqli_execute_query(\mysqli $mysqli)
43-
{
44-
mysqli_execute_query($mysqli, 'SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada');
45-
}
4641
}

tests/rules/data/syntax-error-in-query-method.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,4 @@ public function conditionalSyntaxErrorInQueryUnion(PDO $pdo)
117117

118118
$pdo->query('SELECT email, adaid FROM ada '.$add.' LIMIT 1', PDO::FETCH_ASSOC);
119119
}
120-
121-
public function mysqliExecuteQuery(\mysqli $mysqli)
122-
{
123-
$mysqli->execute_query('SELECT email adaid WHERE gesperrt freigabe1u1 FROM ada');
124-
}
125120
}

0 commit comments

Comments
 (0)