Skip to content

Commit 49cb7b0

Browse files
committed
修复一些可能存在的数组键名是 int 类型时的错误 (#563)
* 修复缓存 setMultiple() 方法传参数组键名是数字 * 修复 * 修复一些可能存在的数组键名是 int 时的错误 * 修复一些可能存在的数组键名是 int 时的错误 * 优化代码 * 优化代码 * 格式化代码 # Conflicts: # dev/bootstrap.php # src/Cache/Handler/Memory.php # src/Cache/Handler/Redis.php # src/Cache/Handler/RequestContext.php # src/Components/grpc/src/Proxy/Http/GrpcHttpClient.php # src/Components/grpc/src/Proxy/Http/GrpcHttpProxy.php # src/Components/swoole/src/Cron/CronManager.php # src/Db/Drivers/TPdoStatement.php # tests/phpunit.xml
1 parent 5dbe394 commit 49cb7b0

File tree

35 files changed

+57
-50
lines changed

35 files changed

+57
-50
lines changed

src/Cache/Handler/Apcu.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function setMultiple($values, $ttl = null)
7878
$newValues = [];
7979
foreach ($values as $k => $v)
8080
{
81-
$newValues[$this->parseKey($k)] = $v;
81+
$newValues[$this->parseKey((string) $k)] = $v;
8282
}
8383

8484
return [] === apcu_store($newValues, null, (int) $ttl);

src/Cache/Handler/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function setMultiple($values, $ttl = null)
206206
}
207207
foreach ($values as $key => $value)
208208
{
209-
$result = $result && $this->set($key, $value, $ttl);
209+
$result = $result && $this->set((string) $key, $value, $ttl);
210210
}
211211

212212
return $result;

src/Cache/Handler/Redis.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function setMultiple($values, $ttl = null)
127127
}
128128
foreach ($setValues as $k => $v)
129129
{
130-
$setValues[$this->parseKey($k)] = $this->encode($v);
130+
$setValues[$this->parseKey((string) $k)] = $this->encode($v);
131131
}
132132
// ttl 支持 \DateInterval 格式
133133
if ($ttl instanceof \DateInterval)
@@ -140,7 +140,7 @@ public function setMultiple($values, $ttl = null)
140140
{
141141
foreach ($setValues as $k => $v)
142142
{
143-
$result = $result && $redis->expire($k, $ttl);
143+
$result = $result && $redis->expire((string) $k, $ttl);
144144
}
145145
}
146146

src/Cache/Handler/RedisHash.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ public function setMultiple($values, $ttl = null)
158158
$setValues = [];
159159
foreach ($_setValues as $k => $v)
160160
{
161+
$k = (string) $k;
161162
$this->parseKey($k, $member);
162163
$setValues[$k]['member'][] = $member;
163164
$setValues[$k]['value'][] = $this->encode($v);

src/Components/fpm/src/Http/Message/FpmResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ private function sendHeaders(): void
4747
{
4848
foreach ($headers as $name => $_)
4949
{
50-
header($name . ':' . $this->getHeaderLine($name));
50+
header($name . ':' . $this->getHeaderLine((string) $name));
5151
}
5252
}
5353
// cookie
5454
$cookieParams = $this->getCookieParams();
5555
if ($cookieParams)
5656
{
57-
foreach ($cookieParams as $name => $cookie)
57+
foreach ($cookieParams as $cookie)
5858
{
5959
setcookie($cookie['key'], $cookie['value'], ['expires' => $cookie['expire'] ?? 0, 'path' => $cookie['path'] ?? '/', 'domain' => $cookie['domain'] ?? '', 'secure' => $cookie['secure'] ?? false, 'httponly' => $cookie['httponly'] ?? false]);
6060
}

src/Components/grpc/src/Client/GrpcClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function send(string $package, string $service, string $name, \Google\Pro
167167
{
168168
foreach ($metadata as $k => $v)
169169
{
170-
$request = $request->withHeader($k, $v);
170+
$request = $request->withHeader((string) $k, $v);
171171
}
172172
}
173173

src/Components/jwt/src/Bean/JWT.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function getBuilderInstance(?string $name = null): Builder
122122
{
123123
foreach ($headers as $k => $v)
124124
{
125-
$builder->withHeader($k, $v);
125+
$builder->withHeader((string) $k, $v);
126126
}
127127
}
128128
$signer = $config->getSignerInstance();
@@ -154,7 +154,7 @@ public function getBuilderInstance(?string $name = null): Builder
154154
{
155155
foreach ($headers as $k => $v)
156156
{
157-
$builder->withHeader($k, $v);
157+
$builder->withHeader((string) $k, $v);
158158
}
159159
}
160160
}

src/Components/pgsql/src/Db/Query/Builder/BaseBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function parseField(array $fields): string
2121
$query = $this->query;
2222
foreach ($fields as $k => $v)
2323
{
24-
if (is_numeric($k))
24+
if (\is_int($k))
2525
{
2626
if ($v instanceof Field)
2727
{

src/Components/pgsql/src/Db/Query/Builder/InsertBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function build(...$args): string
3434
{
3535
if ($v instanceof \Imi\Db\Query\Raw)
3636
{
37-
if (!is_numeric($k))
37+
if (!\is_int($k))
3838
{
3939
$fields[] = $query->fieldQuote($k);
4040
$valueParams[] = $v->toString($query);

src/Components/pgsql/src/Db/Query/Builder/ReplaceBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function build(...$args): string
3535
{
3636
if ($v instanceof \Imi\Db\Query\Raw)
3737
{
38-
if (is_numeric($k))
38+
if (\is_int($k))
3939
{
4040
$setStrs[] = $v->toString($query);
4141
}

0 commit comments

Comments
 (0)