mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-10-07 04:20:42 +00:00
Allow users without last_activity_time
Since schema 0.0.33 User.last_activity_time is nullable and not required. AbstractUser and its subclasses declared it as int, so a user object without it failed with "Argument #6 ($lastActivityTime) must be of type int, null given" and took the whole update with it.
This commit is contained in:
@@ -12,7 +12,7 @@ abstract readonly class AbstractUser extends AbstractModel
|
||||
* @param string|null $lastName Users last name.
|
||||
* @param string|null $username Unique public user name. Can be `null` if user is not accessible or it is not set.
|
||||
* @param bool $isBot Is the user a bot.
|
||||
* @param int $lastActivityTime Time of last user activity in Max (Unix timestamp in milliseconds).
|
||||
* @param int|null $lastActivityTime Time of last user activity in Max (Unix timestamp in milliseconds).
|
||||
* Can be outdated if user disabled its "online" status in settings.
|
||||
*/
|
||||
public function __construct(
|
||||
@@ -21,7 +21,7 @@ abstract readonly class AbstractUser extends AbstractModel
|
||||
public ?string $lastName,
|
||||
public ?string $username,
|
||||
public bool $isBot,
|
||||
public int $lastActivityTime,
|
||||
public ?int $lastActivityTime,
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ final readonly class BotInfo extends AbstractUser
|
||||
* @param string|null $lastName User's display last name.
|
||||
* @param string|null $username Unique public name of the user, may be null if the user is not available or no name is set.
|
||||
* @param bool $isBot Is the user a bot.
|
||||
* @param int $lastActivityTime User last activity time in MAX (Unix time in milliseconds). May be irrelevant if the user has disabled the "online" status in the settings.
|
||||
* @param int|null $lastActivityTime User last activity time in MAX (Unix time in milliseconds). May be irrelevant if the user has disabled the "online" status in the settings.
|
||||
* @param string|null $description User description, may be null if the user has not filled it in (up to 16000 characters).
|
||||
* @param string|null $avatarUrl Avatar URL.
|
||||
* @param string|null $fullAvatarUrl Larger Avatar URL.
|
||||
@@ -29,7 +29,7 @@ final readonly class BotInfo extends AbstractUser
|
||||
?string $lastName,
|
||||
?string $username,
|
||||
bool $isBot,
|
||||
int $lastActivityTime,
|
||||
?int $lastActivityTime,
|
||||
public ?string $description,
|
||||
public ?string $avatarUrl,
|
||||
public ?string $fullAvatarUrl,
|
||||
|
||||
@@ -18,7 +18,7 @@ final readonly class ChatMember extends AbstractUser
|
||||
* @param string|null $lastName User's last name.
|
||||
* @param string|null $username User's public username.
|
||||
* @param bool $isBot True if the user is a bot.
|
||||
* @param int $lastActivityTime Time of the user's last activity in Max.
|
||||
* @param int|null $lastActivityTime Time of the user's last activity in Max.
|
||||
* @param string|null $description User's profile description.
|
||||
* @param string|null $avatarUrl URL of the user's avatar.
|
||||
* @param string|null $fullAvatarUrl URL of the user's full-sized avatar.
|
||||
@@ -35,7 +35,7 @@ final readonly class ChatMember extends AbstractUser
|
||||
?string $lastName,
|
||||
?string $username,
|
||||
bool $isBot,
|
||||
int $lastActivityTime,
|
||||
?int $lastActivityTime,
|
||||
public ?string $description,
|
||||
public ?string $avatarUrl,
|
||||
public ?string $fullAvatarUrl,
|
||||
|
||||
@@ -12,7 +12,7 @@ final readonly class UserWithPhoto extends AbstractUser
|
||||
* @param string|null $lastName Users last name.
|
||||
* @param string|null $username Unique public user name. Can be `null` if user is not accessible or it is not set.
|
||||
* @param bool $isBot `true` if user is bot.
|
||||
* @param int $lastActivityTime Time of last user activity in Max (Unix timestamp in milliseconds).
|
||||
* @param int|null $lastActivityTime Time of last user activity in Max (Unix timestamp in milliseconds).
|
||||
* @param string|null $description UserWithPhoto description. Can be `null` if user did not fill it out.
|
||||
* @param string|null $avatarUrl URL of avatar.
|
||||
* @param string|null $fullAvatarUrl URL of avatar of a bigger size.
|
||||
@@ -23,7 +23,7 @@ final readonly class UserWithPhoto extends AbstractUser
|
||||
?string $lastName,
|
||||
?string $username,
|
||||
bool $isBot,
|
||||
int $lastActivityTime,
|
||||
?int $lastActivityTime,
|
||||
public ?string $description,
|
||||
public ?string $avatarUrl,
|
||||
public ?string $fullAvatarUrl,
|
||||
|
||||
@@ -12,6 +12,23 @@ use PHPUnit\Framework\TestCase;
|
||||
#[CoversClass(UserWithPhoto::class)]
|
||||
final class UserWithPhotoTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function optionalFieldsMayBeAbsent(): void
|
||||
{
|
||||
// Since schema 0.0.33 only user_id, first_name and is_bot are required
|
||||
$user = UserWithPhoto::fromArray([
|
||||
'user_id' => 123,
|
||||
'first_name' => 'John',
|
||||
'is_bot' => false,
|
||||
]);
|
||||
|
||||
$this->assertSame(123, $user->userId);
|
||||
$this->assertNull($user->lastName);
|
||||
$this->assertNull($user->username);
|
||||
$this->assertNull($user->lastActivityTime);
|
||||
$this->assertNull($user->avatarUrl);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function canBeCreatedFromArray(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user