Skip to content

Commit

Permalink
Minor opcode cache optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
unreal4u committed Jan 2, 2018
1 parent a85c21b commit b496ca8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/Abstracts/TelegramMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ final protected function mandatoryUserOrInlineMessageId(array &$return): array
* @param TelegramTypes $replyMarkup
* @return TelegramTypes
*/
final private function formatReplyMarkup(TelegramTypes $replyMarkup): TelegramTypes
private function formatReplyMarkup(TelegramTypes $replyMarkup): TelegramTypes
{
if ($replyMarkup instanceof Markup) {
$replyMarkup->inline_keyboard = $this->getArrayFromKeyboard($replyMarkup->inline_keyboard);
Expand All @@ -132,7 +132,7 @@ final private function formatReplyMarkup(TelegramTypes $replyMarkup): TelegramTy
return $replyMarkup;
}

final private function getArrayFromKeyboard(array $keyboardArray): array
private function getArrayFromKeyboard(array $keyboardArray): array
{
$finalCleanArray = [];

Expand Down Expand Up @@ -161,7 +161,7 @@ final private function getArrayFromKeyboard(array $keyboardArray): array
* @param TelegramTypes $markupItem
* @return array
*/
final private function exportReplyMarkupItem(TelegramTypes $markupItem): array
private function exportReplyMarkupItem(TelegramTypes $markupItem): array
{
$finalArray = [];
$cleanObject = new $markupItem;
Expand Down
4 changes: 2 additions & 2 deletions src/Abstracts/TelegramTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final protected function populateObject(array $data = []): TelegramTypes
{
foreach ($data as $key => $value) {
$candidateKey = null;
if (is_array($value)) {
if (\is_array($value)) {
$this->logger->debug('Array detected, mapping subobjects for key', ['key' => $key]);
$candidateKey = $this->mapSubObjects($key, $value);
}
Expand Down Expand Up @@ -76,7 +76,7 @@ protected function mapSubObjects(string $key, array $data): TelegramTypes
$key,
'https://github.com/unreal4u/telegram-api/issues'
), [
'object' => get_class($this),
'object' => \get_class($this),
'data' => $data,
]);
}
Expand Down
6 changes: 3 additions & 3 deletions src/InternalFunctionality/PostOptionsConstructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function constructOptions(TelegramMethods $method): array
return [
'headers' => [
'Content-Type' => 'application/x-www-form-urlencoded',
'Content-Length' => strlen($body),
'Content-Length' => \strlen($body),
'User-Agent' => 'PHP7+ Bot API',
],
'body' => $body
Expand All @@ -84,7 +84,7 @@ private function checkIsMultipart(TelegramMethods $method): array
$return = [];

foreach ($method as $key => $value) {
if (is_object($value) && $value instanceof InputFile) {
if (\is_object($value) && $value instanceof InputFile) {
$this->logger->debug('About to send a file, so changing request to use multi-part instead');
// If we are about to send a file, we must use the multipart/form-data way
$this->formType = 'multipart/form-data';
Expand Down Expand Up @@ -131,7 +131,7 @@ public function constructMultipartOptions(array $data, string $fileKeyName, $str
$array = [
'headers' => [
'Content-Type' => 'multipart/form-data; boundary="' . $builder->getBoundary() . '"',
'Content-Length' => strlen($body)
'Content-Length' => \strlen($body)
],
'body' => $body
];
Expand Down
2 changes: 1 addition & 1 deletion src/InternalFunctionality/TelegramDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(TelegramResponse $response)

// Same with file length
$this->file_size = !empty($headers['Content-Length']) ? $headers['Content-Length']
: strlen($response->getRawData());
: \strlen($response->getRawData());
$this->contents = $response->getRawData();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Telegram/Types/Custom/InputFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(string $path)
private function setStream(): InputFile
{
if (is_readable($this->path)) {
$this->stream = fopen($this->path, 'r');
$this->stream = fopen($this->path, 'rb');
} else {
throw new FileNotReadable(sprintf('Can not read local file "%s", please check', $this->path));
}
Expand Down
3 changes: 1 addition & 2 deletions src/Telegram/Types/Custom/ResultBoolean.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public function __toString()
{
if ($this->data === true) {
return '1';
} else {
return '0';
}
return '0';
}
}

0 comments on commit b496ca8

Please sign in to comment.