Skip to content

Commit

Permalink
Merge pull request #724 from SQKo/php-cs-fixer
Browse files Browse the repository at this point in the history
Run PHP cs fixer
  • Loading branch information
key2peace authored Feb 12, 2022
2 parents 2b49734 + 1cd9475 commit 2b8b2ed
Show file tree
Hide file tree
Showing 44 changed files with 152 additions and 128 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ This release contains breaking changes regarding messages.
- Added [guild feature flags](https://github.com/discord-php/DiscordPHP/blob/28d741c47e81f9957a3b0d92c2f187d81d26c9c8/src/Discord/Parts/Guild/Guild.php#L75-L95).
- Removed `premium_since` attribute from the `PresenceUpdate` object.
- This would have been null since v6 anyway.
- `$message->author` is now only return an `User` object and no longer return a `Member` object. `$message->user` is removed in favour of `$message->author`
- `Message::stickers` is now `Message::sticker_items`
- Deprecated old permission names: (#661)
- `use_slash_commands` is now `use_application_commands`
- `use_public_threads` is now `create_public_threads`
- `use_private_threads` is now `create_private_threads`
- `manage_emojis` is now `manage_emojis_and_stickers`
- `Guild::region` is deprecated and may be removed in future release
- Sticker `use Discord\Parts\Channel\Sticker` is now `use Discord\Parts\Guild\Sticker`
- Invite `use Discord\Parts\Guild\Invite` is now `use Discord\Parts\Channel\Invite`
- Some event handler arguments have been updated, check out the documentation.

## Version 6.0.2

Expand Down
16 changes: 11 additions & 5 deletions src/Discord/Builders/CommandBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use JsonSerializable;

use function Discord\poly_strlen;

/**
* Helper class used to build application commands.
*
Expand All @@ -24,7 +25,7 @@
class CommandBuilder implements JsonSerializable
{
/**
* Type of the command. The type defaults to 1
* Type of the command. The type defaults to 1.
*
* @var int
*/
Expand All @@ -38,7 +39,7 @@ class CommandBuilder implements JsonSerializable
protected string $name;

/**
* Description of the command. should be emtpy if the type is not CHAT_INPUT
* Description of the command. should be emtpy if the type is not CHAT_INPUT.
*
* @var string
*/
Expand All @@ -52,7 +53,7 @@ class CommandBuilder implements JsonSerializable
protected array $options = [];

/**
* The default permission of the command. If true the command is enabled when the app is added to the guild
* The default permission of the command. If true the command is enabled when the app is added to the guild.
*
* @var bool
*/
Expand Down Expand Up @@ -84,6 +85,7 @@ public function setType(int $type): self
}

$this->type = $type;

return $this;
}

Expand All @@ -103,6 +105,7 @@ public function setName(string $name): self
}

$this->name = $name;

return $this;
}

Expand All @@ -122,6 +125,7 @@ public function setDescription(string $description): self
}

$this->description = $description;

return $this;
}

Expand All @@ -135,6 +139,7 @@ public function setDescription(string $description): self
public function setDefaultPermission(bool $permission): self
{
$this->default_permission = $permission;

return $this;
}

Expand All @@ -154,6 +159,7 @@ public function addOption(Option $option): self
}

$this->options[] = $option;

return $this;
}

Expand Down Expand Up @@ -213,10 +219,10 @@ public function toArray(): array
'description' => $this->description,
'type' => $this->type,
'options' => [],
'default_permission' => $this->default_permission
'default_permission' => $this->default_permission,
];

