Skip to content

Commit b91267a

Browse files
committed
Tweaks to studly params & ran cs-unsupported
The library only uses studly for the magic methods on attributes, but it's easier to ensure consistency in other aspects by making ucfirst a toggle
1 parent 8a103f5 commit b91267a

22 files changed

+46
-47
lines changed

src/Discord/Builders/Components/Button.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public function isDisabled(): bool
602602
}
603603

604604
/**
605-
* {@inheritDoc}
605+
* @inheritDoc
606606
*/
607607
public function jsonSerialize(): array
608608
{

src/Discord/Builders/MessageBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ public function setIsComponentsV2Flag(bool $enable = true): self
864864
{
865865
if ($enable) {
866866
if (! ($this->flags & Message::FLAG_IS_COMPONENTS_V2)) {
867-
$this->flags |= Message::FLAG_IS_COMPONENTS_V2 ;
867+
$this->flags |= Message::FLAG_IS_COMPONENTS_V2;
868868
}
869869
} elseif ($this->flags & Message::FLAG_IS_COMPONENTS_V2) {
870870
$this->flags &= ~Message::FLAG_IS_COMPONENTS_V2;

src/Discord/Parts/Channel/ChannelTrait.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ public function sendMessage($message, bool $tts = false, $embed = null, $allowed
514514
if (is_string($message)) {
515515
$message = MessageBuilder::new()->setContent($message);
516516
$message->setTts($tts);
517-
if ($embed) $message->addEmbed($embed);
517+
if ($embed) {
518+
$message->addEmbed($embed);
519+
}
518520
$message->setAllowedMentions($allowed_mentions);
519521
$message->setReplyTo($replyTo);
520522
}

src/Discord/Parts/Channel/Message/MediaGallery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
class MediaGallery extends Content
3333
{
3434
/**
35-
* {@inheritDoc}
35+
* @inheritDoc
3636
*/
3737
protected $fillable = [
3838
'type',

src/Discord/Parts/Channel/Message/MessagePinData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class MessagePinData extends Part
3131
{
3232
/**
33-
* {@inheritDoc}
33+
* @inheritDoc
3434
*/
3535
protected $fillable = [
3636
'items',

src/Discord/Parts/Guild/AuditLog/Entry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class Entry extends Part
175175
// AUDIT LOG ENTRY TYPES
176176

177177
/**
178-
* {@inheritDoc}
178+
* @inheritDoc
179179
*/
180180
protected $fillable = [
181181
'target_id',

src/Discord/Parts/Guild/Role.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Role extends Part implements Stringable
4949
public const IN_PROMPT = 1 << 0; // Role can be selected by members in an onboarding prompt.
5050

5151
/**
52-
* {@inheritDoc}
52+
* @inheritDoc
5353
*/
5454
protected $fillable = [
5555
'id',
@@ -196,7 +196,7 @@ protected function getTagsAttribute(): ?RoleTags
196196
}
197197

198198
/**
199-
* {@inheritDoc}
199+
* @inheritDoc
200200
*
201201
* @link https://discord.com/developers/docs/resources/guild#create-guild-role-json-params
202202
*/
@@ -214,7 +214,7 @@ public function getCreatableAttributes(): array
214214
}
215215

216216
/**
217-
* {@inheritDoc}
217+
* @inheritDoc
218218
*
219219
* @link https://discord.com/developers/docs/resources/guild#modify-guild-role-json-params
220220
*/
@@ -232,7 +232,7 @@ public function getUpdatableAttributes(): array
232232
}
233233

234234
/**
235-
* {@inheritDoc}
235+
* @inheritDoc
236236
*/
237237
public function getRepositoryAttributes(): array
238238
{

src/Discord/Parts/PartInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getUpdatableAttributes(): array;
5151
//protected function makeOptionalAttributes(array $attributes): array;
5252
public function getDiscord(): Discord;
5353
public function createOf(string $class, array|object $data): self;
54-
//private static function studly(string $string): string;
54+
//private static function studly(string $string, bool $ucfirst = true): string;
5555
public function __toString(): string;
5656
public function __debugInfo(): array;
5757
public function __get(string $key);

src/Discord/Parts/PartTrait.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -419,13 +419,14 @@ public function createOf(string $class, array|object $data): self
419419
* do not want to introduce BC by replacing it. This method is private
420420
* static as we may move it outside this class in future.
421421
*
422-
* @param string $string The string to convert.
422+
* @param string $string The string to convert.
423+
* @param bool $ucfirst Whether to uppercase the first character.
423424
*
424425
* @return string
425426
*
426427
* @since 10.0.0
427428
*/
428-
private static function studly(string $string): string
429+
private static function studly(string $string, bool $ucfirst = true): string
429430
{
430431
static $studlyCache = [];
431432

@@ -435,7 +436,7 @@ private static function studly(string $string): string
435436

436437
$words = explode(' ', str_replace(['-', '_'], ' ', $string));
437438

438-
$studlyWords = array_map('ucfirst', $words);
439+
$studlyWords = array_map($ucfirst ? 'ucfirst' : null, $words);
439440

440441
return $studlyCache[$string] = implode($studlyWords);
441442
}
@@ -454,6 +455,7 @@ public function getConstArray(): array
454455
foreach ($reflection->getConstants() as $name => $value) {
455456
$map[$name] = $value;
456457
}
458+
457459
return $map;
458460
}
459461

src/Discord/Parts/User/Activity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @property Carbon|null $created_at Timestamp of when the activity was added to the user's session.
3333
* @property object|null $timestamps Unix timestamps for start and/or end of the game.
3434
* @property string|null $application_id Application id for the game.
35-
* @property ?integer|null $status_display_type Status display type; controls which field is displayed in the user's status text in the member list.
35+
* @property ?int|null $status_display_type Status display type; controls which field is displayed in the user's status text in the member list.
3636
* @property ?string|null $details What the player is currently doing.
3737
* @property ?string|null $details_url URL that is linked when clicking on the details text
3838
* @property ?string|null $state The user's current party status, or text used for a custom status.

0 commit comments

Comments
 (0)