45 lines
1.2 KiB
PHP
45 lines
1.2 KiB
PHP
<?php
|
|
// namespace
|
|
namespace sven\sys\sven;
|
|
|
|
/**
|
|
* uncallable
|
|
*
|
|
* Wrapper to reduce fatal errors
|
|
*
|
|
* @package sven\sys\sven
|
|
* @copyright 2018 Ruben Meyer
|
|
* @author Ruben Meyer <contact@rxbn.de>
|
|
* @version 0.1.0
|
|
* @TODO Documentation
|
|
*/
|
|
class uncallable {
|
|
private $name = "";
|
|
private $line = 0;
|
|
private $trace = null;
|
|
|
|
public function __construct() {
|
|
$this->trace = $trace = debug_backtrace();
|
|
$this->line = $trace[0]['line'];
|
|
$this->name = "\\".$trace[count($trace)-1]['class'];
|
|
$this->fn = $trace[count($trace)-1]['function'];
|
|
|
|
if(!empty($trace[count($trace)-1]['args']))
|
|
$this->fn .= "('".implode("', '", $trace[count($trace)-1]['args'])."')";
|
|
else
|
|
$this->fn .= "()";
|
|
}
|
|
|
|
public function __call($name, $arguments) {
|
|
$call = "{$this->fn}->{$name}";
|
|
if(!empty($arguments))
|
|
$message = "Can't call {$call}('".implode("', '", $arguments)."')";
|
|
else
|
|
$message = "Can't call {$call}()";
|
|
\sven\sys\core::addException(new \sven\sys\Exception("ERROR: Uncallable Function in {$this->name} at line {$this->line}", $message, 404));
|
|
return new uncallable;
|
|
}
|
|
};
|
|
|
|
?>
|