for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @file
* Query path parsing exception.
*/
namespace QueryPath;
* Exception indicating that a parser has failed to parse a file.
*
* This will report parser warnings as well as parser errors. It should only be
* thrown, though, under error conditions.
* @ingroup querypath_core
class ParseException extends \QueryPath\Exception
{
public const ERR_MSG_FORMAT = 'Parse error in %s on line %d column %d: %s (%d)';
public const WARN_MSG_FORMAT = 'Parser warning in %s on line %d column %d: %s (%d)';
// trigger_error
public function __construct($msg = '', $code = 0, $file = NULL, $line = NULL)
$msgs = [];
foreach (libxml_get_errors() as $err) {
$format = $err->level === LIBXML_ERR_WARNING ? self::WARN_MSG_FORMAT : self::ERR_MSG_FORMAT;
$msgs[] = sprintf($format, $err->file, $err->line, $err->column, $err->message, $err->code);
}
$msg .= implode("\n", $msgs);
if (isset($file)) {
$msg .= ' (' . $file;
if (isset($line)) {
$msg .= ': ' . $line;
$msg .= ')';
parent::__construct($msg, $code);
public static function initializeFromError($code, $str, $file, $line, $cxt)
$cxt
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public static function initializeFromError($code, $str, $file, $line, /** @scrutinizer ignore-unused */ $cxt)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
//printf("\n\nCODE: %s %s\n\n", $code, $str);
$class = __CLASS__;
throw new $class($str, $code, $file, $line);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.