PhpParser\Error::__construct PHP Method

__construct() public method

Creates an Exception signifying a parse error.
public __construct ( string $message, array | integer $attributes = [] )
$message string Error message
$attributes array | integer Attributes of node/token where error occurred (or start line of error -- deprecated)
    public function __construct($message, $attributes = array())
    {
        $this->rawMessage = (string) $message;
        if (is_array($attributes)) {
            $this->attributes = $attributes;
        } else {
            $this->attributes = array('startLine' => $attributes);
        }
        $this->updateMessage();
    }

Usage Example

 /**
  * Constructor!
  *
  * @param string $message (default: "")
  * @param int    $line    (default: -1)
  */
 public function __construct($message = '', $line = -1)
 {
     $message = sprintf('PHP Parse error: %s', $message);
     parent::__construct($message, $line);
 }