Skip to content

Commit

Permalink
Strict PHP inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
unreal4u committed Jan 8, 2017
1 parent 57255e6 commit 46abfbc
Show file tree
Hide file tree
Showing 42 changed files with 84 additions and 62 deletions.
2 changes: 1 addition & 1 deletion src/Abstracts/CustomType.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
*/
abstract class CustomType extends TelegramTypes
{
public $data = null;
public $data = [];
}
3 changes: 2 additions & 1 deletion src/Abstracts/TelegramMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function performSpecialConditions(): TelegramMethods
* Exports the class to an array in order to send it to the Telegram servers without extra fields that we don't need
*
* @return array
* @throws MissingMandatoryField
*/
final public function export(): array
{
Expand All @@ -77,7 +78,7 @@ final public function export(): array
$cleanObject = new $this();
foreach ($cleanObject as $fieldId => $value) {
if ($this->$fieldId === $cleanObject->$fieldId) {
if (in_array($fieldId, $mandatoryFields)) {
if (in_array($fieldId, $mandatoryFields, true)) {
throw new MissingMandatoryField(sprintf(
'The field "%s" is mandatory and empty, please correct',
$fieldId
Expand Down
2 changes: 2 additions & 0 deletions src/Interfaces/CustomArrayType.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types = 1);

namespace unreal4u\TelegramAPI\Interfaces;

use Psr\Log\LoggerInterface;
Expand Down
1 change: 0 additions & 1 deletion src/Telegram/Methods/DeleteWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData;
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
use unreal4u\TelegramAPI\Telegram\Types\User;

/**
* Use this method to remove webhook integration if you decide to switch back to getUpdates. Returns True on success.
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Methods/GetFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class GetFile extends TelegramMethods
/**
* This call will return an array with updates, so call up a custom type to do this
*
* @param array $data
* @param TelegramRawData $data
* @param LoggerInterface $logger
* @return TelegramTypes
*/
Expand Down
3 changes: 0 additions & 3 deletions src/Telegram/Methods/GetGameScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
use Psr\Log\LoggerInterface;
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
use unreal4u\TelegramAPI\Exceptions\InvalidResultType;
use unreal4u\TelegramAPI\InternalFunctionality\TelegramRawData;
use unreal4u\TelegramAPI\Telegram\Types\Custom\GameHighScoreArray;
use unreal4u\TelegramAPI\Telegram\Types\Custom\ResultBoolean;
use unreal4u\TelegramAPI\Telegram\Types\Message;

/**
* Use this method to get data for high score tables. Will return the score of the specified user and several of his
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Methods/GetUserProfilePhotos.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class GetUserProfilePhotos extends TelegramMethods
/**
* This call will return an array with updates, so call up a custom type to do this
*
* @param array $data
* @param TelegramRawData $data
* @param LoggerInterface $logger
* @return TelegramTypes
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Telegram/Methods/SendAudio.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace unreal4u\TelegramAPI\Telegram\Methods;

use unreal4u\TelegramAPI\Abstracts\KeyboardMethods;
use unreal4u\TelegramAPI\Abstracts\TelegramMethods;
use unreal4u\TelegramAPI\Telegram\Types\Custom\InputFile;

Expand Down Expand Up @@ -80,9 +81,9 @@ class SendAudio extends TelegramMethods
/**
* Optional. Additional interface options. A JSON-serialized object for a custom reply keyboard, instructions to
* hide keyboard or to force a reply from the user
* @var null
* @var KeyboardMethods
*/
public $reply_markup = null;
public $reply_markup;

public function getMandatoryFields(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Methods/SendGame.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SendGame extends TelegramMethods
* hide keyboard or to force a reply from the user.
* @var Markup
*/
public $reply_markup = null;
public $reply_markup;

public function getMandatoryFields(): array
{
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/Custom/ChatMembersArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
*/
class ChatMembersArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
foreach ($data as $id => $chatMember) {
$this->data[$id] = new ChatMember($chatMember, $logger);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/Custom/GameHighScoreArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
*/
class GameHighScoreArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
foreach ($data as $id => $gameHighScore) {
$this->data[$id] = new GameHighScore($gameHighScore, $logger);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/Custom/InlineKeyboardButtonArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
*/
class InlineKeyboardButtonArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
foreach ($data as $rowId => $button) {
$this->data[$rowId][] = new Button($data, $logger);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Telegram/Types/Custom/InputFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class InputFile
* The actual stream to the file
* @var resource
*/
private $stream = null;
private $stream;

public function __construct(string $path)
{
Expand All @@ -36,6 +36,7 @@ public function __construct(string $path)
* Will setup the stream
*
* @return InputFile
* @throws FileNotReadable
*/
private function setStream(): InputFile
{
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/Custom/KeyboardButtonArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
*/
class KeyboardButtonArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
foreach ($data as $rowId => $button) {
$this->data[$rowId][] = new KeyboardButton($data, $logger);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/Custom/MessageEntityArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
*/
class MessageEntityArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
foreach ($data as $id => $messageEntity) {
$this->data[$id] = new MessageEntity($messageEntity, $logger);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/Custom/PhotoSizeArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
*/
class PhotoSizeArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
foreach ($data as $id => $photo) {
$this->data[$id] = new PhotoSize($photo, $logger);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/Custom/UpdatesArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
*/
class UpdatesArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
foreach ($data as $telegramResponse) {
// Create an actual Update object and fill the array
$this->data[] = new Update($telegramResponse, $logger);
Expand Down
5 changes: 2 additions & 3 deletions src/Telegram/Types/Custom/UserProfilePhotosArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
*/
class UserProfilePhotosArray extends CustomType implements CustomArrayType
{
public $data = [];

public function __construct(array $data = null, LoggerInterface $logger = null)
{
if (!empty($data)) {
if (count($data) !== 0) {
$i = 0;
/** @var array $telegramResponse */
foreach ($data as $telegramResponse) {
foreach ($telegramResponse as $photoSize) {
// Create an actual PhotoSize object and fill the array
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Types/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Game extends TelegramTypes
* Optional. Animation that will be displayed in the game message in chats. Upload via BotFather
* @var Animation
*/
public $animation = null;
public $animation;

public function mapSubObjects(string $key, array $data): TelegramTypes
{
Expand Down
4 changes: 1 addition & 3 deletions src/Telegram/Types/GameHighScore.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
namespace unreal4u\TelegramAPI\Telegram\Types;

use unreal4u\TelegramAPI\Abstracts\TelegramTypes;
use unreal4u\TelegramAPI\Telegram\Types\Custom\MessageEntityArray;
use unreal4u\TelegramAPI\Telegram\Types\Custom\PhotoSizeArray;

/**
* This object represents one row of the high scores table for a game
Expand All @@ -25,7 +23,7 @@ class GameHighScore extends TelegramTypes

/**
* User
* @var string
* @var User
*/
public $user;

Expand Down
5 changes: 3 additions & 2 deletions src/Telegram/Types/Inline/Query/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ abstract class Result extends TelegramTypes
* Optional. Inline keyboard attached to the message
* @var Markup
*/
public $reply_markup = null;
public $reply_markup;

protected function mapSubObjects(string $key, array $data): TelegramTypes
{
Expand Down Expand Up @@ -85,6 +85,7 @@ public function getMandatoryFields(): array
*
* @see TelegramMethods::export
* @return array
* @throws \unreal4u\TelegramAPI\Exceptions\MissingMandatoryField
*/
public function export(): array
{
Expand All @@ -94,7 +95,7 @@ public function export(): array
$cleanObject = new $this();
foreach ($cleanObject as $fieldId => $value) {
if ($fieldId !== 'type' && $this->$fieldId === $cleanObject->$fieldId) {
if (in_array($fieldId, $mandatoryFields)) {
if (in_array($fieldId, $mandatoryFields, true)) {
throw new MissingMandatoryField(sprintf(
'The field "%s" is mandatory and empty, please correct',
$fieldId
Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ class Article extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ class Audio extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Audio.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ class Audio extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ class Document extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Gif.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ class Gif extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Mpeg4Gif.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ class Mpeg4Gif extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ class Photo extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Sticker.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class Sticker extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ class Video extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Cached/Voice.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ class Voice extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ class Contact extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ class Document extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Gif.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ class Gif extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ class Location extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Mpeg4Gif.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,5 @@ class Mpeg4Gif extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Photo.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ class Photo extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
2 changes: 1 addition & 1 deletion src/Telegram/Types/Inline/Query/Result/Venue.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ class Venue extends Result
* Optional. Content of the message to be sent instead of the audio/document/voice message/video/sticker/etc.
* @var InputMessageContent
*/
public $input_message_content = null;
public $input_message_content;
}
Loading

0 comments on commit 46abfbc

Please sign in to comment.