Drop useNopStatements option

This commit is contained in:
Nikita Popov 2017-01-20 22:29:41 +01:00
parent b5fb6f2d0a
commit 414adfb146
4 changed files with 7 additions and 13 deletions

View File

@ -179,7 +179,7 @@ function resolveMacros($code) {
assertArgs(3, $args, $name);
return '$startAttributes = ' . $args[1] . ';'
. ' if ($this->useNopStatements && isset($startAttributes[\'comments\']))'
. ' if (isset($startAttributes[\'comments\']))'
. ' { ' . $args[0] . ' = new Stmt\Nop($startAttributes + ' . $args[2] . '); }'
. ' else { ' . $args[0] . ' = null; }';
}

View File

@ -928,7 +928,7 @@ class Php5 extends \PhpParser\ParserAbstract
}
protected function reduceRule4() {
$startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
$startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)];
}
@ -1409,7 +1409,7 @@ class Php5 extends \PhpParser\ParserAbstract
}
protected function reduceRule124() {
$startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
$startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)];
}
@ -1550,7 +1550,7 @@ class Php5 extends \PhpParser\ParserAbstract
}
protected function reduceRule159() {
$startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if ($this->useNopStatements && isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; };
$startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; };
if ($this->semValue === null) $this->semValue = array(); /* means: no statement */
}

View File

@ -829,7 +829,7 @@ class Php7 extends \PhpParser\ParserAbstract
}
protected function reduceRule4() {
$startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
$startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)];
}
@ -1310,7 +1310,7 @@ class Php7 extends \PhpParser\ParserAbstract
}
protected function reduceRule124() {
$startAttributes = $this->lookaheadStartAttributes; if ($this->useNopStatements && isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
$startAttributes = $this->lookaheadStartAttributes; if (isset($startAttributes['comments'])) { $nop = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $nop = null; };
if ($nop !== null) { $this->semStack[$this->stackPos-(1-1)][] = $nop; } $this->semValue = $this->semStack[$this->stackPos-(1-1)];
}
@ -1435,7 +1435,7 @@ class Php7 extends \PhpParser\ParserAbstract
}
protected function reduceRule155() {
$startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if ($this->useNopStatements && isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; };
$startAttributes = $this->startAttributeStack[$this->stackPos-(1-1)]; if (isset($startAttributes['comments'])) { $this->semValue = new Stmt\Nop($startAttributes + $this->endAttributes); } else { $this->semValue = null; };
if ($this->semValue === null) $this->semValue = array(); /* means: no statement */
}

View File

@ -114,8 +114,6 @@ abstract class ParserAbstract implements Parser
/** @var bool Whether to create Identifier nodes for non-namespaced names */
protected $useIdentifierNodes;
/** @var bool Whether to use Stmt\Nop nodes */
protected $useNopStatements;
/**
* Creates a parser instance.
@ -123,8 +121,6 @@ abstract class ParserAbstract implements Parser
* Options:
* * useIdentifierNodes (default false): Create Identifier nodes for non-namespaced names.
* Otherwise plain strings will be used.
* * useNopStatements (default true): Create Stmt\Nop nodes for dangling comments at the end of
* statement lists.
*
* @param Lexer $lexer A lexer
* @param array $options Options array.
@ -133,8 +129,6 @@ abstract class ParserAbstract implements Parser
$this->lexer = $lexer;
$this->errors = array();
$this->useIdentifierNodes = !empty($options['useIdentifierNodes']);
$this->useNopStatements =
isset($options['useNopStatements']) ? $options['useNopStatements'] : true;
if (isset($options['throwOnError'])) {
throw new \LogicException(