Issues (127)

src/Messages.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * This phpFile is auto-generated.
5
 */
6
7
declare(strict_types=1);
8
9
namespace PHPTdGram\Schema;
10
11
/**
12
 * Contains a list of messages.
13
 */
14
class Messages extends TdObject
15
{
16
    public const TYPE_NAME = 'messages';
17
18
    /**
19
     * Approximate total count of messages found.
20
     */
21
    protected int $totalCount;
22
23
    /**
24
     * List of messages; messages may be null.
25
     *
26
     * @var Message[]|null
27
     */
28
    protected ?array $messages;
29
30
    public function __construct(int $totalCount, ?array $messages)
31
    {
32
        $this->totalCount = $totalCount;
33
        $this->messages   = $messages;
34
    }
35
36
    public static function fromArray(array $array): Messages
37
    {
38
        return new static(
39
            $array['total_count'],
40
            (isset($array['messages']) ? array_map(fn ($x) => TdSchemaRegistry::fromArray($x), $array['messages']) : null),
41
        );
42
    }
43
44
    public function typeSerialize(): array
45
    {
46
        return [
47
            '@type'                                     => static::TYPE_NAME,
48
            'total_count'                               => $this->totalCount,
49
            (isset($this->messages) ? array_map(fn ($x) => $x->typeSerialize(), $this->messages) : null),
0 ignored issues
show
It seems like $this->messages can also be of type null; however, parameter $arr1 of array_map() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

49
            (isset($this->messages) ? array_map(fn ($x) => $x->typeSerialize(), /** @scrutinizer ignore-type */ $this->messages) : null),
Loading history...
50
        ];
51
    }
52
53
    public function getTotalCount(): int
54
    {
55
        return $this->totalCount;
56
    }
57
58
    public function getMessages(): ?array
59
    {
60
        return $this->messages;
61
    }
62
}
63