Minor fixes

This commit is contained in:
Daniil Gentili 2020-10-03 13:50:37 +02:00
parent d78ea88700
commit c6f8394934
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
7 changed files with 27 additions and 2 deletions

View File

@ -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": {

View File

@ -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

View File

@ -25,6 +25,8 @@ use const danog\Decoder\PHOTOSIZE_SOURCE_DIALOGPHOTO_SMALL;
/**
* Represents source of photosize.
*
* @extends PhotoSizeSource<PhotoSizeSourceDialogPhoto>
*/
class PhotoSizeSourceDialogPhoto extends PhotoSizeSource
{

View File

@ -24,6 +24,8 @@ use const danog\Decoder\PHOTOSIZE_SOURCE_LEGACY;
/**
* Represents source of photosize.
*
* @extends PhotoSizeSource<PhotoSizeSourceLegacy>
*/
class PhotoSizeSourceLegacy extends PhotoSizeSource
{

View File

@ -24,6 +24,8 @@ use const danog\Decoder\PHOTOSIZE_SOURCE_STICKERSET_THUMBNAIL;
/**
* Represents source of photosize.
*
* @extends PhotoSizeSource<PhotoSizeSourceStickersetThumbnail>
*/
class PhotoSizeSourceStickersetThumbnail extends PhotoSizeSource
{

View File

@ -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.

View File

@ -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
*/