Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 928a754

Browse filesBrowse files
committed
[DoctrineBridge] Fix comment for type on Query::setValue (middlewares)
1 parent b893a71 commit 928a754
Copy full SHA for 928a754

File tree

2 files changed

+27
-7
lines changed
Filter options

2 files changed

+27
-7
lines changed

‎src/Symfony/Bridge/Doctrine/Middleware/Debug/Query.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Middleware/Debug/Query.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public function setParam($param, &$variable, int $type): void
5959
}
6060

6161
/**
62-
* @param string|int $param
63-
* @param string|int|float|bool|null $value
62+
* @param string|int $param
63+
* @param mixed $value
6464
*/
6565
public function setValue($param, $value, int $type): void
6666
{

‎src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Middleware/Debug/MiddlewareTest.php
+25-5Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\DBAL\DriverManager;
1818
use Doctrine\DBAL\ParameterType;
1919
use Doctrine\DBAL\Result;
20+
use Doctrine\DBAL\Types\Types;
2021
use PHPUnit\Framework\TestCase;
2122
use Symfony\Bridge\Doctrine\Middleware\Debug\DebugDataHolder;
2223
use Symfony\Bridge\Doctrine\Middleware\Debug\Middleware;
@@ -61,12 +62,23 @@ private function init(bool $withStopwatch = true): void
6162
id INTEGER PRIMARY KEY,
6263
name TEXT NOT NULL,
6364
price REAL NOT NULL,
64-
stock INTEGER NOT NULL
65+
stock INTEGER NOT NULL,
66+
picture BLOB NULL,
67+
tags TEXT NULL,
68+
created_at TEXT NULL
6569
);
6670
EOT
6771
);
6872
}
6973

74+
private function getResourceFromString(string $str)
75+
{
76+
$res = fopen('php://temp', 'r+');
77+
fwrite($res, $str);
78+
79+
return $res;
80+
}
81+
7082
public function provideExecuteMethod(): array
7183
{
7284
return [
@@ -107,18 +119,26 @@ public function testWithValueBound(callable $executeMethod)
107119
{
108120
$this->init();
109121

110-
$stmt = $this->conn->prepare('INSERT INTO products(name, price, stock) VALUES (?, ?, ?)');
122+
$sql = <<<EOT
123+
INSERT INTO products(name, price, stock, picture, tags, created_at)
124+
VALUES (?, ?, ?, ?, ?, ?)
125+
EOT;
126+
127+
$stmt = $this->conn->prepare($sql);
111128
$stmt->bindValue(1, 'product1');
112129
$stmt->bindValue(2, 12.5);
113130
$stmt->bindValue(3, 5, ParameterType::INTEGER);
131+
$stmt->bindValue(4, $res = $this->getResourceFromString('mydata'), ParameterType::BINARY);
132+
$stmt->bindValue(5, ['foo', 'bar'], Types::SIMPLE_ARRAY);
133+
$stmt->bindValue(6, new \DateTime('2022-06-12 11:00:00'), Types::DATETIME_MUTABLE);
114134

115135
$executeMethod($stmt);
116136

117137
$debug = $this->debugDataHolder->getData()['default'] ?? [];
118138
$this->assertCount(2, $debug);
119-
$this->assertSame('INSERT INTO products(name, price, stock) VALUES (?, ?, ?)', $debug[1]['sql']);
120-
$this->assertSame(['product1', 12.5, 5], $debug[1]['params']);
121-
$this->assertSame([ParameterType::STRING, ParameterType::STRING, ParameterType::INTEGER], $debug[1]['types']);
139+
$this->assertSame($sql, $debug[1]['sql']);
140+
$this->assertSame(['product1', 12.5, 5, $res, 'foo,bar', '2022-06-12 11:00:00'], $debug[1]['params']);
141+
$this->assertSame([ParameterType::STRING, ParameterType::STRING, ParameterType::INTEGER, ParameterType::BINARY, ParameterType::STRING, ParameterType::STRING], $debug[1]['types']);
122142
$this->assertGreaterThan(0, $debug[1]['executionMS']);
123143
}
124144

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.