for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* DronePHP (http://www.dronephp.com)
*
* @link http://github.com/Pleets/DronePHP
* @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org)
* @license http://www.dronephp.com/license
* @author Darío Rivera <[email protected]>
*/
namespace Drone\Mvc;
* View class
* This class manages views and parameters
class View
{
use \Drone\Util\ParamTrait;
* View name
* @var string
protected $name;
* The path where views are located.
protected $path;
* Returns the view name
* @return string
public function getName()
return $this->name;
}
* Returns the path
public function getPath()
return $this->path;
* Sets the view name
* @param string
* @return null
public function setName($name)
$this->name = $name;
* Sets the path
public function setPath($path)
$this->path = $path;
* Constructor
* @param string $name
* @param array $parameters
public function __construct($name, Array $parameters = [])
$this->setParams($parameters);
* Get the contents of the view
* @throws Exception\ViewNotFoundException
public function getContents()
$_view = $this->path . DIRECTORY_SEPARATOR . $this->name . '.phtml';
if (!file_exists($_view))
throw new Exception\ViewNotFoundException("The view '" .$this->name. "' does not exists");
$contents = file_get_contents($_view);
if ($contents === false)
throw new Exception\ViewGetContentsErrorException("The view '" .$this->name. "' does not exists");
return $contents;
return $contents
string
null
* Loads the view
public function render()
if (count($this->getParams()))
extract($this->getParams(), EXTR_SKIP);
include $this->getContents();
$this->getContents()
Drone\Mvc\View::getContents()
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.