Mutagenesis\Mutable::_parseToken PHP 메소드

_parseToken() 보호된 메소드

Parse a given token (in array form) to identify its type and ascertain whether it can be replaced with a mutated form. The mutated form, if any, is returned for future integration into a mutated version of the source code being tested.
protected _parseToken ( array $token, integer $index ) : mixed
$token array The token to check for viable mutations
$index integer The index of the token in the method's body
리턴 mixed Return null if no mutation, or a mutation object
    protected function _parseToken(array $token, $index)
    {
        $type = '';
        switch ($token[0]) {
            case T_INC:
                $type = 'OperatorIncrement';
                break;
            case T_DEC:
                $type = 'OperatorDecrement';
                break;
            case T_BOOLEAN_AND:
                $type = 'BooleanAnd';
                break;
            case T_BOOLEAN_OR:
                $type = 'BooleanOr';
                break;
            case T_STRING:
                $type = $this->_parseTString($token);
                break;
        }
        if (!empty($type)) {
            $mutationClass = 'Mutagenesis\\Mutation\\' . $type;
            if (!class_exists($mutationClass)) {
                // todo: given we're autoloading, could we not just kick up an exception here?
                require_once str_replace('\\', '/', ltrim($mutationClass, '\\')) . '.php';
            }
            $mutation = new $mutationClass($this->getFilename());
            return $mutation;
        }
        return null;
    }