class FileInputStream
The FileInputStream loads a file to be parsed.
So right now we read files into strings and then process the string. We chose to do this largely for the sake of expediency of development, and also because we could optimize toward processing arbitrarily large chunks of the input. But in the future, we'd really like to rewrite this class to efficiently handle lower level stream reads (and thus efficiently handle large documents).
Hierarchy
- class \Masterminds\HTML5\Parser\StringInputStream implements \Masterminds\HTML5\Parser\InputStream
- class \Masterminds\HTML5\Parser\FileInputStream extends \Masterminds\HTML5\Parser\StringInputStream implements \Masterminds\HTML5\Parser\InputStream
Expanded class hierarchy of FileInputStream
Deprecated
since 2.4, to remove in 3.0. Use a string in the scanner instead.
File
-
vendor/
masterminds/ html5/ src/ HTML5/ Parser/ FileInputStream.php, line 17
Namespace
Masterminds\HTML5\ParserView source
class FileInputStream extends StringInputStream implements InputStream {
/**
* Load a file input stream.
*
* @param string $data The file or url path to load.
* @param string $encoding The encoding to use for the data.
* @param string $debug A fprintf format to use to echo the data on stdout.
*/
public function __construct($data, $encoding = 'UTF-8', $debug = '') {
// Get the contents of the file.
$content = file_get_contents($data);
parent::__construct($content, $encoding, $debug);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
---|---|---|---|---|
FileInputStream::__construct | public | function | Load a file input stream. | Overrides StringInputStream::__construct |
StringInputStream::$char | private | property | The current integer byte position we are in $data. | |
StringInputStream::$data | private | property | The string data we're parsing. | |
StringInputStream::$EOF | private | property | Length of $data; when $char === $data, we are at the end-of-file. | |
StringInputStream::$errors | public | property | Parse errors. | |
StringInputStream::charsUntil | public | function | Read to a particular match (or until $max bytes are consumed). | Overrides InputStream::charsUntil |
StringInputStream::charsWhile | public | function | Returns the string so long as $bytes matches. | Overrides InputStream::charsWhile |
StringInputStream::columnOffset | public | function | Returns the current column of the current line that the tokenizer is at. Newlines are column 0. The first char after a newline is column 1. |
Overrides InputStream::columnOffset |
StringInputStream::current | public | function | Get the current character. | |
StringInputStream::currentLine | public | function | Returns the current line that the tokenizer is at. | Overrides InputStream::currentLine |
StringInputStream::getColumnOffset | public | function | ||
StringInputStream::getCurrentLine | public | function | ||
StringInputStream::key | public | function | ||
StringInputStream::next | public | function | Advance the pointer. This is part of the Iterator interface. |
|
StringInputStream::peek | public | function | Look ahead without moving cursor. | Overrides InputStream::peek |
StringInputStream::remainingChars | public | function | Get all characters until EOF. | Overrides InputStream::remainingChars |
StringInputStream::replaceLinefeeds | protected | function | Replace linefeed characters according to the spec. | |
StringInputStream::rewind | public | function | Rewind to the start of the string. | |
StringInputStream::unconsume | public | function | Unconsume characters. | Overrides InputStream::unconsume |
StringInputStream::valid | public | function | Is the current pointer location valid. | |
StringInputStream::__toString | public | function |