Completed
Push — master ( 96c671...2e6f66 )
by Roma
01:37
created

Example.php (45 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
class Message {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
    /**
6
     * @var int $messageId
7
     */
8
    private $messageId;
0 ignored issues
show
The property $messageId is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
9
10
    /**
11
     * @var null|User $from
12
     */
13
    private $from;
0 ignored issues
show
The property $from is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
15
    /**
16
     * @var int $date
17
     */
18
    private $date;
0 ignored issues
show
The property $date is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
19
20
    /**
21
     * @var Chat $chat
22
     */
23
    private $chat;
0 ignored issues
show
The property $chat is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
24
25
    /**
26
     * @var null|User $forwardFrom
27
     */
28
    private $forwardFrom;
0 ignored issues
show
The property $forwardFrom is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
29
30
    /**
31
     * @var null|Chat $forwardFromChat
32
     */
33
    private $forwardFromChat;
0 ignored issues
show
The property $forwardFromChat is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
34
35
    /**
36
     * @var null|int $forwardFromMessageId
37
     */
38
    private $forwardFromMessageId;
0 ignored issues
show
The property $forwardFromMessageId is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
39
40
    /**
41
     * @var null|int $forwardDate
42
     */
43
    private $forwardDate;
0 ignored issues
show
The property $forwardDate is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
44
45
    /**
46
     * @var null|Message $replyToMessage
47
     */
48
    private $replyToMessage;
0 ignored issues
show
The property $replyToMessage is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
49
50
    /**
51
     * @var null|int $editDate
52
     */
53
    private $editDate;
0 ignored issues
show
The property $editDate is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
54
55
    /**
56
     * @var null|string $text
57
     */
58
    private $text;
0 ignored issues
show
The property $text is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
59
60
    /**
61
     * @var null|Message[] $entities
62
     */
63
    private $entities;
0 ignored issues
show
The property $entities is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
64
65
    /**
66
     * @var null|Audio $audio
67
     */
68
    private $audio;
0 ignored issues
show
The property $audio is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
69
70
    /**
71
     * @var null|Document $document
72
     */
73
    private $document;
0 ignored issues
show
The property $document is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
74
75
    /**
76
     * @var null|Game $game
77
     */
78
    private $game;
0 ignored issues
show
The property $game is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
79
80
    /**
81
     * @var null|PhotoSize[] $photo
82
     */
83
    private $photo;
0 ignored issues
show
The property $photo is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
84
85
    /**
86
     * @var null|Sticker $sticker
87
     */
88
    private $sticker;
0 ignored issues
show
The property $sticker is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
89
90
    /**
91
     * @var null|Video $video
92
     */
93
    private $video;
0 ignored issues
show
The property $video is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
94
95
    /**
96
     * @var null|Voice $voice
97
     */
98
    private $voice;
0 ignored issues
show
The property $voice is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
99
100
    /**
101
     * @var null|VideoNote $videoNote
102
     */
103
    private $videoNote;
0 ignored issues
show
The property $videoNote is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
104
105
    /**
106
     * @var null|User[] $newChatMembers
107
     */
108
    private $newChatMembers;
0 ignored issues
show
The property $newChatMembers is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
109
110
    /**
111
     * @var null|string $caption
112
     */
113
    private $caption;
0 ignored issues
show
The property $caption is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
114
115
    /**
116
     * @var null|Contact $contact
117
     */
118
    private $contact;
0 ignored issues
show
The property $contact is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
119
120
    /**
121
     * @var null|Location $location
122
     */
123
    private $location;
0 ignored issues
show
The property $location is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
124
125
    /**
126
     * @var null|Venue $venue
127
     */
128
    private $venue;
0 ignored issues
show
The property $venue is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
129
130
    /**
131
     * @var null|User $newChatMember
132
     */
133
    private $newChatMember;
0 ignored issues
show
The property $newChatMember is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
134
135
    /**
136
     * @var null|User $leftChatMember
137
     */
138
    private $leftChatMember;
0 ignored issues
show
The property $leftChatMember is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
139
140
    /**
141
     * @var null|string $newChatTitle
142
     */
143
    private $newChatTitle;
0 ignored issues
show
The property $newChatTitle is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
144
145
    /**
146
     * @var null|PhotoSize[] $newChatPhoto
147
     */
148
    private $newChatPhoto;
0 ignored issues
show
The property $newChatPhoto is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
149
150
    /**
151
     * @var null|bool $deleteChatPhoto
152
     */
153
    private $deleteChatPhoto;
0 ignored issues
show
The property $deleteChatPhoto is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
154
155
    /**
156
     * @var null|bool $groupChatCreated
157
     */
158
    private $groupChatCreated;
0 ignored issues
show
The property $groupChatCreated is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
159
160
    /**
161
     * @var null|bool $supergroupChatCreated
162
     */
163
    private $supergroupChatCreated;
0 ignored issues
show
The property $supergroupChatCreated is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
164
165
    /**
166
     * @var null|bool $channelChatCreated
167
     */
168
    private $channelChatCreated;
0 ignored issues
show
The property $channelChatCreated is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
169
170
    /**
171
     * @var null|int $migrateToChatId
172
     */
173
    private $migrateToChatId;
0 ignored issues
show
The property $migrateToChatId is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
174
175
    /**
176
     * @var null|int $migrateFromChatId
177
     */
178
    private $migrateFromChatId;
0 ignored issues
show
The property $migrateFromChatId is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
179
180
    /**
181
     * @var null|Message $pinnedMessage
182
     */
183
    private $pinnedMessage;
0 ignored issues
show
The property $pinnedMessage is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
184
185
    /**
186
     * @var null|Invoice $invoice
187
     */
188
    private $invoice;
0 ignored issues
show
The property $invoice is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
189
190
    /**
191
     * @var null|SuccessfulPayment $successfulPayment
192
     */
193
    private $successfulPayment;
0 ignored issues
show
The property $successfulPayment is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
194
195
    /**
196
     * @var null|string $authorSignature
197
     */
198
    private $authorSignature;
0 ignored issues
show
The property $authorSignature is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
199
200
    /**
201
     * @var null|string $forwardSignature
202
     */
203
    private $forwardSignature;
0 ignored issues
show
The property $forwardSignature is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
204
205
206
    /**
207
     * @param array $data
208
     */
209
    public function __construct(array $data = array()) {
210
211
        $scheme = array(
212
            'message_id'              => true,
213
            'from'                    => array(
214
                'value'   => User::class,
215
                'require' => false
216
            ),
217
            'date'                    => true,
218
            'chat'                    => array(
219
                'value'   => Chat::class,
220
                'require' => true
221
            ),
222
            'forward_from'            => array(
223
                'value'   => User::class,
224
                'require' => false
225
            ),
226
            'forward_from_chat'       => array(
227
                'value'   => Chat::class,
228
                'require' => false
229
            ),
230
            'forward_from_message_id' => false,
231
            'forward_date'            => false,
232
            'reply_to_message'        => array(
233
                'value'   => Message::class,
234
                'require' => false
235
            ),
236
            'edit_date'               => false,
237
            'text'                    => false,
238
            'entities'                => array(
239
                'value'   => MessageEntity::class,
240
                'require' => false,
241
                'array'   => true
242
            ),
243
            'audio'                   => array(
244
                'value'   => Audio::class,
245
                'require' => false
246
            ),
247
            'document'                => array(
248
                'value'   => Document::class,
249
                'require' => false
250
            ),
251
            'game'                    => array(
252
                'value'   => Game::class,
253
                'require' => false
254
            ),
255
            'photo'                   => array(
256
                'value'   => PhotoSize::class,
257
                'require' => false,
258
                'array'   => true
259
            ),
260
            'sticker'                 => array(
261
                'value'   => Sticker::class,
262
                'require' => false
263
            ),
264
            'video'                   => array(
265
                'value'   => Video::class,
266
                'require' => false
267
            ),
268
            'video_note'              => array(
269
                'value'   => VideoNote::class,
270
                'require' => false
271
            ),
272
            'new_chat_members'        => array(
273
                'value'   => User::class,
274
                'require' => false,
275
                'array'   => true
276
            ),
277
            'voice'                   => array(
278
                'value'   => Voice::class,
279
                'require' => false
280
            ),
281
            'caption'                 => false,
282
            'contact'                 => array(
283
                'value'   => Contact::class,
284
                'require' => false
285
            ),
286
            'location'                => array(
287
                'value'   => Location::class,
288
                'require' => false
289
            ),
290
            'venue'                   => array(
291
                'value'   => Venue::class,
292
                'require' => false
293
            ),
294
            'new_chat_member'         => array(
295
                'value'   => User::class,
296
                'require' => false
297
            ),
298
            'left_chat_member'        => array(
299
                'value'   => User::class,
300
                'require' => false
301
            ),
302
            'new_chat_title'          => false,
303
            'new_chat_photo'          => array(
304
                'value'   => PhotoSize::class,
305
                'require' => false,
306
                'array'   => true
307
            ),
308
            'delete_chat_photo'       => false,
309
            'group_chat_created'      => false,
310
            'supergroup_chat_created' => false,
311
            'channel_chat_created'    => false,
312
            'migrate_to_chat_id'      => false,
313
            'migrate_from_chat_id'    => false,
314
            'pinned_message'          => array(
315
                'value'   => Message::class,
316
                'require' => false,
317
            ),
318
            'invoice'                 => array(
319
                'value'   => Invoice::class,
320
                'require' => false,
321
            ),
322
            'successful_payment'      => array(
323
                'value'   => SuccessfulPayment::class,
324
                'require' => false,
325
            ),
326
        );
327
    }
328
329
330
}
331
332
class Example {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
333
334
    /**
335
     * Camelizes a given string.
336
     *
337
     * Thank you: (https://github.com/symfony/property-access/blob/master/PropertyAccessor.php#L733)
338
     *
339
     * @param string $value
340
     * @return string
341
     */
342
    private function camelize($value) {
343
        return str_replace(' ', '', ucwords(str_replace('_', ' ', $value)));
344
    }
345
346
347
    private $scheme = array(
348
        'user' => User::class,
349
        'get'  => false,
350
        'chat' => false
351
    );
352
353
354
    private function check() {
355
356
    }
357
358
    private function checkNo() {
359
360
    }
361
362
363
    public function __construct(array $data = array()) {
364
365
366
        foreach ($allow as $key => $value) {
367
368
            if ($value) isset($data[$key]) {
0 ignored issues
show
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected '{'
Loading history...
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
369
370
            }
371
        }
372
373
        foreach ($data as $key => $value) {
374
            $this->{$key} = $value;
375
        }
376
    }
377
}
378