This commit is contained in:
Daniil Gentili 2024-04-01 14:28:39 +02:00
parent c55474a2f3
commit 500f131d85
12 changed files with 188 additions and 292 deletions

View File

@ -1,6 +1,17 @@
<?php
$config = new Amp\CodeStyle\Config();
$config = new class extends Amp\CodeStyle\Config {
public function getRules(): array
{
return array_merge(
parent::getRules(),
[
'phpdoc_to_property_type' => true,
'phpdoc_to_param_type' => true,
]
);
}
};
$config->getFinder()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests');

View File

@ -15,7 +15,7 @@
},
"require-dev": {
"phpunit/phpunit": "^9",
"amphp/php-cs-fixer-config": "dev-master"
"amphp/php-cs-fixer-config": "^2"
},
"autoload": {
"psr-4": {

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Decoded FileId class.
*
@ -32,78 +32,65 @@ class FileId
/**
* Bot API file ID version.
*
* @var int
*/
private $_version = 4;
private int $version = 4;
/**
* Bot API file ID subversion.
*
* @var int
*/
private $_subVersion = 47;
private int $subVersion = 47;
/**
* DC ID.
*
* @var int
*/
private $_dcId = 0;
private int $dcId = 0;
/**
* File type.
*
* @var int
*/
private $_type = 0;
private int $type = 0;
/**
* File reference.
*
* @var string
*/
private $_fileReference = '';
private string $fileReference = '';
/**
* File URL for weblocation.
*
* @var string
*/
private $_url = '';
private string $url = '';
/**
* File id.
*
* @var int
*/
private $_id;
private int $id;
/**
* File access hash.
*
* @var int
*/
private $_accessHash;
private int $accessHash;
/**
* Photo volume ID.
*
* @var int
*/
private $_volumeId;
private int $volumeId;
/**
* Photo local ID.
*
* @var int
*/
private $_localId;
private int $localId;
/**
* Photo size source.
*
* @var PhotoSizeSource
*/
private $_photoSizeSource;
private PhotoSizeSource $photoSizeSource;
/**
* Basic constructor function.
*/
@ -116,7 +103,6 @@ class FileId
*
* @param string $fileId File ID
*
* @return self
*/
public static function fromBotAPI(string $fileId): self
{
@ -182,11 +168,9 @@ class FileId
return $result;
}
/**
* Get bot API file ID.
*
* @return string
*/
public function getBotAPI(): string
{
@ -261,7 +245,6 @@ class FileId
/**
* Get unique file ID from file ID.
*
* @return UniqueFileId
*/
public function getUnique(): UniqueFileId
{
@ -270,7 +253,6 @@ class FileId
/**
* Get unique bot API file ID from file ID.
*
* @return string
*/
public function getUniqueBotAPI(): string
{
@ -279,7 +261,6 @@ class FileId
/**
* Get bot API file ID.
*
* @return string
*/
public function __toString(): string
{
@ -288,23 +269,21 @@ class FileId
/**
* Get bot API file ID version.
*
* @return int
*/
public function getVersion(): int
{
return $this->_version;
return $this->version;
}
/**
* Set bot API file ID version.
*
* @param int $_version Bot API file ID version.
* @param int $version Bot API file ID version.
*
* @return self
*/
public function setVersion(int $_version): self
public function setVersion(int $version): self
{
$this->_version = $_version;
$this->version = $version;
return $this;
}
@ -312,23 +291,21 @@ class FileId
/**
* Get bot API file ID subversion.
*
* @return int
*/
public function getSubVersion(): int
{
return $this->_subVersion;
return $this->subVersion;
}
/**
* Set bot API file ID subversion.
*
* @param int $_subVersion Bot API file ID subversion.
* @param int $subVersion Bot API file ID subversion.
*
* @return self
*/
public function setSubVersion(int $_subVersion): self
public function setSubVersion(int $subVersion): self
{
$this->_subVersion = $_subVersion;
$this->subVersion = $subVersion;
return $this;
}
@ -336,33 +313,30 @@ class FileId
/**
* Get file type.
*
* @return int
*/
public function getType(): int
{
return $this->_type;
return $this->type;
}
/**
* Get file type as string.
*
* @return string
*/
public function getTypeName(): string
{
return TYPES[$this->_type];
return TYPES[$this->type];
}
/**
* Set file type.
*
* @param int $_type File type.
* @param int $type File type.
*
* @return self
*/
public function setType(int $_type): self
public function setType(int $type): self
{
$this->_type = $_type;
$this->type = $type;
return $this;
}
@ -370,23 +344,21 @@ class FileId
/**
* Get file reference.
*
* @return string
*/
public function getFileReference(): string
{
return $this->_fileReference;
return $this->fileReference;
}
/**
* Set file reference.
*
* @param string $_fileReference File reference.
* @param string $fileReference File reference.
*
* @return self
*/
public function setFileReference(string $_fileReference): self
public function setFileReference(string $fileReference): self
{
$this->_fileReference = $_fileReference;
$this->fileReference = $fileReference;
return $this;
}
@ -398,17 +370,16 @@ class FileId
*/
public function hasFileReference(): bool
{
return !empty($this->_fileReference);
return !empty($this->fileReference);
}
/**
* Get file URL for weblocation.
*
* @return string
*/
public function getUrl(): string
{
return $this->_url;
return $this->url;
}
/**
@ -418,19 +389,18 @@ class FileId
*/
public function hasUrl(): bool
{
return !empty($this->_url);
return !empty($this->url);
}
/**
* Set file URL for weblocation.
*
* @param string $_url File URL for weblocation.
* @param string $url File URL for weblocation.
*
* @return self
*/
public function setUrl(string $_url): self
public function setUrl(string $url): self
{
$this->_url = $_url;
$this->url = $url;
return $this;
}
@ -442,19 +412,18 @@ class FileId
*/
public function getId()
{
return $this->_id;
return $this->id;
}
/**
* Set file id.
*
* @param int $_id File id.
* @param int $id File id.
*
* @return self
*/
public function setId($_id): self
public function setId(int $id): self
{
$this->_id = $_id;
$this->id = $id;
return $this;
}
@ -462,11 +431,10 @@ class FileId
/**
* Check if has file id.
*
* @return bool
*/
public function hasId(): bool
{
return isset($this->_id);
return isset($this->id);
}
/**
@ -476,19 +444,18 @@ class FileId
*/
public function getAccessHash()
{
return $this->_accessHash;
return $this->accessHash;
}
/**
* Set file access hash.
*
* @param int $_accessHash File access hash.
* @param int $accessHash File access hash.
*
* @return self
*/
public function setAccessHash($_accessHash): self
public function setAccessHash(int $accessHash): self
{
$this->_accessHash = $_accessHash;
$this->accessHash = $accessHash;
return $this;
}
@ -500,19 +467,18 @@ class FileId
*/
public function getVolumeId()
{
return $this->_volumeId;
return $this->volumeId;
}
/**
* Set photo volume ID.
*
* @param int $_volumeId Photo volume ID.
* @param int $volumeId Photo volume ID.
*
* @return self
*/
public function setVolumeId($_volumeId): self
public function setVolumeId(int $volumeId): self
{
$this->_volumeId = $_volumeId;
$this->volumeId = $volumeId;
return $this;
}
@ -523,29 +489,27 @@ class FileId
*/
public function hasVolumeId(): bool
{
return isset($this->_volumeId);
return isset($this->volumeId);
}
/**
* Get photo local ID.
*
* @return int
*/
public function getLocalId(): int
{
return $this->_localId;
return $this->localId;
}
/**
* Set photo local ID.
*
* @param int $_localId Photo local ID.
* @param int $localId Photo local ID.
*
* @return self
*/
public function setLocalId(int $_localId): self
public function setLocalId(int $localId): self
{
$this->_localId = $_localId;
$this->localId = $localId;
return $this;
}
@ -557,29 +521,27 @@ class FileId
*/
public function hasLocalId(): bool
{
return isset($this->_localId);
return isset($this->localId);
}
/**
* Get photo size source.
*
* @return PhotoSizeSource
*/
public function getPhotoSizeSource(): PhotoSizeSource
{
return $this->_photoSizeSource;
return $this->photoSizeSource;
}
/**
* Set photo size source.
*
* @param PhotoSizeSource $_photoSizeSource Photo size source.
* @param PhotoSizeSource $photoSizeSource Photo size source.
*
* @return self
*/
public function setPhotoSizeSource(PhotoSizeSource $_photoSizeSource): self
public function setPhotoSizeSource(PhotoSizeSource $photoSizeSource): self
{
$this->_photoSizeSource = $_photoSizeSource;
$this->photoSizeSource = $photoSizeSource;
return $this;
}
@ -591,29 +553,27 @@ class FileId
*/
public function hasPhotoSizeSource(): bool
{
return isset($this->_photoSizeSource);
return isset($this->photoSizeSource);
}
/**
* Get dC ID.
*
* @return int
*/
public function getDcId(): int
{
return $this->_dcId;
return $this->dcId;
}
/**
* Set dC ID.
*
* @param int $_dcId DC ID.
* @param int $dcId DC ID.
*
* @return self
*/
public function setDcId(int $_dcId): self
public function setDcId(int $dcId): self
{
$this->_dcId = $_dcId;
$this->dcId = $dcId;
return $this;
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Photosize source class.
*
@ -30,9 +30,8 @@ abstract class PhotoSizeSource
/**
* Source type.
*
* @var int
*/
private $_type;
private int $type;
/**
* Set photosize source type.
@ -41,7 +40,7 @@ abstract class PhotoSizeSource
*/
public function __construct(int $type)
{
$this->_type = $type;
$this->type = $type;
return $this;
}
@ -65,6 +64,6 @@ abstract class PhotoSizeSource
*/
public function getType(): int
{
return $this->_type;
return $this->type;
}
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Photosize source class.
*
@ -33,15 +33,13 @@ class PhotoSizeSourceDialogPhoto extends PhotoSizeSource
/**
* ID of dialog.
*
* @var int
*/
private $_dialogId;
private int $dialogId;
/**
* Access hash of dialog.
*
* @var int
*/
private $_dialogAccessHash;
private int $dialogAccessHash;
/**
* Get dialog ID.
@ -50,18 +48,17 @@ class PhotoSizeSourceDialogPhoto extends PhotoSizeSource
*/
public function getDialogId()
{
return $this->_dialogId;
return $this->dialogId;
}
/**
* Set dialog ID.
*
* @param int $id Dialog ID
*
* @return self
*/
public function setDialogId($id): self
public function setDialogId(int $id): self
{
$this->_dialogId = $id;
$this->dialogId = $id;
return $this;
}
/**
@ -71,7 +68,7 @@ class PhotoSizeSourceDialogPhoto extends PhotoSizeSource
*/
public function getDialogAccessHash()
{
return $this->_dialogAccessHash;
return $this->dialogAccessHash;
}
/**
@ -79,11 +76,10 @@ class PhotoSizeSourceDialogPhoto extends PhotoSizeSource
*
* @param int $dialogAccessHash Access hash of dialog
*
* @return self
*/
public function setDialogAccessHash($dialogAccessHash): self
public function setDialogAccessHash(int $dialogAccessHash): self
{
$this->_dialogAccessHash = $dialogAccessHash;
$this->dialogAccessHash = $dialogAccessHash;
return $this;
}
@ -91,7 +87,6 @@ class PhotoSizeSourceDialogPhoto extends PhotoSizeSource
/**
* Get whether the big or small version of the photo is being used.
*
* @return bool
*/
public function isSmallDialogPhoto(): bool
{

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Photosize source class.
*
@ -30,9 +30,8 @@ class PhotoSizeSourceLegacy extends PhotoSizeSource
/**
* Secret legacy ID.
*
* @var int
*/
private $_secret;
private int $secret;
/**
* Get secret legacy ID.
@ -41,19 +40,18 @@ class PhotoSizeSourceLegacy extends PhotoSizeSource
*/
public function getSecret()
{
return $this->_secret;
return $this->secret;
}
/**
* Set secret legacy ID.
*
* @param int $_secret Secret legacy ID
* @param int $secret Secret legacy ID
*
* @return self
*/
public function setSecret($_secret): self
public function setSecret(int $secret): self
{
$this->_secret = $_secret;
$this->secret = $secret;
return $this;
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Photosize source class.
*
@ -30,16 +30,13 @@ class PhotoSizeSourceStickersetThumbnail extends PhotoSizeSource
/**
* Stickerset ID.
*
* @var int
*/
private $_stickerSetId;
private int $stickerSetId;
/**
* Stickerset access hash.
*
* @var int
*/
private $_stickerSetAccessHash;
private int $stickerSetAccessHash;
/**
* Get stickerset ID.
@ -48,19 +45,18 @@ class PhotoSizeSourceStickersetThumbnail extends PhotoSizeSource
*/
public function getStickerSetId()
{
return $this->_stickerSetId;
return $this->stickerSetId;
}
/**
* Set stickerset ID.
*
* @param int $_stickerSetId Stickerset ID
* @param int $stickerSetId Stickerset ID
*
* @return self
*/
public function setStickerSetId($_stickerSetId): self
public function setStickerSetId(int $stickerSetId): self
{
$this->_stickerSetId = $_stickerSetId;
$this->stickerSetId = $stickerSetId;
return $this;
}
@ -72,19 +68,18 @@ class PhotoSizeSourceStickersetThumbnail extends PhotoSizeSource
*/
public function getStickerSetAccessHash()
{
return $this->_stickerSetAccessHash;
return $this->stickerSetAccessHash;
}
/**
* Set stickerset access hash.
*
* @param int $_stickerSetAccessHash Stickerset access hash
* @param int $stickerSetAccessHash Stickerset access hash
*
* @return self
*/
public function setStickerSetAccessHash($_stickerSetAccessHash): self
public function setStickerSetAccessHash(int $stickerSetAccessHash): self
{
$this->_stickerSetAccessHash = $_stickerSetAccessHash;
$this->stickerSetAccessHash = $stickerSetAccessHash;
return $this;
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Photosize source class.
*
@ -30,22 +30,18 @@ class PhotoSizeSourceStickersetThumbnailVersion extends PhotoSizeSource
/**
* Stickerset ID.
*
* @var int
*/
private $_stickerSetId;
private int $stickerSetId;
/**
* Stickerset access hash.
*
* @var int
*/
private $_stickerSetAccessHash;
private int $stickerSetAccessHash;
/**
* Stickerset version.
*
* @var int
*/
private $_stickerSetVersion;
private int $stickerSetVersion;
/**
* Get stickerset ID.
@ -54,19 +50,18 @@ class PhotoSizeSourceStickersetThumbnailVersion extends PhotoSizeSource
*/
public function getStickerSetId()
{
return $this->_stickerSetId;
return $this->stickerSetId;
}
/**
* Set stickerset ID.
*
* @param int $_stickerSetId Stickerset ID
* @param int $stickerSetId Stickerset ID
*
* @return self
*/
public function setStickerSetId($_stickerSetId): self
public function setStickerSetId(int $stickerSetId): self
{
$this->_stickerSetId = $_stickerSetId;
$this->stickerSetId = $stickerSetId;
return $this;
}
@ -78,19 +73,18 @@ class PhotoSizeSourceStickersetThumbnailVersion extends PhotoSizeSource
*/
public function getStickerSetAccessHash()
{
return $this->_stickerSetAccessHash;
return $this->stickerSetAccessHash;
}
/**
* Set stickerset access hash.
*
* @param int $_stickerSetAccessHash Stickerset access hash
* @param int $stickerSetAccessHash Stickerset access hash
*
* @return self
*/
public function setStickerSetAccessHash($_stickerSetAccessHash): self
public function setStickerSetAccessHash(int $stickerSetAccessHash): self
{
$this->_stickerSetAccessHash = $_stickerSetAccessHash;
$this->stickerSetAccessHash = $stickerSetAccessHash;
return $this;
}
@ -98,23 +92,21 @@ class PhotoSizeSourceStickersetThumbnailVersion extends PhotoSizeSource
/**
* Get stickerset version.
*
* @return int
*/
public function getStickerSetVersion(): int
{
return $this->_stickerSetVersion;
return $this->stickerSetVersion;
}
/**
* Set stickerset version.
*
* @param int $_stickerSetVersion Stickerset version.
* @param int $stickerSetVersion Stickerset version.
*
* @return self
*/
public function setStickerSetVersion(int $_stickerSetVersion): self
public function setStickerSetVersion(int $stickerSetVersion): self
{
$this->_stickerSetVersion = $_stickerSetVersion;
$this->stickerSetVersion = $stickerSetVersion;
return $this;
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Photosize source class.
*
@ -30,45 +30,40 @@ class PhotoSizeSourceThumbnail extends PhotoSizeSource
/**
* File type of original file.
*
* @var int
*/
private $_thumbFileType;
private int $thumbFileType;
/**
* Thumbnail size.
*
* @var string
*/
private $_thumbType;
private string $thumbType;
/**
* Get file type of original file.
*
* @return int
*/
public function getThumbFileType(): int
{
return $this->_thumbFileType;
return $this->thumbFileType;
}
/**
* Get file type of original file as string.
*
* @return string
*/
public function getThumbFileTypeString(): string
{
return TYPES[$this->_thumbFileType];
return TYPES[$this->thumbFileType];
}
/**
* Set file type of original file.
*
* @param int $_thumbFileType File type of original file
* @param int $thumbFileType File type of original file
*
* @return self
*/
public function setThumbFileType(int $_thumbFileType): self
public function setThumbFileType(int $thumbFileType): self
{
$this->_thumbFileType = $_thumbFileType;
$this->thumbFileType = $thumbFileType;
return $this;
}
@ -76,23 +71,21 @@ class PhotoSizeSourceThumbnail extends PhotoSizeSource
/**
* Get thumbnail size.
*
* @return string
*/
public function getThumbType(): string
{
return $this->_thumbType;
return $this->thumbType;
}
/**
* Set thumbnail size.
*
* @param string $_thumbType Thumbnail size
* @param string $thumbType Thumbnail size
*
* @return self
*/
public function setThumbType(string $_thumbType): self
public function setThumbType(string $thumbType): self
{
$this->_thumbType = $_thumbType;
$this->thumbType = $thumbType;
return $this;
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Decoded UniqueFileId class.
*
@ -30,51 +30,43 @@ class UniqueFileId
/**
* File type.
*
* @var int
*/
private $_type = NONE;
private int $type = NONE;
/**
* File ID.
*
* @var int
*/
private $_id;
private int $id;
/**
* Photo volume ID.
*
* @var int
*/
private $_volumeId;
private int $volumeId;
/**
* Photo local ID.
*
* @var int
*/
private $_localId;
private int $localId;
/**
* Photo subtype.
*
* @var int
*/
private $_subType;
private int $subType;
/**
* Sticker set ID.
*
* @var int
*/
private $_stickerSetId;
private int $stickerSetId;
/**
* Sticker set version.
*
* @var int
*/
private $_stickerSetVersion;
private int $stickerSetVersion;
/**
* Weblocation URL.
*
* @var string
*/
private $_url;
private string $url;
/**
* Basic constructor function.
*/
@ -85,7 +77,6 @@ class UniqueFileId
/**
* Get unique bot API file ID.
*
* @return string
*/
public function __toString(): string
{
@ -95,7 +86,6 @@ class UniqueFileId
/**
* Get unique bot API file ID.
*
* @return string
*/
public function getUniqueBotAPI(): string
{
@ -126,7 +116,6 @@ class UniqueFileId
*
* @param string $fileId Bot API file ID
*
* @return self
*/
public static function fromUniqueBotAPI(string $fileId): self
{
@ -159,7 +148,6 @@ class UniqueFileId
*
* @param string $fileId Full bot API file ID
*
* @return self
*/
public static function fromBotAPI(string $fileId): self
{
@ -171,7 +159,6 @@ class UniqueFileId
*
* @param FileId $fileId Full file ID
*
* @return self
*/
public static function fromFileId(FileId $fileId): self
{
@ -217,33 +204,30 @@ class UniqueFileId
/**
* Get unique file type as string.
*
* @return string
*/
public function getTypeName(): string
{
return UNIQUE_TYPES[$this->_type];
return UNIQUE_TYPES[$this->type];
}
/**
* Get unique file type.
*
* @return int
*/
public function getType(): int
{
return $this->_type;
return $this->type;
}
/**
* Set file type.
*
* @param int $_type File type.
* @param int $type File type.
*
* @return self
*/
public function setType(int $_type): self
public function setType(int $type): self
{
$this->_type = $_type;
$this->type = $type;
return $this;
}
@ -255,19 +239,18 @@ class UniqueFileId
*/
public function getId()
{
return $this->_id;
return $this->id;
}
/**
* Set file ID.
*
* @param int $_id File ID.
* @param int $id File ID.
*
* @return self
*/
public function setId($_id): self
public function setId(int $id): self
{
$this->_id = $_id;
$this->id = $id;
return $this;
}
@ -279,10 +262,9 @@ class UniqueFileId
*/
public function hasId(): bool
{
return isset($this->_id);
return isset($this->id);
}
/**
* Get photo volume ID.
*
@ -290,19 +272,18 @@ class UniqueFileId
*/
public function getVolumeId()
{
return $this->_volumeId;
return $this->volumeId;
}
/**
* Set photo volume ID.
*
* @param int $_volumeId Photo volume ID.
* @param int $volumeId Photo volume ID.
*
* @return self
*/
public function setVolumeId($_volumeId): self
public function setVolumeId(int $volumeId): self
{
$this->_volumeId = $_volumeId;
$this->volumeId = $volumeId;
return $this;
}
@ -313,29 +294,27 @@ class UniqueFileId
*/
public function hasVolumeId(): bool
{
return isset($this->_volumeId);
return isset($this->volumeId);
}
/**
* Get photo local ID.
*
* @return int
*/
public function getLocalId(): int
{
return $this->_localId;
return $this->localId;
}
/**
* Set photo local ID.
*
* @param int $_localId Photo local ID.
* @param int $localId Photo local ID.
*
* @return self
*/
public function setLocalId(int $_localId): self
public function setLocalId(int $localId): self
{
$this->_localId = $_localId;
$this->localId = $localId;
return $this;
}
@ -347,30 +326,27 @@ class UniqueFileId
*/
public function hasLocalId(): bool
{
return isset($this->_localId);
return isset($this->localId);
}
/**
* Get weblocation URL.
*
* @return string
*/
public function getUrl(): string
{
return $this->_url;
return $this->url;
}
/**
* Set weblocation URL.
*
* @param string $_url Weblocation URL
* @param string $url Weblocation URL
*
* @return self
*/
public function setUrl(string $_url): self
public function setUrl(string $url): self
{
$this->_url = $_url;
$this->url = $url;
return $this;
}
@ -382,39 +358,36 @@ class UniqueFileId
*/
public function hasUrl(): bool
{
return isset($this->_url);
return isset($this->url);
}
/**
* Get photo subtype.
*
* @return int
*/
public function getSubType(): int
{
return $this->_subType;
return $this->subType;
}
/**
* Has photo subtype?
*
* @return bool
*/
public function hasSubType(): bool
{
return isset($this->_subType);
return isset($this->subType);
}
/**
* Set photo subtype.
*
* @param int $_subType Photo subtype
* @param int $subType Photo subtype
*
* @return self
*/
public function setSubType(int $_subType): self
public function setSubType(int $subType): self
{
$this->_subType = $_subType;
$this->subType = $subType;
return $this;
}
@ -426,30 +399,27 @@ class UniqueFileId
*/
public function getStickerSetId()
{
return $this->_stickerSetId;
return $this->stickerSetId;
}
/**
* Has sticker set ID?
*
* @return bool
*/
public function hasStickerSetId(): bool
{
return isset($this->_stickerSetId);
return isset($this->stickerSetId);
}
/**
* Set sticker set ID.
*
* @param int $_stickerSetId Sticker set ID
* @param int $stickerSetId Sticker set ID
*
* @return self
*/
public function setStickerSetId($_stickerSetId): self
public function setStickerSetId(int $stickerSetId): self
{
$this->_stickerSetId = $_stickerSetId;
$this->stickerSetId = $stickerSetId;
return $this;
}
@ -457,33 +427,30 @@ class UniqueFileId
/**
* Get sticker set version.
*
* @return int
*/
public function getStickerSetVersion(): int
{
return $this->_stickerSetVersion;
return $this->stickerSetVersion;
}
/**
* Has sticker set version.
*
* @return bool
*/
public function hasStickerSetVersion(): bool
{
return isset($this->_stickerSetVersion);
return isset($this->stickerSetVersion);
}
/**
* Set sticker set version.
*
* @param int $_stickerSetVersion Sticker set version
* @param int $stickerSetVersion Sticker set version
*
* @return self
*/
public function setStickerSetVersion(int $_stickerSetVersion): self
public function setStickerSetVersion(int $stickerSetVersion): self
{
$this->_stickerSetVersion = $_stickerSetVersion;
$this->stickerSetVersion = $stickerSetVersion;
return $this;
}

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
/**
* Type enum + helper functions.
*
@ -226,11 +226,9 @@ function unpackLong(string $field)
/**
* Pack string long.
*
* @param string|int $field
*
* @return string
*/
function packLongBig($field): string
function packLongBig(string|int $field): string
{
if (PHP_INT_SIZE === 8) {
/** @psalm-suppress InvalidGlobal */
@ -272,9 +270,8 @@ function fixLong(array &$params, string $field)
*
* @param string|int|int[] $fields Fields to encode
*
* @return string
*/
function packLong($fields): string
function packLong(string|int|array $fields): string
{
if (\is_string($fields)) { // Already encoded, we hope
return $fields;
@ -292,7 +289,6 @@ function packLong($fields): string
*
* @internal
*
* @return string
*/
function base64urlDecode(string $data): string
{
@ -306,7 +302,6 @@ function base64urlDecode(string $data): string
*
* @internal
*
* @return string
*/
function base64urlEncode(string $data): string
{
@ -320,7 +315,6 @@ function base64urlEncode(string $data): string
*
* @internal
*
* @return string
*/
function rleDecode(string $string): string
{
@ -348,7 +342,6 @@ function rleDecode(string $string): string
*
* @internal
*
* @return string
*/
function rleEncode(string $string): string
{
@ -374,7 +367,6 @@ function rleEncode(string $string): string
return $new;
}
/**
* Positive modulo
* Works just like the % (modulus) operator, only returns always a postive number.
@ -400,9 +392,8 @@ function posmod(int $a, int $b): int
*
* @internal
*
* @return string
*/
function readTLString($stream): string
function readTLString(mixed $stream): string
{
$l = \ord(\stream_get_contents($stream, 1));
if ($l > 254) {
@ -430,7 +421,6 @@ function readTLString($stream): string
*
* @param string $string String
*
* @return string
*/
function packTLString(string $string): string
{
@ -458,7 +448,6 @@ function packTLString(string $string): string
*
* @internal
*
* @return array
*/
function internalDecode(string $fileId): array
{
@ -583,14 +572,12 @@ function internalDecode(string $fileId): array
*
* @internal
*
* @return array
*/
function internalDecodeUnique(string $fileId): array
{
$orig = $fileId;
$fileId = rleDecode(base64urlDecode($fileId));
$result = \unpack('VtypeId', $fileId);
if (!isset(UNIQUE_TYPES[$result['typeId']])) {
throw new \InvalidArgumentException("Invalid file type provided: {$result['typeId']}");

View File

@ -1,4 +1,4 @@
<?php
<?php declare(strict_types=1);
namespace danog\Decoder\Test;
@ -13,7 +13,6 @@ use const danog\Decoder\TYPES_IDS;
class IntegrationTest extends TestCase
{
/**
* @param string $fileId File ID
* @param string $type Expected type
*
* @dataProvider provideFileIdsAndType