Fix: Handle null content in PlanResource::formatContent method
Some checks failed
Docker Build and Publish / build (push) Has been cancelled

- Fix deprecated warning when passing null to str_replace() function\n- Use null coalescing operator to provide empty string as default value\n- Comply with PHP 8.2+ type requirements
This commit is contained in:
xboard 2025-02-25 19:14:19 +08:00
parent 220d306a54
commit 5a08754735
5 changed files with 10 additions and 3 deletions

View File

@ -27,6 +27,7 @@ class ClientController extends Controller
'vmess' => '[vmess]',
'trojan' => '[trojan]',
'tuic' => '[tuic]',
'socks' => '[socks]',
];
// 支持hy2 的客户端版本列表

View File

@ -147,6 +147,9 @@ class UniProxyController extends Controller
'zero_rtt_handshake' => false,
'heartbeat' => "3s",
],
'socks' => [
'server_port' => (int) $serverPort,
],
default => []
};

View File

@ -52,6 +52,8 @@ class ServerSave extends FormRequest
'reality_settings.public_key' => 'nullable|string',
'reality_settings.private_key' => 'nullable|string',
'reality_settings.short_id' => 'nullable|string',
],
'socks' => [
]
];

View File

@ -80,7 +80,7 @@ class PlanResource extends JsonResource
*/
protected function formatContent(): string
{
$content = $this->resource['content'];
$content = $this->resource['content'] ?? '';
$replacements = [
'{{transfer}}' => $this->resource['transfer_enable'],

View File

@ -18,7 +18,7 @@ class Server extends Model
public const TYPE_VMESS = 'vmess';
public const TYPE_TUIC = 'tuic';
public const TYPE_SHADOWSOCKS = 'shadowsocks';
public const TYPE_SOCKS = 'socks';
public const STATUS_OFFLINE = 0;
public const STATUS_ONLINE_NO_PUSH = 1;
public const STATUS_ONLINE = 2;
@ -52,6 +52,7 @@ class Server extends Model
self::TYPE_VMESS,
self::TYPE_TUIC,
self::TYPE_SHADOWSOCKS,
self::TYPE_SOCKS,
];
protected $table = 'v2_server';