mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-06 01:51:51 +00:00
Player: do not assign maybe-false result of json_encode() to ModalFormRequestPacket
fixes a phpstan error on l7
This commit is contained in:
parent
6a7b77fee2
commit
a8ec51daac
@ -3515,13 +3515,14 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
|||||||
* Sends a Form to the player, or queue to send it if a form is already open.
|
* Sends a Form to the player, or queue to send it if a form is already open.
|
||||||
*/
|
*/
|
||||||
public function sendForm(Form $form) : void{
|
public function sendForm(Form $form) : void{
|
||||||
|
$formData = json_encode($form);
|
||||||
|
if($formData === false){
|
||||||
|
throw new \InvalidArgumentException("Failed to encode form JSON: " . json_last_error_msg());
|
||||||
|
}
|
||||||
$id = $this->formIdCounter++;
|
$id = $this->formIdCounter++;
|
||||||
$pk = new ModalFormRequestPacket();
|
$pk = new ModalFormRequestPacket();
|
||||||
$pk->formId = $id;
|
$pk->formId = $id;
|
||||||
$pk->formData = json_encode($form);
|
$pk->formData = $formData;
|
||||||
if($pk->formData === false){
|
|
||||||
throw new \InvalidArgumentException("Failed to encode form JSON: " . json_last_error_msg());
|
|
||||||
}
|
|
||||||
if($this->dataPacket($pk)){
|
if($this->dataPacket($pk)){
|
||||||
$this->forms[$id] = $form;
|
$this->forms[$id] = $form;
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,6 @@ parameters:
|
|||||||
count: 1
|
count: 1
|
||||||
path: ../../../src/pocketmine/Player.php
|
path: ../../../src/pocketmine/Player.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Property pocketmine\\\\network\\\\mcpe\\\\protocol\\\\ModalFormRequestPacket\\:\\:\\$formData \\(string\\) does not accept string\\|false\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: ../../../src/pocketmine/Player.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Only booleans are allowed in an if condition, bool\\|int given\\.$#"
|
message: "#^Only booleans are allowed in an if condition, bool\\|int given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user