forked from nikic/PHP-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EncapsedStringPart.php
49 lines (39 loc) · 1.32 KB
/
EncapsedStringPart.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php declare(strict_types=1);
namespace PhpParser\Node\Scalar;
use PhpParser\Node\Scalar;
class EncapsedStringPart extends Scalar
{
/** @var string String value */
public $value;
/**
* Constructs a node representing a string part of an encapsed string.
*
* @param string $value String value
* @param array $attributes Additional attributes
*/
public function __construct(string $value, array $attributes = []) {
$this->attributes = $attributes;
$this->value = $value;
}
public static function fromString(string $value, array $attributes): self
{
$attributes['rawValue'] = $value;
return new self($value, $attributes);
}
/**
* @param null|string $quote Quote type
* @param bool $parseUnicodeEscape Whether to parse PHP 7 \u escapes
*/
public static function fromStringParsed(string $value, array $attributes, $quote, bool $parseUnicodeEscape = true): self
{
$attributes['rawValue'] = $value;
$parsedValue = String_::parseEscapeSequences($value, $quote, $parseUnicodeEscape);
return new self($parsedValue, $attributes);
}
public function getSubNodeNames() : array {
return ['value'];
}
public function getType() : string {
return 'Scalar_EncapsedStringPart';
}
}