foreach ($this->options AS $option) {
foreach ($this->options as $option) {
$arrCommand['options'][] = $option->getRawAttributes();
}

Expand Down
4 changes: 2 additions & 2 deletions src/Discord/Builders/Components/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Button extends Component
/**
* Creates a new button.
*
* @param int $style Style of the button.
* @param int $style Style of the button.
* @param string|null $custom_id custom ID of the button. If not given, an UUID will be used
*
* @throws \InvalidArgumentException
Expand All @@ -118,7 +118,7 @@ public function __construct(int $style, ?string $custom_id)
/**
* Creates a new button.
*
* @param int $style Style of the button.
* @param int $style Style of the button.
* @param string|null $custom_id custom ID of the button.
*
* @return self
Expand Down
2 changes: 1 addition & 1 deletion src/Discord/Builders/Components/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use function Discord\poly_strlen;

/**
* Option for select menu component
* Option for select menu component.
*
* @see https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Discord/Builders/Components/SelectMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ class SelectMenu extends Component

/**
* Creates a new select menu.
*
*
* @param string|null $custom_id The custom ID of the select menu. If not given, an UUID will be used
*/
public function __construct(?string $custom_id)
{
$this->setCustomId($custom_id ?? $this->generateUuid());
$this->setCustomId($custom_id ?? $this->generateUuid());
}

/**
* Creates a new select menu.
*
* @param string|null $custom_id The custom ID of the select menu.
*
*
* @return self
*/
public static function new(?string $custom_id = null): self
Expand All @@ -109,8 +109,8 @@ public static function new(?string $custom_id = null): self
}

/**
* Sets the custom ID for the select menu
*
* Sets the custom ID for the select menu.
*
* @param string $custom_id
*
* @throws \LengthException
Expand Down
8 changes: 4 additions & 4 deletions src/Discord/Builders/Components/TextInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ class TextInput extends Component
private $label;

/**
* Minimum input length for a text input, min 0, max 4000
* Minimum input length for a text input, min 0, max 4000.
*
* @var int|null
*/
private $min_length;

/**
* Maximum input length for a text input, min 1, max 4000
* Maximum input length for a text input, min 1, max 4000.
*
* @var int|null
*/
Expand All @@ -66,7 +66,7 @@ class TextInput extends Component
private $required = false;

/**
* Pre-filled value for text input. Max 4000 characters
* Pre-filled value for text input. Max 4000 characters.
*
* @var string|null
*/
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function new(string $label, int $style, ?string $custom_id = null)
}

