1 | <?php |
||
27 | class EditMessageMedia extends TelegramMethods |
||
28 | { |
||
29 | /** |
||
30 | * Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target |
||
31 | * channel (in the format @channelusername) |
||
32 | * @var string |
||
33 | */ |
||
34 | public $chat_id = ''; |
||
35 | |||
36 | /** |
||
37 | * Required if inline_message_id is not specified. Unique identifier of the sent message |
||
38 | * @var int |
||
39 | */ |
||
40 | public $message_id = 0; |
||
41 | |||
42 | /** |
||
43 | * Required if chat_id and message_id are not specified. Identifier of the inline message |
||
44 | * @var string |
||
45 | */ |
||
46 | public $inline_message_id = ''; |
||
47 | |||
48 | /** |
||
49 | * A JSON-serialized object for a new media content of the message |
||
50 | * @var InputMedia |
||
51 | */ |
||
52 | public $media; |
||
53 | |||
54 | /** |
||
55 | * Optional. A JSON-serialized object for an inline keyboard. |
||
56 | * @var Markup |
||
57 | */ |
||
58 | public $reply_markup; |
||
59 | |||
60 | public function getMandatoryFields(): array |
||
66 | |||
67 | /** |
||
68 | * @param TelegramRawData $data |
||
69 | * @param LoggerInterface $logger |
||
70 | * @return TelegramTypes |
||
71 | * @throws InvalidResultType |
||
72 | */ |
||
73 | public static function bindToObject(TelegramResponse $data, LoggerInterface $logger): TelegramTypes |
||
88 | } |
||
89 |
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.