Skip to content

Commit f6f30be

Browse files
Bump php-parser version to 5
1 parent 116f1a0 commit f6f30be

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"nikic/php-parser": "^4.10.3",
13+
"nikic/php-parser": "^5",
1414
"illuminate/support": "*"
1515
},
1616
"require-dev": {

src/Evaluator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function evaluate($node, $context = [])
2323
} elseif ($node instanceof DNumber) {
2424
return floatval($node->value);
2525
} elseif ($node instanceof ConstFetch) {
26-
return $this->getConstantValue($node->name->parts[0]);
26+
return $this->getConstantValue($node->name->getParts()[0]);
2727
} elseif ($node instanceof Array_) {
2828
return $this->evaluateArray($node, $context);
2929
} elseif ($node instanceof String_) {
@@ -62,7 +62,7 @@ protected function getNestedPath(PropertyFetch $propertyFetch)
6262
protected function evaluateFunctionCall(FuncCall $funcCall, $context)
6363
{
6464
$runtimeMethod = new MethodCall();
65-
$runtimeMethod->name = $funcCall->name->parts[0];
65+
$runtimeMethod->name = $funcCall->name->getParts()[0];
6666

6767
foreach ($funcCall->args as $arg) {
6868
if ($arg instanceof Arg) {

src/Parser.php

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
namespace Stillat\Primitives;
44

55
use Illuminate\Support\Str;
6-
use PhpParser\Lexer\Emulative;
76
use PhpParser\Node\Arg;
87
use PhpParser\Parser\Php7;
8+
use PhpParser\ParserFactory;
99
use PhpParser\PrettyPrinter\Standard;
1010

1111
class Parser
@@ -15,21 +15,9 @@ class Parser
1515
*/
1616
protected $parser;
1717

18-
/**
19-
* @var Emulative
20-
*/
21-
protected $lexer = null;
22-
2318
public function __construct()
2419
{
25-
$this->lexer = new Emulative([
26-
'usedAttributes' => [
27-
'comments',
28-
'startLine', 'endLine',
29-
'startTokenPos', 'endTokenPos',
30-
],
31-
]);
32-
$this->parser = new Php7($this->lexer);
20+
$this->parser = (new ParserFactory())->createForNewestSupportedVersion();
3321
}
3422

3523
/**

0 commit comments

Comments
 (0)