本文整理汇总了PHP中Error::getFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Error::getFile方法的具体用法?PHP Error::getFile怎么用?PHP Error::getFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Error
的用法示例。
在下文中一共展示了Error::getFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAttributes
public function testGetAttributes()
{
$this->assertEquals('error_type', $this->error->getType());
$this->assertEquals('error_file', $this->error->getFile());
$this->assertEquals('error_line', $this->error->getLine());
$this->assertEquals('error_char', $this->error->getChar());
$this->assertEquals('error_code', $this->error->getCode());
}
示例2: test
public function test()
{
$error = new Error(E_ERROR, 'message', 'file', 0);
$this->assertSame(E_ERROR, $error->getSeverity());
$this->assertSame('message', $error->getMessage());
$this->assertSame('Fatal error', $error->getSeverityAsString());
$this->assertSame('E_ERROR', $error->getSeverityAsConstantName());
$this->assertSame('file', $error->getFile());
$this->assertSame(0, $error->getLine());
$this->assertSame('Fatal error: message in file on line 0', (string) $error);
}
示例3: getTraceElements
/**
* @param \Error|\Exception $ex
* @param int $offset
* @return string[]
*/
protected static function getTraceElements($ex, $offset = 0)
{
$trace = $ex->getTrace();
$file = str_replace('.php', '', basename($ex->getFile()));
$elements = ['[throwable] ' . get_class($ex) . '(...) in ' . $file . ':' . $ex->getLine()];
foreach ($trace as $currentTrack) {
$elements[] = static::parseTraceElement($currentTrack);
}
$elements[] = '[main]';
array_splice($elements, -$offset + 1, $offset);
return $elements;
}
示例4: applyCodeInfo
private static function applyCodeInfo(ThrowableInfo $throwableInfo, \Error $e)
{
$filePath = $e->getFile();
$lineNo = $e->getLine();
self::findCallPos($e, $filePath, $lineNo);
if ($filePath !== null) {
$throwableInfo->addCodeInfo(self::createCodeInfo($filePath, $lineNo));
}
}
示例5: newMessage
/**
* New exception.
*
* @param Exception $exception
* @param boolean $printError
* show error or not
* @param boolean $clear
* clear the errorlog
* @param string $errorFile
* file to save to
*/
public static function newMessage(\Error $exception)
{
$message = $exception->getMessage();
$code = $exception->getCode();
$file = $exception->getFile();
$line = $exception->getLine();
$trace = $exception->getTraceAsString();
$trace = str_replace(DB_PASS, '********', $trace);
$date = date('M d, Y G:iA');
$logMessage = "<h3>Exception information:</h3>\n\n <p><strong>Date:</strong> {$date}</p>\n\n <p><strong>Message:</strong> {$message}</p>\n\n <p><strong>Code:</strong> {$code}</p>\n\n <p><strong>File:</strong> {$file}</p>\n\n <p><strong>Line:</strong> {$line}</p>\n\n <h3>Stack trace:</h3>\n\n <pre>{$trace}</pre>\n\n <hr />\n";
$errorFile = self::getCurrentErrorLog();
if (is_file($errorFile) === false) {
file_put_contents($errorFile, '');
}
if (self::$clear) {
$f = fopen($errorFile, "r+");
if ($f !== false) {
ftruncate($f, 0);
fclose($f);
}
$content = null;
} else {
$content = file_get_contents($errorFile);
}
file_put_contents($errorFile, $logMessage . $content);
if (self::$printError == true) {
echo $logMessage;
exit;
}
}