for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Vanderlee\Comprehend\Parser\Output;
use Vanderlee\Comprehend\Core\Token;
/**
* @author Martijn
*/
trait TokenTrait
{
* Name of the token.
*
* @var null
private $tokenName = null;
* Group to which this token belongs (mostly for standard Library tokens).
* @var string|null
private $tokenGroup = null;
* Is this token the deepest node in this tree to report a token on?
* @var bool
private $tokenIsTerminal = false;
* @param string $token
* @param string|null $group
* @param bool $isTerminal
* @return $this
public function token($token, $group = null, $isTerminal = false)
$this->tokenName = $token;
$token
string
null
$tokenName
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
$this->tokenGroup = $group;
$this->tokenIsTerminal = $isTerminal;
return $this;
}
* Has a token been set for this Parser?
* @return bool
public function hasToken()
return $this->tokenName !== null;
private function resolveToken($input, $offset, $length, &$children, $class)
if ($this->tokenIsTerminal) {
$children = [];
return new Token($this->tokenGroup, $this->tokenName, $input, $offset, $length, $children, $class);
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..