Skip to content

Commit 06400fb

Browse files
committed
bug #46811 [DoctrineBridge] Fix comment for type on Query::setValue (middlewares) (l-vo)
This PR was merged into the 5.4 branch. Discussion ---------- [DoctrineBridge] Fix comment for type on Query::setValue (middlewares) | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | See #46810 and #46744 Commits ------- 928a754 [DoctrineBridge] Fix comment for type on Query::setValue (middlewares)
2 parents 78e4118 + 928a754 commit 06400fb

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

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

Lines 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

Lines 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy