-
-
Notifications
You must be signed in to change notification settings - Fork 252
Create OptionsResolver normalizers #1455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9e13b6c
c95cc5e
f52d883
ecb9b81
1d9cb2b
3e25411
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -63,6 +63,7 @@ | |||||||||
| use Ratchet\Client\Connector; | ||||||||||
| use Ratchet\Client\WebSocket; | ||||||||||
| use Ratchet\RFC6455\Messaging\Message; | ||||||||||
| use React\Dns\Config\Config as DnsConfig; | ||||||||||
| use React\EventLoop\Loop; | ||||||||||
| use React\EventLoop\LoopInterface; | ||||||||||
| use React\EventLoop\TimerInterface; | ||||||||||
|
|
@@ -100,6 +101,29 @@ | |||||||||
| * @property SoundRepository $sounds | ||||||||||
| * @property StickerPackRepository $sticker_packs | ||||||||||
| * @property UserRepository $users | ||||||||||
| * | ||||||||||
| * @property array $options | ||||||||||
| * @property string $options['token'] | ||||||||||
| * @property LoggerInterface $options['logger'] | ||||||||||
| * @property LoopInterface $options['loop'] | ||||||||||
| * @property array|bool $options['loadAllMembers'] | ||||||||||
| * @property array $options['disabledEvents'] | ||||||||||
| * @property bool $options['storeMessages'] | ||||||||||
| * @property array|bool $options['retrieveBans'] | ||||||||||
| * @property int|null $options['large_threshold'] | ||||||||||
| * @property array|null $options['shard'] | ||||||||||
| * @property int|null $options['shard_id'] | ||||||||||
| * @property int|null $options['num_shards'] | ||||||||||
| * @property int|null $options['shardId'] | ||||||||||
| * @property int|null $options['shardCount'] | ||||||||||
| * @property array|null $options['presence'] | ||||||||||
| * @property int $options['intents'] | ||||||||||
| * @property array $options['socket_options'] | ||||||||||
| * @property DnsConfig|string $options['dnsConfig'] | ||||||||||
| * @property array $options['cache'] | ||||||||||
| * @property string $options['collection'] | ||||||||||
| * @property bool $options['useTransportCompression'] | ||||||||||
| * @property bool $options['usePayloadCompression'] | ||||||||||
| */ | ||||||||||
| class Discord | ||||||||||
| { | ||||||||||
|
|
@@ -1703,7 +1727,8 @@ protected function resolveOptions(array $options = []): array | |||||||||
| 'usePayloadCompression', | ||||||||||
| ]) | ||||||||||
| ->setDefaults([ | ||||||||||
| 'logger' => null, | ||||||||||
| 'loop' => Loop::get(), | ||||||||||
| 'logger' => new Monolog('DiscordPHP', [(new StreamHandler('php://stdout', Level::Debug))->setFormatter(new LineFormatter(null, null, true, true))]), | ||||||||||
|
Comment on lines
+1730
to
+1731
|
||||||||||
| 'loop' => Loop::get(), | |
| 'logger' => new Monolog('DiscordPHP', [(new StreamHandler('php://stdout', Level::Debug))->setFormatter(new LineFormatter(null, null, true, true))]), | |
| 'loop' => null, | |
| 'logger' => null, |
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dnsConfig normalizer only runs when the caller explicitly sets the option; since dnsConfig has no default in the resolver, omitting it will bypass this normalizer and rely on separate manual initialization later in resolveOptions(). To fully centralize normalization, consider setting a default (e.g. null) so the normalizer always executes, and then remove the later manual dnsConfig fallback block.
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added collection allowed-types + normalizer block duplicates an existing collection configuration later in this method (there’s already another setAllowedTypes('collection', ...) + normalizer below). This results in the same option being configured twice and makes future changes error-prone; keep only a single collection configuration block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PHPDoc uses
@propertytags with array offsets (e.g.$options['token']). This syntax isn’t understood by most PHPDoc parsers (including phpDocumentor), so it’s likely to be ignored or mis-parsed. If the goal is to document the options array shape for tooling, consider using an@var array{...}shape (or a@phpstan-type/@psalm-type) instead of@propertyentries for offsets.