\XF::asVisitor should use phpdoc template for return type hint.

Xon

Well-known member
Affected version
2.3.2
Using asVisitor destroys the return type for phpstorm static analysis, but with phpdoc templates this can be fixed:

PHP:
/**
 * Temporarily take an action with the given user considered to be the visitor
 *
 * @template T
 * @param User $user
 * @param callable(): T $action
 * @param bool $withLanguage If true, the action will be taken with the given user's language
 * @return T
 *
 * @throws \Exception
 */
public static function asVisitor(User $user, callable $action, bool $withLanguage = false)

phpdocs syntax for setting the arguments and return type works with callables and not Closures.

There might be a few other locations which also could do with updating for return type from callables/closures.
 
Back
Top Bottom