mirror of
https://github.com/danog/tg-file-decoder.git
synced 2024-11-26 12:24:40 +01:00
Minor fixes
This commit is contained in:
parent
d78ea88700
commit
c6f8394934
@ -15,7 +15,8 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^8|^6",
|
||||
"amphp/php-cs-fixer-config": "dev-master"
|
||||
"amphp/php-cs-fixer-config": "dev-master",
|
||||
"vimeo/psalm": "dev-master"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
@ -18,8 +18,12 @@
|
||||
|
||||
namespace danog\Decoder;
|
||||
|
||||
use danog\Decoder\PhotoSizeSource\PhotoSizeSourceLegacy;
|
||||
|
||||
/**
|
||||
* Represents source of photosize.
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
abstract class PhotoSizeSource
|
||||
{
|
||||
@ -48,6 +52,17 @@ abstract class PhotoSizeSource
|
||||
*
|
||||
* @return integer
|
||||
*
|
||||
* @psalm-return (
|
||||
* T is PhotoSizeSourceLegacy ?
|
||||
* ? \danog\Decoder\PHOTOSIZE_SOURCE_LEGACY
|
||||
* : (T is PhotoSizeSourceDialogPhoto
|
||||
* ? \danog\Decoder\PHOTOSIZE_SOURCE_DIALOGPHOTO_*
|
||||
* (T is PhotoSizeSourceStickersetThumbnail
|
||||
* ? \danog\Decoder\PHOTOSIZE_SOURCE_STICKERSET_THUMBNAIL
|
||||
* : \danog\Decoder\PHOTOSIZE_SOURCE_THUMBNAIL
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @internal Internal use
|
||||
*/
|
||||
public function getType(): int
|
||||
|
@ -25,6 +25,8 @@ use const danog\Decoder\PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL;
|
||||
|
||||
/**
|
||||
* Represents source of photosize.
|
||||
*
|
||||
* @extends PhotoSizeSource<PhotoSizeSourceDialogPhoto>
|
||||
*/
|
||||
class PhotoSizeSourceDialogPhoto extends PhotoSizeSource
|
||||
{
|
||||
|
@ -24,6 +24,8 @@ use const danog\Decoder\PHOTOSIZE_SOURCE_LEGACY;
|
||||
|
||||
/**
|
||||
* Represents source of photosize.
|
||||
*
|
||||
* @extends PhotoSizeSource<PhotoSizeSourceLegacy>
|
||||
*/
|
||||
class PhotoSizeSourceLegacy extends PhotoSizeSource
|
||||
{
|
||||
|
@ -24,6 +24,8 @@ use const danog\Decoder\PHOTOSIZE_SOURCE_STICKERSET_THUMBNAIL;
|
||||
|
||||
/**
|
||||
* Represents source of photosize.
|
||||
*
|
||||
* @extends PhotoSizeSource<PhotoSizeSourceStickersetThumbnail>
|
||||
*/
|
||||
class PhotoSizeSourceStickersetThumbnail extends PhotoSizeSource
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ namespace danog\Decoder\PhotoSizeSource;
|
||||
use danog\Decoder\PhotoSizeSource;
|
||||
|
||||
use const danog\Decoder\PHOTOSIZE_SOURCE_THUMBNAIL;
|
||||
use const danog\Decoder\TYPES;
|
||||
|
||||
/**
|
||||
* Represents source of photosize.
|
||||
|
@ -206,6 +206,7 @@ $BIG_ENDIAN = \pack('L', 1) === \pack('N', 1);
|
||||
function unpackLong(string $field)
|
||||
{
|
||||
if (PHP_INT_SIZE === 8) {
|
||||
/** @psalm-suppress InvalidGlobal */
|
||||
global $BIG_ENDIAN; // Evil
|
||||
return \unpack('q', $BIG_ENDIAN ? \strrev($field) : $field)[1];
|
||||
}
|
||||
@ -227,6 +228,7 @@ function unpackLong(string $field)
|
||||
function packLongBig($field): string
|
||||
{
|
||||
if (PHP_INT_SIZE === 8) {
|
||||
/** @psalm-suppress InvalidGlobal */
|
||||
global $BIG_ENDIAN; // Evil
|
||||
$res = \pack('q', $field);
|
||||
return $BIG_ENDIAN ? \strrev($res) : $res;
|
||||
@ -263,7 +265,7 @@ function fixLong(array &$params, string $field)
|
||||
/**
|
||||
* Encode long to string.
|
||||
*
|
||||
* @param string|array $fields Fields to encode
|
||||
* @param int|int[] $fields Fields to encode
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user