protected function saveString()
	{
		$startpos = $this->index;

		// saveString is always called after a gets cleared, so we push b into
		// that spot.
		$this->a = $this->b;

		// If this isn't a string we don't need to do anything.
		if ($this->a !== "'" && $this->a !== '"')
		{
			return;
		}

		// String type is the quote used, " or '
		$stringType = $this->a;

		// Echo out that starting quote
		echo $this->a;

		// Loop until the string is done
		while (true)
		{
			// Grab the very next character and load it into a
			$this->a = $this->getChar();

			switch ($this->a)
			{
				// If the string opener (single or double quote) is used
				// output it and break out of the while loop-
				// The string is finished!
				case $stringType:
					break 2;

				// New lines in strings without line delimiters are bad- actual
				// new lines will be represented by the string \n and not the actual
				// character, so those will be treated just fine using the switch
				// block below.
				case "\n":
					throw new \RuntimeException('Unclosed string at position: ' . $startpos);
					break;

				// Escaped characters get picked up here. If it's an escaped new line it's not really needed
				case '\\':

					// a is a slash. We want to keep it, and the next character,
					// unless it's a new line. New lines as actual strings will be
					// preserved, but escaped new lines should be reduced.
					$this->b = $this->getChar();

					// If b is a new line we discard a and b and restart the loop.
					if ($this->b === "\n")
					{
						break;
					}

					// echo out the escaped character and restart the loop.
					echo $this->a . $this->b;
					break;


				// Since we're not dealing with any special cases we simply
				// output the character and continue our loop.
				default:
					echo $this->a;
			}
		}
	}
protected function saveString()
	{
		$startpos = $this->index;

		// saveString is always called after a gets cleared, so we push b into
		// that spot.
		$this->a = $this->b;

		// If this isn't a string we don't need to do anything.
		if ($this->a !== "'" && $this->a !== '"')
		{
			return;
		}

		// String type is the quote used, " or '
		$stringType = $this->a;

		// Echo out that starting quote
		echo $this->a;

		// Loop until the string is done
		while (true)
		{
			// Grab the very next character and load it into a
			$this->a = $this->getChar();

			switch ($this->a)
			{
				// If the string opener (single or double quote) is used
				// output it and break out of the while loop-
				// The string is finished!
				case $stringType:
					break 2;

				// New lines in strings without line delimiters are bad- actual
				// new lines will be represented by the string \n and not the actual
				// character, so those will be treated just fine using the switch
				// block below.
				case "\n":
					throw new \RuntimeException('Unclosed string at position: ' . $startpos);
					break;

				// Escaped characters get picked up here. If it's an escaped new line it's not really needed
				case '\\':

					// a is a slash. We want to keep it, and the next character,
					// unless it's a new line. New lines as actual strings will be
					// preserved, but escaped new lines should be reduced.
					$this->b = $this->getChar();

					// If b is a new line we discard a and b and restart the loop.
					if ($this->b === "\n")
					{
						break;
					}

					// echo out the escaped character and restart the loop.
					echo $this->a . $this->b;
					break;


				// Since we're not dealing with any special cases we simply
				// output the character and continue our loop.
				default:
					echo $this->a;
			}
		}
	}
protected function saveString ( ) { $ startpos = $ this -> index ; // saveString is always called after a gets cleared, so we push b into // that spot. $ this -> a = $ this -> b ; // If this isn't a string we don't need to do anything. if ( $ this -> a !== "'" && $ this -> a !== '"' ) { return ; } // String type is the quote used, " or ' $ stringType = $ this -> a ; // Echo out that starting quote echo $ this -> a ; // Loop until the string is done while ( true ) { // Grab the very next character and load it into a $ this -> a = $ this -> getChar ( ) ; switch ( $ this -> a ) { // If the string opener (single or double quote) is used // output it and break out of the while loop- // The string is finished! case $ stringType : break 2 ; // New lines in strings without line delimiters are bad- actual // new lines will be represented by the string \n and not the actual // character, so those will be treated just fine using the switch // block below. case "\n" : throw new \ RuntimeException ( 'Unclosed string at position: ' . $ startpos ) ; break ; // Escaped characters get picked up here. If it's an escaped new line it's not really needed case '\\' : // a is a slash. We want to keep it, and the next character, // unless it's a new line. New lines as actual strings will be // preserved, but escaped new lines should be reduced. $ this -> b = $ this -> getChar ( ) ; // If b is a new line we discard a and b and restart the loop. if ( $ this -> b === "\n" ) { break ; } // echo out the escaped character and restart the loop. echo $ this -> a . $ this -> b ; break ; // Since we're not dealing with any special cases we simply // output the character and continue our loop. default : echo $ this -> a ; } } }
When a javascript string is detected this function crawls for the end of
it and saves the whole string.

@throws \RuntimeException Unclosed strings will throw an error
When a javascript string is detected this function crawls for the end of it and saves the whole string .