Skip to content

Commit c7b7126

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents e2a2b31 + 8f1b775 commit c7b7126

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Configs/JsonConfig.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace BitApps\WPKit\Configs;
4+
5+
final class JsonConfig
6+
{
7+
protected static $decodeAsArray = true;
8+
9+
public static function setDecodeAsArray($value)
10+
{
11+
static::$decodeAsArray = $value;
12+
}
13+
14+
public static function decodeAsArray()
15+
{
16+
return static::$decodeAsArray;
17+
}
18+
}

src/Http/Request/Request.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace BitApps\WPKit\Http\Request;
44

55
use ArrayAccess;
6+
use BitApps\WPKit\Configs\JsonConfig;
67
use BitApps\WPKit\Helpers\Arr;
78
use BitApps\WPKit\Helpers\JSON;
89
use BitApps\WPKit\Http\IpTool;
@@ -239,7 +240,7 @@ protected function setBody($body = [])
239240
strpos($this->contentType(), 'form-data') === false
240241
&& strpos($this->contentType(), 'x-www-form-urlencoded') === false
241242
) {
242-
$this->body = JSON::maybeDecode(file_get_contents('php://input'));
243+
$this->body = JSON::maybeDecode(file_get_contents('php://input'), JsonConfig::decodeAsArray());
243244
}
244245

245246
if (!empty($_POST)) {

0 commit comments

Comments
 (0)