1 | <?php |
||
24 | class EditMessageText extends TelegramMethods |
||
25 | { |
||
26 | /** |
||
27 | * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target |
||
28 | * channel (in the format @channelusername) |
||
29 | * @var string |
||
30 | */ |
||
31 | public $chat_id = ''; |
||
32 | |||
33 | /** |
||
34 | * Required if inline_message_id is not specified. Unique identifier of the sent message |
||
35 | * @var int |
||
36 | */ |
||
37 | public $message_id = 0; |
||
38 | |||
39 | /** |
||
40 | * Required if chat_id and message_id are not specified. Identifier of the inline message |
||
41 | * @var string |
||
42 | */ |
||
43 | public $inline_message_id = ''; |
||
44 | |||
45 | /** |
||
46 | * New text of the message |
||
47 | * @var string |
||
48 | */ |
||
49 | public $text = ''; |
||
50 | |||
51 | /** |
||
52 | * Optional. Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs |
||
53 | * in your bot's message |
||
54 | * @var string |
||
55 | */ |
||
56 | public $parse_mode = ''; |
||
57 | |||
58 | /** |
||
59 | * Optional. Disables link previews for links in this message |
||
60 | * @var boolean |
||
61 | */ |
||
62 | public $disable_web_page_preview = false; |
||
63 | |||
64 | /** |
||
65 | * Optional. A JSON-serialized object for an inline keyboard. |
||
66 | * @var Markup |
||
67 | */ |
||
68 | public $reply_markup; |
||
69 | |||
70 | 4 | public function getMandatoryFields(): array |
|
76 | |||
77 | public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes |
||
89 | } |
||
90 |
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.
Let’s take a look at an example:
As you can see in this example, the array
$myArray
is initialized the first time when the foreach loop is entered. You can also see that the value of thebar
key is only written conditionally; thus, its value might result from a previous iteration.This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.