Skip to content

Commit

Permalink
Support scalar expressions for constants
Browse files Browse the repository at this point in the history
This allows ReflectionConstant to parse scalar expressions when defining
constants, such as:

    const FOO = 1 ** 2;
    const BAR = array(1 => 'one');
    const BAZ = 'foo' . 'bar';
    const QUX = \Acme\Com\Demo::class;

Should fix Andrewsville#62 and Andrewsville#69.
  • Loading branch information
kdambekalns committed Oct 20, 2015
1 parent 1c5ff91 commit 439622b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions TokenReflection/ReflectionConstant.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,21 @@ private function parseValue(Stream $tokenStream, IReflection $parent)
static $acceptedTokens = array(
'-' => true,
'+' => true,
'(' => true,
')' => true,
'[' => true,
']' => true,
'.' => true,
T_STRING => true,
T_NS_SEPARATOR => true,
T_CONSTANT_ENCAPSED_STRING => true,
T_DNUMBER => true,
T_LNUMBER => true,
T_DOUBLE_COLON => true,
T_POW => true,
T_ARRAY => true,
T_DOUBLE_ARROW => true,
T_CLASS => true,
T_CLASS_C => true,
T_DIR => true,
T_FILE => true,
Expand Down

1 comment on commit 439622b

@prymas007
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance to merge this PR ?

Please sign in to comment.