/**
* Sets the custom ID for the text input
* Sets the custom ID for the text input.
*
* @param string $custom_id
*
Expand Down
3 changes: 1 addition & 2 deletions src/Discord/Builders/MessageBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Discord\Builders\Components\ActionRow;
use Discord\Builders\Components\Component;
use Discord\Builders\Components\SelectMenu;
use Discord\Builders\Components\TextInput;
use Discord\Exceptions\FileNotFoundException;
use Discord\Helpers\Multipart;
use Discord\Http\Exceptions\RequestFailedException;
Expand Down Expand Up @@ -89,7 +88,7 @@ class MessageBuilder implements JsonSerializable
private $allowed_mentions;

/**
* IDs of up to 3 stickers in the server to send in the message
* IDs of up to 3 stickers in the server to send in the message.
*
* @var array|null
*/
Expand Down
17 changes: 9 additions & 8 deletions src/Discord/Discord.php
Original file line number Diff line number Diff line change
Expand Up @@ -1064,13 +1064,13 @@ protected function ready()
/**
* Updates the clients presence.
*
* @param Activity|null $activity The current client activity, or null.
* Note: The activity type _cannot_ be custom, and the only valid fields are `name`, `type` and `url`.
* @param bool $idle Whether the client is idle.
* @param string $status The current status of the client.
* Must be one of the following:
* online, dnd, idle, invisible, offline
* @param bool $afk Whether the client is AFK.
* @param Activity|null $activity The current client activity, or null.
* Note: The activity type _cannot_ be custom, and the only valid fields are `name`, `type` and `url`.
* @param bool $idle Whether the client is idle.
* @param string $status The current status of the client.
* Must be one of the following:
* online, dnd, idle, invisible, offline
* @param bool $afk Whether the client is AFK.
*
* @throws \UnexpectedValueException
*/
Expand All @@ -1090,7 +1090,7 @@ public function updatePresence(Activity $activity = null, bool $idle = false, st

$allowed = ['online', 'dnd', 'idle', 'invisible', 'offline'];

if (! in_array($status, $allowed)) {
if (! in_array($status, $allowed)) {
$status = 'online';
}

Expand Down Expand Up @@ -1553,6 +1553,7 @@ public function listenCommand($name, callable $callback = null, ?callable $autoc
if (! isset($this->application_commands[$baseCommand])) {
$this->listenCommand($baseCommand);
}

return $this->application_commands[$baseCommand]->addSubCommand($name, $callback, $autocomplete_callback);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Discord/DiscordCommandClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ public function __construct(array $options = [])
}
// Use embed fields in case commands count is below limit
if (count($embedfields) <= 25) {
foreach ($embedfields as $field)
{
foreach ($embedfields as $field) {
$embed->addField($field);
}
$commandsDescription = '';
Expand Down
11 changes: 7 additions & 4 deletions src/Discord/Helpers/Bitwise.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
namespace Discord\Helpers;

/**
* Polyfill to handle bitwise operation in 32 bit php using ext-gmp
* Polyfill to handle bitwise operation in 32 bit php using ext-gmp.
*/
class Bitwise
{
private static bool $is_32_gmp = false;

/**
* Run a single check whether the GMP extension is loaded, internally used
* during Discord class construct
* during Discord class construct.
*
* @return bool true if GMP extension is loaded
*/
Expand Down Expand Up @@ -89,7 +89,7 @@ public static function not($a)
return \gmp_sub(\gmp_neg(self::floatCast($a)), 1);
}

return ~ $a;
return ~$a;
}

/**
Expand Down Expand Up @@ -148,6 +148,7 @@ public static function set($a, int $b)
if (self::$is_32_gmp) {
$gmp = \gmp_init(self::floatCast($a));
\gmp_setbit($gmp, $b);

return $gmp;
}

Expand All @@ -166,7 +167,9 @@ public static function set($a, int $b)
public static function floatCast($value)
{
// Discard non float
if (! is_float($value)) return $value;
if (! is_float($value)) {
return $value;
}

$currentLocale = setlocale(LC_NUMERIC, '0');
setlocale(LC_NUMERIC, 'C');
Expand Down
1 change: 0 additions & 1 deletion src/Discord/Helpers/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Countable;
use IteratorAggregate;
use JsonSerializable;
use Serializable;
use Traversable;

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Discord/Helpers/RegisteredCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public function addSubCommand($name, callable $callback = null, ?callable $autoc
}

/**
* Get command name
* Get command name.
*
* @return string
*/
Expand All @@ -202,7 +202,7 @@ public function getName(): string
}

/**
* Get sub commands
* Get sub commands.
*
* @return RegisteredCommand[]|null
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Discord/Parts/Channel/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Discord\Parts\Part;

/**
* A message attachment
* A message attachment.
*
* @see https://discord.com/developers/docs/resources/channel#attachment-object
*
Expand Down Expand Up @@ -44,6 +44,6 @@ class Attachment extends Part
'proxy_url',
'height',
'width',
'ephemeral'
'ephemeral',
];
}
6 changes: 3 additions & 3 deletions src/Discord/Parts/Channel/Invite.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected function getGuildIdAttribute(): ?string
*
* @throws \Exception
*
* @return Channel The Channel that you have been invited to.
* @return Channel The Channel that you have been invited to.
*/
protected function getChannelAttribute(): Channel
{
Expand Down Expand Up @@ -205,7 +205,7 @@ protected function getInviterAttribute(): ?User
*
* @throws \Exception
*
* @return Carbon The time that the invite was created.
* @return Carbon The time that the invite was created.
*/
protected function getCreatedAtAttribute(): Carbon
{
Expand All @@ -217,7 +217,7 @@ protected function getCreatedAtAttribute(): Carbon
*
* @throws \Exception
*
* @return User|null The user whose stream to display for this voice channel stream invite.
* @return User|null The user whose stream to display for this voice channel stream invite.
*/
protected function getTargetUserAttribute(): ?User
{
Expand Down
Loading

0 comments on commit 2b8b2ed

Please sign in to comment.