use Psr\Http\Server\RequestHandlerInterface;
use wcf\http\Helper;
use wcf\system\endpoint\controller\core\messages\MentionSuggestions;
-use wcf\system\endpoint\Parameters;
/**
* Suggests users that may be mentioned.
\assert(\count($parameters) === 1);
\assert($parameters[0]->getName() === 'parameters');
- $attribute = current($parameters[0]->getAttributes(Parameters::class));
+ $type = $parameters[0]->getType();
- \assert($attribute !== false);
+ \assert($type instanceof \ReflectionNamedType);
$parameters = Helper::mapQueryParameters(
$request->getQueryParams(),
- $attribute->newInstance()->arrayShape,
+ $type->getName(),
);
return (new MentionSuggestions())->mentionSuggestions($parameters);
{
#[GetRequest('/core/messages/mentionsuggestions')]
public function mentionSuggestions(
- #[Parameters(
- <<<'EOT'
- array {
- query: non-empty-string
- }
- EOT,
- )]
- array $parameters
+ #[Parameters] MentionSuggestionsParameters $parameters
): ResponseInterface {
- $query = \mb_strtolower($parameters['query']);
+ $query = \mb_strtolower($parameters->query);
$matches = [];
foreach ($this->getGroups($query) as $userGroup) {
return $userGroups;
}
}
+
+/** @internal */
+final class MentionSuggestionsParameters
+{
+ public function __construct(
+ /** @var non-empty-string */
+ public readonly string $query,
+ ) {
+ }
+}