<commit_before><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  /**
   * Indicates the XML cannot be parsed (i.e., it is not well-formed). 
   *
   * The error type can be retrieved via the getType() method and will
   * be one of the following constants:
   * <pre>
   *   XML_ERROR_NONE                         
   *   XML_ERROR_NO_MEMORY                    
   *   XML_ERROR_SYNTAX                       
   *   XML_ERROR_NO_ELEMENTS                  
   *   XML_ERROR_INVALID_TOKEN                
   *   XML_ERROR_UNCLOSED_TOKEN               
   *   XML_ERROR_PARTIAL_CHAR                 
   *   XML_ERROR_TAG_MISMATCH                 
   *   XML_ERROR_DUPLICATE_ATTRIBUTE          
   *   XML_ERROR_JUNK_AFTER_DOC_ELEMENT       
   *   XML_ERROR_PARAM_ENTITY_REF             
   *   XML_ERROR_UNDEFINED_ENTITY             
   *   XML_ERROR_RECURSIVE_ENTITY_REF         
   *   XML_ERROR_ASYNC_ENTITY                 
   *   XML_ERROR_BAD_CHAR_REF                 
   *   XML_ERROR_BINARY_ENTITY_REF            
   *   XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF
   *   XML_ERROR_MISPLACED_XML_PI             
   *   XML_ERROR_UNKNOWN_ENCODING             
   *   XML_ERROR_INCORRECT_ENCODING           
   *   XML_ERROR_UNCLOSED_CDATA_SECTION       
   *   XML_ERROR_EXTERNAL_ENTITY_HANDLING        
   * </pre>
   *
   * @purpose  Exception
   */
  class XMLFormatException extends FormatException {
    public
      $type     = 0,
      $file     = '',
      $line     = 0,
      $column   = 0;
  
    /**
     * Constructor
     *
     * @access  public
     * @param   string message
     * @param   int type default XML_ERROR_SYNTAX
     * @param   string file default NULL
     * @param   int line
     * @param   int column
     */
    public function __construct(
      $message, 
      $type = XML_ERROR_SYNTAX,
      $file = NULL,
      $line = 0,
      $column = 0
    ) {
      parent::__construct($message);
      $this->type= $type;
      $this->file= $file;
      $this->line= $line;
      $this->column= $column;
    }
    
    /**
     * Returns a string representation of this exception
     *
     * @access  public
     * @return  string
     */
    public function toString() {      
      $s= sprintf(
        "%s@('%s'){\n".
        "  type     %d (%s)\n".
        "  file     %s\n".
        "  line     %d\n".
        "  column   %d\n".
        "}\n",
        self::getClassName(),
        self::getMessage(),
        self::getType(),
        self::getTypeName(),
        var_export(self::getFile(), 1),
        self::getLine(),
        self::getColumn()
      );
      for ($i= 0, $t= sizeof($this->trace); $i < $t; $i++) {
        $s.= $this->trace[$i]->toString();
      }
      return $s;
    }

    /**
     * Get Type
     *
     * @access  public
     * @return  int
     */
    public function getType() {
      return $this->type;
    }
    
    /**
     * Get Type's name
     *
     * @access  public
     * @return  string
     */
    public function getTypeName() {
      static $types= array(
        XML_ERROR_NONE                           => 'NONE',
        XML_ERROR_NO_MEMORY                      => 'NO_MEMORY',
        XML_ERROR_SYNTAX                         => 'SYNTAX',
        XML_ERROR_NO_ELEMENTS                    => 'NO_ELEMENTS',
        XML_ERROR_INVALID_TOKEN                  => 'INVALID_TOKEN',
        XML_ERROR_UNCLOSED_TOKEN                 => 'UNCLOSED_TOKEN',
        XML_ERROR_PARTIAL_CHAR                   => 'PARTIAL_CHAR',
        XML_ERROR_TAG_MISMATCH                   => 'TAG_MISMATCH',
        XML_ERROR_DUPLICATE_ATTRIBUTE            => 'DUPLICATE_ATTRIBUTE',
        XML_ERROR_JUNK_AFTER_DOC_ELEMENT         => 'JUNK_AFTER_DOC_ELEMENT',
        XML_ERROR_PARAM_ENTITY_REF               => 'PARAM_ENTITY_REF',
        XML_ERROR_UNDEFINED_ENTITY               => 'UNDEFINED_ENTITY',
        XML_ERROR_RECURSIVE_ENTITY_REF           => 'RECURSIVE_ENTITY_REF',
        XML_ERROR_ASYNC_ENTITY                   => 'ASYNC_ENTITY',
        XML_ERROR_BAD_CHAR_REF                   => 'BAD_CHAR_REF',
        XML_ERROR_BINARY_ENTITY_REF              => 'BINARY_ENTITY_REF',
        XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF  => 'ATTRIBUTE_EXTERNAL_ENTITY_REF',
        XML_ERROR_MISPLACED_XML_PI               => 'MISPLACED_XML_PI',
        XML_ERROR_UNKNOWN_ENCODING               => 'UNKNOWN_ENCODING',
        XML_ERROR_INCORRECT_ENCODING             => 'INCORRECT_ENCODING',
        XML_ERROR_UNCLOSED_CDATA_SECTION         => 'UNCLOSED_CDATA_SECTION',
        XML_ERROR_EXTERNAL_ENTITY_HANDLING       => 'EXTERNAL_ENTITY_HANDLING',
      );
      return $types[$this->type];
    }

    /**
     * Get File
     *
     * @access  public
     * @return  string
     */
    public function getFile() {
      return $this->file;
    }

    /**
     * Get Line
     *
     * @access  public
     * @return  int
     */
    public function getLine() {
      return $this->line;
    }

    /**
     * Get Column
     *
     * @access  public
     * @return  int
     */
    public function getColumn() {
      return $this->column;
    }  
  }
