From 59abffe74447bf142a52d7ad5d1e305e5b19fb67 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Thu, 23 Dec 2021 17:06:11 +0000 Subject: [PATCH] [ENTITY][Actor][DOC] Add explanation in Actor::__call --- src/Entity/Actor.php | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/Entity/Actor.php b/src/Entity/Actor.php index fd5f7e49f2..b19c4404ee 100644 --- a/src/Entity/Actor.php +++ b/src/Entity/Actor.php @@ -28,7 +28,6 @@ use App\Core\DB\DB; use App\Core\Entity; use App\Core\Event; use App\Core\Router\Router; -use App\Core\UserRoles; use App\Util\Exception\BugFoundException; use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\NicknameException; @@ -290,21 +289,6 @@ class Actor extends Entity } } - public function __call(string $name, array $arguments): mixed - { - if (Formatting::startsWith($name, 'is')) { - $type = Formatting::removePrefix($name, 'is'); - $const = self::class . '::' . mb_strtoupper($type); - if (\defined($const)) { - return $this->type === \constant($const); - } else { - throw new BugFoundException("Actor cannot be a '{$type}', check your spelling"); - } - } else { - return parent::__call($name, $arguments); - } - } - public function getAvatarUrl(string $size = 'full') { return Avatar::getUrl($this->getId(), $size); @@ -423,11 +407,6 @@ class Actor extends Entity return $this->getSubCount(which: 'subscribed', column: 'subscriber'); } - public function isPerson(): bool - { - return ($this->roles & UserRoles::BOT) === 0; - } - /** * Resolve an ambiguous nickname reference, checking in following order: * - Actors that $sender subscribes to @@ -588,6 +567,28 @@ class Actor extends Entity } } + /** + * @method bool isPerson() + * @method bool isGroup() + * @method bool isOrganization() + * @method bool isBusiness() + * @method bool isBot() + */ + public function __call(string $name, array $arguments): mixed + { + if (Formatting::startsWith($name, 'is')) { + $type = Formatting::removePrefix($name, 'is'); + $const = self::class . '::' . mb_strtoupper($type); + if (\defined($const)) { + return $this->type === \constant($const); + } else { + throw new BugFoundException("Actor cannot be a '{$type}', check your spelling"); + } + } else { + return parent::__call($name, $arguments); + } + } + public static function schemaDef(): array { return [