Home » Php » php – What is the return type of View::make in Laravel?

php – What is the return type of View::make in Laravel?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I like clean docs and phpdoc will automagically look up the type. When documenting a controller function that returns View::make, I have no idea what type to use for the @return in my documentation.

<?php

class FooController extends BaseController {

    /**
     * Show a view.
     *
     * @return  ??? description of the view
     */
    public function show(){
        return View::make('bar');
    }

}

What is the type here or is there a better way to document the function for this purpose?

How to&Answers:

The return value is

Illuminate\View\View

I traced through the ServiceProvider which lead me to

Illuminate\View\Environment::make

Which is line 113 of vendor/laravel/framework/src/Illuminate/View/Environment.php (in 4.1 at least)

/**
 * Get a evaluated view contents for the given view.
 *
 * @param  string  $view
 * @param  array   $data
 * @param  array   $mergeData
 * @return \Illuminate\View\View
 */
public function make($view, $data = array(), $mergeData = array())
{
    $path = $this->finder->find($view);

    $data = array_merge($mergeData, $this->parseData($data));

    $this->callCreator($view = new View($this, $this->getEngineFromPath($path), $view, $path, $data));

    return $view;
}