?>
<commit_msg>- Prevent Fatal error: Cannot override final method   exception::getFile() due to required subclassing of exceptions   from the built-in exception class # See http://zend.com/lists/php-dev/200402/msg00393.html # and http://zend.com/lists/php-dev/200402/msg00405.html # but I guess this won`t happen<commit_after><?php
/* This class is part of the XP framework
 *
 * $Id$ 
 */

  /**
   * Indicates the XML cannot be parsed (i.e., it is not well-formed). 
   *
   * The error type can be retrieved via the getType() method and will
   * be one of the following constants:
   * <pre>
   *   XML_ERROR_NONE                         
   *   XML_ERROR_NO_MEMORY                    
   *   XML_ERROR_SYNTAX                       
   *   XML_ERROR_NO_ELEMENTS                  
   *   XML_ERROR_INVALID_TOKEN                
   *   XML_ERROR_UNCLOSED_TOKEN               
   *   XML_ERROR_PARTIAL_CHAR                 
   *   XML_ERROR_TAG_MISMATCH                 
   *   XML_ERROR_DUPLICATE_ATTRIBUTE          
   *   XML_ERROR_JUNK_AFTER_DOC_ELEMENT       
   *   XML_ERROR_PARAM_ENTITY_REF             
   *   XML_ERROR_UNDEFINED_ENTITY             
   *   XML_ERROR_RECURSIVE_ENTITY_REF         
   *   XML_ERROR_ASYNC_ENTITY                 
   *   XML_ERROR_BAD_CHAR_REF                 
   *   XML_ERROR_BINARY_ENTITY_REF            
   *   XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF
   *   XML_ERROR_MISPLACED_XML_PI             
   *   XML_ERROR_UNKNOWN_ENCODING             
   *   XML_ERROR_INCORRECT_ENCODING           
   *   XML_ERROR_UNCLOSED_CDATA_SECTION       
   *   XML_ERROR_EXTERNAL_ENTITY_HANDLING        
   * </pre>
   *
   * @purpose  Exception
   */
  class XMLFormatException extends FormatException {
    public
      $type       = 0,
      $filename   = '',
      $linenumber = 0,
      $column     = 0;
  
    /**
     * Constructor
     *
     * @access  public
     * @param   string message
     * @param   int type default XML_ERROR_SYNTAX
     * @param   string file default NULL
     * @param   int line
     * @param   int column
     */
    public function __construct(
      $message, 
      $type = XML_ERROR_SYNTAX,
      $file = NULL,
      $line = 0,
      $column = 0
    ) {
      parent::__construct($message);
      $this->type= $type;
      $this->filename= $file;
      $this->linenumber= $line;
      $this->column= $column;
    }
    
    /**
     * Returns a string representation of this exception
     *
     * @access  public
     * @return  string
     */
    public function toString() {      
      $s= sprintf(
        "%s@('%s'){\n".
        "  type     %d (%s)\n".
        "  file     %s\n".
        "  line     %d\n".
        "  column   %d\n".
        "}\n",
        self::getClassName(),
        self::getMessage(),
        self::getType(),
        self::getTypeName(),
        var_export(self::getFileName(), 1),
        self::getLineNumber(),
        self::getColumn()
      );
      for ($i= 0, $t= sizeof($this->trace); $i < $t; $i++) {
        $s.= $this->trace[$i]->toString();
      }
      return $s;
    }

    /**
     * Get Type
     *
     * @access  public
     * @return  int
     */
    public function getType() {
      return $this->type;
    }
    
    /**
     * Get Type's name
     *
     * @access  public
     * @return  string
     */
    public function getTypeName() {
      static $types= array(
        XML_ERROR_NONE                           => 'NONE',
        XML_ERROR_NO_MEMORY                      => 'NO_MEMORY',
        XML_ERROR_SYNTAX                         => 'SYNTAX',
        XML_ERROR_NO_ELEMENTS                    => 'NO_ELEMENTS',
        XML_ERROR_INVALID_TOKEN                  => 'INVALID_TOKEN',
        XML_ERROR_UNCLOSED_TOKEN                 => 'UNCLOSED_TOKEN',
        XML_ERROR_PARTIAL_CHAR                   => 'PARTIAL_CHAR',
        XML_ERROR_TAG_MISMATCH                   => 'TAG_MISMATCH',
        XML_ERROR_DUPLICATE_ATTRIBUTE            => 'DUPLICATE_ATTRIBUTE',
        XML_ERROR_JUNK_AFTER_DOC_ELEMENT         => 'JUNK_AFTER_DOC_ELEMENT',
        XML_ERROR_PARAM_ENTITY_REF               => 'PARAM_ENTITY_REF',
        XML_ERROR_UNDEFINED_ENTITY               => 'UNDEFINED_ENTITY',
        XML_ERROR_RECURSIVE_ENTITY_REF           => 'RECURSIVE_ENTITY_REF',
        XML_ERROR_ASYNC_ENTITY                   => 'ASYNC_ENTITY',
        XML_ERROR_BAD_CHAR_REF                   => 'BAD_CHAR_REF',
        XML_ERROR_BINARY_ENTITY_REF              => 'BINARY_ENTITY_REF',
        XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF  => 'ATTRIBUTE_EXTERNAL_ENTITY_REF',
        XML_ERROR_MISPLACED_XML_PI               => 'MISPLACED_XML_PI',
        XML_ERROR_UNKNOWN_ENCODING               => 'UNKNOWN_ENCODING',
        XML_ERROR_INCORRECT_ENCODING             => 'INCORRECT_ENCODING',
        XML_ERROR_UNCLOSED_CDATA_SECTION         => 'UNCLOSED_CDATA_SECTION',
        XML_ERROR_EXTERNAL_ENTITY_HANDLING       => 'EXTERNAL_ENTITY_HANDLING',
      );
      return $types[$this->type];
    }

    /**
     * Get File
     *
     * @access  public
     * @return  string
     */
    public function getFileName() {
      return $this->filename;
    }

    /**
     * Get Line
     *
     * @access  public
     * @return  int
     */
    public function getLineNumber() {
      return $this->linenumber;
    }

    /**
     * Get Column
     *
     * @access  public
     * @return  int
     */
    public function getColumn() {
      return $this->column;
    }  
  }
?>

{'fraction_non_alphanumeric': 0.09648875082368445, 'fraction_numerical': 0.003388873199661113, 'mean_word_length': 1.569286577992745, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4735994', 'n_tokens_mistral': 3500, 'n_tokens_neox': 3405, 'n_words': 572}