phpmodel-view-controllerdocblocks

Using DocBlocks - how to indicate that a function returns a value only in some conditions?


I have this function:

public function createController()
{
    $valid_controller = class_exists($this->controllerClass)
                    &&  in_array("BaseController", class_parents($this->controllerClass));

    if($valid_controller)
    {
        return new $this->controllerClass($this->urlData["action"]);
    }
    else
    {
        $error = new ErrorController("badurl");
    }
}

and I want to create a DocBlock that describe it. This function returns a controller object only if the required controller is valid, and if not, it creates an instace of the ErrorController class, but does not return a value. How can I right a proper @return tag for this function?


Solution

  • PHPDocumentor Docs say to use

    @return  null|ControllerClass    text description or explanation here