Completed
Pull Request — master (#41)
by Lars
03:14
created

KeepOriginalValuePrinter::pStmts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Spatie\Php7to5\PhpParser;
4
5
use PhpParser\Node;
6
use PhpParser\PrettyPrinter\Standard;
7
8
class KeepOriginalValuePrinter extends Standard
9
{
10
    /**
11
     * Pretty prints an array of nodes (statements) and indents them optionally.
12
     *
13
     * @param Node[] $nodes Array of nodes
14
     * @param bool $indent Whether to indent the printed nodes
15
     *
16
     * @return string Pretty printed statements
17
     */
18
    protected function pStmts(array $nodes, bool $indent = true) : string
19
    {
20
        // DEBUG
21
        //var_dump($nodes);
22
23
        return parent::pStmts($nodes, $indent);
24
    }
25
26
    protected function pScalar_String(Node\Scalar\String_ $node)
27
    {
28
        // DEBUG
29
        //var_dump($node);
30
31
        $str = $node->getAttribute('originalValue');
32
33
        // DEBUG
34
        //var_dump($str);
35
36
        $str = str_replace(
37
            ['"_+*-7-to-5-*+_', '_+*-7-to-5-*+_"', '_+*-7-to-5-*+_'],
38
            ['"', '"', ''],
39
            $str
40
        );
41
42
        return $str;
43
    }
44
}
45