Skip to content

Commit 005dd07

Browse files
committed
Fix php 7.2.0alpha error
1 parent b67a189 commit 005dd07

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/ASTConverter/ASTConverter.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
use PhpParser\ParserFactory;
55

6+
/**
7+
* Source: https://github.com/TysonAndre/php-parser-to-php-ast
8+
* Uses PhpParser to create an instance of \ast\Node.
9+
* Useful if the php-ast extension isn't actually installed.
10+
* @author Tyson Andre
11+
*/
612
class ASTConverter {
713
// The latest stable version of php-ast.
814
// For something > 40, update the library's release.
@@ -522,7 +528,7 @@ private static function _phpparser_type_to_ast_node($type, int $line) {
522528
if (is_null($type)) {
523529
return $type;
524530
}
525-
if (is_string($type)) {
531+
if (\is_string($type)) {
526532
switch(strtolower($type)) {
527533
case 'null':
528534
$flags = \ast\flags\TYPE_NULL; break;
@@ -1008,7 +1014,7 @@ private static function _ast_stmt_declare(\ast\Node $declares, ?\ast\Node $stmts
10081014
}
10091015

10101016
private static function _ast_node_call($expr, $args, int $startLine) : \ast\Node{
1011-
if (is_string($expr)) {
1017+
if (\is_string($expr)) {
10121018
if (substr($expr, 0, 1) === '\\') {
10131019
$expr = substr($expr, 1);
10141020
}
@@ -1023,7 +1029,7 @@ private static function _ast_node_method_call($expr, $method, \ast\Node $args, i
10231029

10241030
private static function _ast_node_static_call($class, $method, \ast\Node $args, int $startLine) : \ast\Node {
10251031
// TODO: is this applicable?
1026-
if (is_string($class)) {
1032+
if (\is_string($class)) {
10271033
if (substr($class, 0, 1) === '\\') {
10281034
$expr = substr($class, 1);
10291035
}
@@ -1033,10 +1039,10 @@ private static function _ast_node_static_call($class, $method, \ast\Node $args,
10331039
}
10341040

10351041
private static function _extract_phpdoc_comment($comments) : ?string {
1036-
if (is_string($comments)) {
1042+
if (\is_string($comments)) {
10371043
return $comments;
10381044
}
1039-
if (count($comments) == 0) {
1045+
if ($comments === null || count($comments) === 0) {
10401046
return null;
10411047
}
10421048
for ($i = count($comments) - 1; $i >= 0; $i--) {
@@ -1134,7 +1140,7 @@ function astnode(int $kind, int $flags, ?array $children, int $lineno, ?string $
11341140
$node->flags = $flags;
11351141
$node->lineno = $lineno;
11361142
$node->children = $children;
1137-
if (is_string($docComment)) {
1143+
if (\is_string($docComment)) {
11381144
$node->docComment = $docComment;
11391145
}
11401146
return $node;

0 commit comments

Comments
 (0)