From 28cdbef38cf38794f5a261f6d80aabce3e4a36ff Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 14 Aug 2021 16:03:57 +0200 Subject: [PATCH] cs-fix --- .php_cs.dist | 12 ----- src/FileId.php | 4 +- .../PhotoSizeSourceDialogPhoto.php | 3 +- src/UniqueFileId.php | 46 +++++++++---------- src/type.php | 2 +- 5 files changed, 27 insertions(+), 40 deletions(-) delete mode 100644 .php_cs.dist diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 859c6f0..0000000 --- a/.php_cs.dist +++ /dev/null @@ -1,12 +0,0 @@ -getFinder() - ->in(__DIR__ . '/src') - ->in(__DIR__ . '/tests'); - -$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__; - -$config->setCacheFile($cacheDir . '/.php_cs.cache'); - -return $config; diff --git a/src/FileId.php b/src/FileId.php index 79acc48..068e911 100644 --- a/src/FileId.php +++ b/src/FileId.php @@ -221,7 +221,7 @@ class FileId case PHOTOSIZE_SOURCE_FULL_LEGACY: $fileId .= packLong($this->getVolumeId()); $fileId .= packLong($photoSize->getSecret()); - $fileId .= pack('l',$this->getLocalId()); + $fileId .= \pack('l', $this->getLocalId()); break; case PHOTOSIZE_SOURCE_THUMBNAIL: $fileId .= \pack('Va4', $photoSize->getThumbFileType(), $photoSize->getThumbType()); @@ -241,7 +241,7 @@ class FileId case PHOTOSIZE_SOURCE_STICKERSET_THUMBNAIL_VERSION: $fileId .= packLong($photoSize->getStickerSetId()); $fileId .= packLong($photoSize->getStickerSetAccessHash()); - $fileId .= pack('l', $photoSize->getStickerSetVersion()); + $fileId .= \pack('l', $photoSize->getStickerSetVersion()); break; } if ($photoSize->getType() >= PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL_LEGACY && $photoSize->getType() <= PHOTOSIZE_SOURCE_STICKERSET_THUMBNAIL_LEGACY) { diff --git a/src/PhotoSizeSource/PhotoSizeSourceDialogPhoto.php b/src/PhotoSizeSource/PhotoSizeSourceDialogPhoto.php index 7614ea9..8bdfd90 100644 --- a/src/PhotoSizeSource/PhotoSizeSourceDialogPhoto.php +++ b/src/PhotoSizeSource/PhotoSizeSourceDialogPhoto.php @@ -20,7 +20,6 @@ namespace danog\Decoder\PhotoSizeSource; use danog\Decoder\PhotoSizeSource; -use const danog\Decoder\PHOTOSIZE_SOURCE_DIALOGPHOTO_BIG; use const danog\Decoder\PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL; use const danog\Decoder\PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL_LEGACY; @@ -96,6 +95,6 @@ class PhotoSizeSourceDialogPhoto extends PhotoSizeSource */ public function isSmallDialogPhoto(): bool { - return in_array($this->getType(), [PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL_LEGACY, PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL]); + return \in_array($this->getType(), [PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL_LEGACY, PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL]); } } diff --git a/src/UniqueFileId.php b/src/UniqueFileId.php index 909e806..3fdc8ad 100644 --- a/src/UniqueFileId.php +++ b/src/UniqueFileId.php @@ -52,19 +52,19 @@ class UniqueFileId */ private $_localId; /** - * Photo subtype + * Photo subtype. * * @var int */ private $_subType; /** - * Sticker set ID + * Sticker set ID. * * @var int */ private $_stickerSetId; /** - * Sticker set version + * Sticker set version. * * @var int */ @@ -107,12 +107,12 @@ class UniqueFileId $fileId .= packLong($this->getVolumeId()); $fileId .= \pack('l', $this->getLocalId()); } elseif ($this->hasStickerSetId()) { - $fileId .= chr($this->getSubType()); + $fileId .= \chr($this->getSubType()); $fileId .= packLong($this->getStickerSetId()); - $fileId .= pack('l', $this->getStickerSetVersion()); + $fileId .= \pack('l', $this->getStickerSetVersion()); } else { $fileId .= packLong($this->getId()); - $fileId .= chr($this->getSubType()); + $fileId .= \chr($this->getSubType()); } } elseif ($this->hasId()) { $fileId .= packLong($this->getId()); @@ -139,10 +139,10 @@ class UniqueFileId if (isset($resultArray['volume_id'])) { $result->setVolumeId($resultArray['volume_id']); $result->setLocalId($resultArray['local_id']); - } else if (isset($resultArray['id'])) { + } elseif (isset($resultArray['id'])) { $result->setId($resultArray['id']); $result->setSubType($resultArray['subType']); - } else if (isset($resultArray['sticker_set_id'])) { + } elseif (isset($resultArray['sticker_set_id'])) { $result->setStickerSetId($resultArray['sticker_set_id']); $result->setStickerSetVersion($resultArray['sticker_set_version']); $result->setSubType($resultArray['subType']); @@ -186,22 +186,22 @@ class UniqueFileId if ($fileId->hasVolumeId()) { $result->setVolumeId($fileId->getVolumeId()); $result->setLocalId($fileId->getLocalId()); - } else if ($fileId->hasId()) { + } elseif ($fileId->hasId()) { $result->setId($fileId->getId()); $photoSize = $fileId->getPhotoSizeSource(); if ($photoSize instanceof PhotoSizeSourceThumbnail) { $type = $photoSize->getThumbType(); if ($type === 'a') { - $type = chr(0); - } else if ($type === 'c') { - $type = chr(1); + $type = \chr(0); + } elseif ($type === 'c') { + $type = \chr(1); } else { - $type = chr(ord($type)+5); + $type = \chr(\ord($type)+5); } - $result->setSubType(ord($type)); - } else if ($photoSize instanceof PhotoSizeSourceDialogPhoto) { + $result->setSubType(\ord($type)); + } elseif ($photoSize instanceof PhotoSizeSourceDialogPhoto) { $result->setSubType($photoSize->isSmallDialogPhoto() ? 0 : 1); - } else if ($photoSize instanceof PhotoSizeSourceStickersetThumbnailVersion) { + } elseif ($photoSize instanceof PhotoSizeSourceStickersetThumbnailVersion) { $result->setSubType(2); $result->setStickerSetId($photoSize->getStickerSetId()); $result->setStickerSetVersion($photoSize->getStickerSetVersion()); @@ -386,7 +386,7 @@ class UniqueFileId } /** - * Get photo subtype + * Get photo subtype. * * @return int */ @@ -406,7 +406,7 @@ class UniqueFileId } /** - * Set photo subtype + * Set photo subtype. * * @param int $_subType Photo subtype * @@ -420,7 +420,7 @@ class UniqueFileId } /** - * Get sticker set ID + * Get sticker set ID. * * @return int */ @@ -441,7 +441,7 @@ class UniqueFileId } /** - * Set sticker set ID + * Set sticker set ID. * * @param int $_stickerSetId Sticker set ID * @@ -455,7 +455,7 @@ class UniqueFileId } /** - * Get sticker set version + * Get sticker set version. * * @return int */ @@ -465,7 +465,7 @@ class UniqueFileId } /** - * Has sticker set version + * Has sticker set version. * * @return bool */ @@ -475,7 +475,7 @@ class UniqueFileId } /** - * Set sticker set version + * Set sticker set version. * * @param int $_stickerSetVersion Sticker set version * diff --git a/src/type.php b/src/type.php index 1be67fc..d938e8e 100644 --- a/src/type.php +++ b/src/type.php @@ -631,7 +631,7 @@ function internalDecodeUnique(string $fileId): array $l = 0; } else { - $l = strlen($fileId); + $l = \strlen($fileId); } if ($l > 0) { \trigger_error("Unique file ID $orig has $l bytes of leftover data");