Fixed No return type hinting on Controller noPermission/notFound

Xon

Well-known member
Affected version
2.2.0
Mostly phpstorm/intellij can infer the return types for various helper methods in XF\Mvc\Controller but there are a couple methods which can't be inferred without either php7 return types of docblock or additional configuration (php metadata which can be expensive or hard to use with multiple add-ons/XF)

Without docblock or return types, this causes phpstorm to incorrectly infer the possible return types too narrowly when possible noPermission/notFound are called as these can return view/error/message types.

Something like;
PHP:
/**
 * @param \XF\Phrase|string|null $message
 * @return \XF\Mvc\Reply\AbstractReply
 */
public function noPermission($message = null)
{
   return $this->plugin('XF:Error')->actionNoPermission($message);
}

/**
 * @param \XF\Phrase|string|null $message
 * @return \XF\Mvc\Reply\AbstractReply
 */
public function notFound($message = null)
{
   return $this->plugin('XF:Error')->actionNotFound($message);
}
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.1).

Change log:
Add PHPDocs to noPermission() and notFound() controller methods
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom