Parses property tokens

@param TokenStream $stream     TokenStream object
@param Token       $visibility Token <TOKEN_PUBL> or <TOKEN_PROT> or <TOKEN_PRIV>
@param Token       $name       Token <TOKEN_NODE>

@throws \Exception
187526
protected function parseProperty(TokenStream $stream, $visibility, $name)
    {
        switch ($visibility->getValue()) {
            case '+':
                $this->nodes[] = new Node(self::NODE_PUBLIC_PROPERTY, $name->getValue());
                break;
            case '#':
                $this->nodes[] = new Node(self::NODE_PROTECTED_PROPERTY, $name->getValue());
                break;
            case '-':
                $this->nodes[] = new Node(self::NODE_PRIVATE_PROPERTY, $name->getValue());
                break;
        }
        if ($this->skip($stream)->is(Lexer::TOKEN_TYPE)) {
            $stream->next();
            $token = $this->skip($stream)->expect(Lexer::TOKEN_NODE);
            $this->nodes[] = new Node(self::NODE_PROPERTY_TYPE, $token->getValue());
        }

        if ($this->skip($stream)->is(Lexer::TOKEN_BRCO)) {
            $stream->next();
            while (!$this->skip($stream)->is(Lexer::TOKEN_BRCC)) {
                if ($this->skip($stream)->is(array(Lexer::TOKEN_PUBL, Lexer::TOKEN_PROT, Lexer::TOKEN_PRIV))) {
                    throw new \Exception('Unexpected token: ' . $stream->current()->getType());
                }

                $token = $stream->skipType(array(Lexer::TOKEN_EOL, Lexer::TOKEN_WTSP))->expect(Lexer::TOKEN_NODE);
                $this->nodes[] = new Node(self::NODE_ACCESSOR, $token->getValue());
            }
            $stream->next();
        }

        $this->parseComment($stream, self::NODE_PROPERTY_COMMENT);
    }
1275831
protected function parseBody(TokenStream $stream)
    {
        $visibility = $this->skip($stream)->expect(array(Lexer::TOKEN_PUBL, Lexer::TOKEN_PROT, Lexer::TOKEN_PRIV));
        $name = $this->skip($stream)->expect(array(Lexer::TOKEN_NODE));

        if ($this->skip($stream)->is(Lexer::TOKEN_METO)) {
            $this->parseMethod($stream, $visibility, $name);
        } else {
            $this->parseProperty($stream, $visibility, $name);
        }
    }
1072271
public void parseSignaturesFile(InputStream in, String name) throws IOException,ParseException {
    forbiddenSignatures.parseSignaturesStream(in, name);
  }
995022
public function parse(Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();

        $count = null;
        $vars = new ArrayExpression([], $lineno);
        $domain = null;
        $locale = null;
        if (!$stream->test(Token::BLOCK_END_TYPE)) {
            if ($stream->test('count')) {
                // {% trans count 5 %}
                $stream->next();
                $count = $this->parser->getExpressionParser()->parseExpression();
            }

            if ($stream->test('with')) {
                // {% trans with vars %}
                $stream->next();
                $vars = $this->parser->getExpressionParser()->parseExpression();
            }

            if ($stream->test('from')) {
                // {% trans from "messages" %}
                $stream->next();
                $domain = $this->parser->getExpressionParser()->parseExpression();
            }

            if ($stream->test('into')) {
                // {% trans into "fr" %}
                $stream->next();
                $locale = $this->parser->getExpressionParser()->parseExpression();
            } elseif (!$stream->test(Token::BLOCK_END_TYPE)) {
                throw new SyntaxError('Unexpected token. Twig was looking for the "with", "from", or "into" keyword.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
            }
        }

        // {% trans %}message{% endtrans %}
        $stream->expect(Token::BLOCK_END_TYPE);
        $body = $this->parser->subparse([$this, 'decideTransFork'], true);

        if (!$body instanceof TextNode && !$body instanceof AbstractExpression) {
            throw new SyntaxError('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext());
        }

        $stream->expect(Token::BLOCK_END_TYPE);

        return new TransNode($body, $domain, $count, $vars, $locale, $lineno, $this->getTag());
    }
1154965
public function parse(AbstractStream $stream)
    {
        if (!($this->dataSet instanceof DataSet)) {
            $this->dataSet = new DataSet;
        }

        $this->rewind();
        do {
            $field = $this->current();
            $field->setDataSet($this->getDataSet());
            if ($field instanceof Conditional) {
                $field = $field->resolveField();
            }
            if ($field instanceof self) {
                $this->dataSet->push($this->key());
                $field->parse($stream);
                $this->dataSet->pop();
            } else {
                $this->dataSet->setValue($this->key(), $field->parse($stream));
            }
            $this->next();
        } while ($this->valid());

        if (isset($this->assert)) {
            $this->validate($this->dataSet->getValueByCurrentPath());
        }

        return $this->dataSet->getData();
    }
897942
public function parse(array $existing = [], string &$name = null): array
    {
        if($this->type !== AnnotationReader::ANNOTATION_TYPE_PROPERTY)
            throw new \Exception("[MVQN\Annotations\AnnotationReader] @KeepNullElements is only supported for properties!");

        $name = "keepNullElements";

        if($this->isValueEval($this->value))
        {
            $existing[$name] = "`{$this->value}`";
            return $existing;
        }
        elseif($this->value === null || $this->value === "")
        {
            $existing[$name] = true;
            return $existing;
        }
        else
        {
            // Exclude the item, as we do not know how to handle the 'value' specifically!
            return $existing;
        }
    }
861363
public function addProperty($name, $initialValueCode, $visibility = 'private', $docComment = '')
    {
        $this->properties[$name] = [
            'initialValueCode' => $initialValueCode,
            'visibility' => $visibility,
            'docComment' => $docComment
        ];
    }
933990
public function setTokenName(string $name)
    {
        if (empty($name)) {
            Throw new TokenException('Empty token name is not allowed.');
        }

        $this->name = $name;
    }
1093014
public SparseDataset parse(String name, InputStream stream) throws IOException, ParseException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
        try {
            String line = reader.readLine();
            if (line == null) {
                throw new IOException("Empty data source.");
            }

            String[] tokens = line.trim().split("\\s+");
            boolean classification = true;
            Attribute response = null;
            try {
                Integer.valueOf(tokens[0]);
                response = new NominalAttribute("class");
            } catch (NumberFormatException e) {
                try {
                    Double.valueOf(tokens[0]);
                    response = new NominalAttribute("response");
                    classification = false;
                } catch (NumberFormatException ex) {
                    logger.error("Failed to parse {}", tokens[0], ex);
                    throw new NumberFormatException("Unrecognized response variable value: " + tokens[0]);
                }
            }

            SparseDataset sparse = new SparseDataset(name, response);
            for (int i = 0; line != null; i++) {
                tokens = line.trim().split("\\s+");

                if (classification) {
                    int y = Integer.parseInt(tokens[0]);
                    sparse.set(i, y);
                } else {
                    double y = Double.parseDouble(tokens[0]);
                    sparse.set(i, y);
                }

                for (int k = 1; k < tokens.length; k++) {
                    String[] pair = tokens[k].split(":");
                    if (pair.length != 2) {
                        throw new NumberFormatException("Invalid data: " + tokens[k]);
                    }

                    int j = Integer.parseInt(pair[0]) - 1;
                    double x = Double.parseDouble(pair[1]);
                    sparse.set(i, j, x);
                }

                line = reader.readLine();
            }

            if (classification) {
                int n = sparse.size();
                int[] y = sparse.toArray(new int[n]);
                int[] label = Math.unique(y);
                Arrays.sort(label);
                for (int c : label) {
                    response.valueOf(String.valueOf(c));
                }

                for (int i = 0; i < n; i++) {
                    sparse.get(i).y = Arrays.binarySearch(label, y[i]);
                }
            }

            return sparse;
        } finally {
            reader.close();
        }
    }
780923
private function tokenToColumn($token, $namingConvention, $class)
    {
        // Find a matching property
        $property = null;
        foreach ($class->getProperties() as $prop) {
            if (strcasecmp($token->getSource(), $prop->getName()) === 0) {
                $property = $prop;
                break;
            }
        }

        if ($property === null) {
            throw new DslSyntaxException('No matching property found for ' . $token->getSource());
        }

        return $namingConvention->propertyToColumnName($property);
    }
886588
private function parseImportList(Stream $stream)
    {
        $list = [];

        do {
            $resource = $this->parseIdentifier($stream);

            if ($stream->current()->equals(Token::TYPE_KEYWORD, 'as')) {
                $stream->expects(Token::TYPE_KEYWORD, 'as');

                $alias = $this->parseIdentifier($stream);
            } else {
                $alias = $resource;
            }

            $list[$resource] = $alias;
        } while ($stream->current()->equals(Token::TYPE_SYMBOL, ',') && $stream->expects(Token::TYPE_SYMBOL, ','));

        return $list;
    }
402953
public function parseText() : void
    {
        if (!count($this->stream->getTokens())) {
            return;
        }

        if ($this->accept(Token::T_TEXT)) {
            $this->insert(new TextNode($this->getCurrentToken()->getValue()));
            $this->advance();
        }
    }
303273
public function checkVisibility(array $visibility, $name, array $original = null)
    {
        if (\count($visibility) > 1) {
            if (\in_array('public', $visibility) && \in_array('protected', $visibility)) {
                throw new CompilerException("Method '$name' cannot be 'public' and 'protected' at the same time", $original);
            }

            if (\in_array('public', $visibility) && \in_array('private', $visibility)) {
                throw new CompilerException("Method '$name' cannot be 'public' and 'private' at the same time", $original);
            }

            if (\in_array('private', $visibility) && \in_array('protected', $visibility)) {
                throw new CompilerException("Method '$name' cannot be 'protected' and 'private' at the same time", $original);
            }

            if (\in_array('private', $visibility) && \in_array('internal', $visibility)) {
                throw new CompilerException("Method '$name' cannot be 'internal' and 'private' at the same time", $original);
            }

            if (\in_array('protected', $visibility) && \in_array('internal', $visibility)) {
                throw new CompilerException("Method '$name' cannot be 'internal' and 'protected' at the same time", $original);
            }

            if (\in_array('public', $visibility) && \in_array('internal', $visibility)) {
                throw new CompilerException("Method '$name' cannot be 'internal' and 'public' at the same time", $original);
            }
        }

        if ('__construct' == $name) {
            if (\in_array('static', $visibility)) {
                throw new CompilerException("Constructors cannot be 'static'", $original);
            }
        } else {
            if ('__destruct' == $name) {
                if (\in_array('static', $visibility)) {
                    throw new CompilerException("Destructors cannot be 'static'", $original);
                }
            }
        }

        if (\is_array($visibility)) {
            $this->isAbstract = \in_array('abstract', $visibility);
            $this->isStatic = \in_array('static', $visibility);
            $this->isFinal = \in_array('final', $visibility);
            $this->isPublic = \in_array('public', $visibility);
            $this->isInternal = \in_array('internal', $visibility);
        }
    }
1209200
protected function parseLinenosOption(\Twig_Token $token, \Twig_TokenStream $stream)
    {
        $this->testToken('linenos', $token, $stream);

        return $this->getNextExpectedBoolValueFromStream($stream, 'linenos');
    }
753383
protected function parseLangOption(\Twig_Token $token, \Twig_TokenStream $stream)
    {
        $this->testToken('lang', $token, $stream);

        return $this->getNextExpectedStringValueFromStream($stream, \Twig_Token::STRING_TYPE);
    }
919655
protected function getStreamTokensReflectionProperty(): \ReflectionProperty
    {
        if (isset($this->tokensReflectionProperty)) {
            return $this->tokensReflectionProperty;
        }
        $stream = $this->parser->getStream();
        $class = new \ReflectionClass($stream);
        $property = $class->getProperty("tokens");
        $property->setAccessible(true);
        return $this->tokensReflectionProperty = $property;
    }
1014470
private function parseClass(Stream $stream)
    {
        $stream->expects(Token::TYPE_KEYWORD, 'new');

        $class = [$stream->expects(Token::TYPE_IDENTIFIER)->getValue()];

        while ($stream->current()->equals(Token::TYPE_SYMBOL, '\\')) {
            $stream->expects(Token::TYPE_SYMBOL, '\\');

            $class[] = $stream->expects(Token::TYPE_IDENTIFIER)->getValue();
        }

        $class = implode('\\', $class);

        $arguments = [];

        if ($stream->current()->equals(Token::TYPE_SYMBOL, '(')) {
            $stream->expects(Token::TYPE_SYMBOL, '(');

            if (!$stream->current()->equals(Token::TYPE_SYMBOL, ')')) {
                $arguments = $this->parseList($stream);
            }

            $stream->expects(Token::TYPE_SYMBOL, ')');
        }

        return new ClassNode($class, $arguments);
    }