Exemple #1
0
 public function pScalar_String(Scalar\String_ $node)
 {
     $kind = $node->getAttribute('kind', Scalar\String_::KIND_SINGLE_QUOTED);
     switch ($kind) {
         case Scalar\String_::KIND_NOWDOC:
             $label = $node->getAttribute('docLabel');
             if ($label && !$this->containsEndLabel($node->value, $label)) {
                 if ($node->value === '') {
                     return $this->pNoIndent("<<<'{$label}'\n{$label}") . $this->docStringEndToken;
                 }
                 return $this->pNoIndent("<<<'{$label}'\n{$node->value}\n{$label}") . $this->docStringEndToken;
             }
             /* break missing intentionally */
         /* break missing intentionally */
         case Scalar\String_::KIND_SINGLE_QUOTED:
             return '\'' . $this->pNoIndent(addcslashes($node->value, '\'\\')) . '\'';
         case Scalar\String_::KIND_HEREDOC:
             $label = $node->getAttribute('docLabel');
             if ($label && !$this->containsEndLabel($node->value, $label)) {
                 if ($node->value === '') {
                     return $this->pNoIndent("<<<{$label}\n{$label}") . $this->docStringEndToken;
                 }
                 $escaped = $this->escapeString($node->value, null);
                 return $this->pNoIndent("<<<{$label}\n" . $escaped . "\n{$label}") . $this->docStringEndToken;
             }
             /* break missing intentionally */
         /* break missing intentionally */
         case Scalar\String_::KIND_DOUBLE_QUOTED:
             return '"' . $this->escapeString($node->value, '"') . '"';
     }
     throw new \Exception('Invalid string kind');
 }
 /**
  * Converts the string into it's original representation without converting
  * the special character combinations.
  *
  * This method is overridden from the original Zend Pretty Printer because
  * the original returns the strings as interpreted by PHP-Parser.
  * Since we do not want such conversions we take the original that is
  * injected by our own custom Lexer.
  *
  * @param String $node The node to return a string
  *     representation of.
  *
  * @see Lexer where the originalValue is injected.
  *
  * @return string
  */
 public function pScalar_String(String_ $node)
 {
     if (method_exists($this, 'pSafe')) {
         return $this->pSafe($node->getAttribute('originalValue'));
     }
     return $this->pNoIndent($node->getAttribute('originalValue'));
 }
 /**
  * @param Scalar\String_ $node
  *
  * @return string
  */
 public function pScalar_String(Scalar\String_ $node)
 {
     if ($node->hasAttribute('originalValue')) {
         $string = $node->getAttribute('originalValue');
     } else {
         $string = '\'' . $this->pNoIndent(addcslashes($node->value, '\'\\')) . '\'';
     }
     return $this->color($string, SyntaxHighlighterConfig::TYPE_STRING);
 }
Exemple #4
0
 public function pScalar_String(Scalar\String_ $node)
 {
     // Cowardly refuse to touch people's multiline strings
     // It is 100% impossible for us to guarantee unchanged semantics
     // and keep single strings otherwise. How do you know they don't want
     // those 8 tabs to stay instead of them being used for indentation?
     // You don't, so...keep it. gofmt seems to refuse to touch strings as
     // well
     return $node->getAttribute('originalValue');
 }
Exemple #5
0
 public function pScalar_String(Node\Scalar\String_ $node)
 {
     $kind = $node->getAttribute('kind', Node\Scalar\String_::KIND_SINGLE_QUOTED);
     if ($kind === Node\Scalar\String_::KIND_HEREDOC || $kind === Node\Scalar\String_::KIND_NOWDOC) {
         return parent::pScalar_String($node);
     }
     return $this->pNoIndent($node->getAttribute('originalValue'));
 }