From 56b0d87b8248f7fd2b76cca850b318098265ec6d Mon Sep 17 00:00:00 2001 From: Andrew Barlow Date: Wed, 9 Aug 2017 08:51:58 +0100 Subject: [PATCH] Fixes for #423 (#424) * Update php7.php * Update StaticAnalyser.php * Update StaticAnalyser.php --- src/StaticAnalyser.php | 4 ++-- tests/Fixtures/php7.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/StaticAnalyser.php b/src/StaticAnalyser.php index 99597d516..f3bfe8246 100644 --- a/src/StaticAnalyser.php +++ b/src/StaticAnalyser.php @@ -101,8 +101,8 @@ protected function fromTokens($tokens, $parseContext) } $token = $this->nextToken($tokens, $parseContext); - if (is_string($token) && $token === '{') { - // php7 anonymous classes (i.e. new class { public function foo() {} };) + if (is_string($token) && ($token === '(' || $token === '{')) { + // php7 anonymous classes (i.e. new class() { public function foo() {} };) continue; } diff --git a/tests/Fixtures/php7.php b/tests/Fixtures/php7.php index 8ea2a5db9..14d8f7566 100644 --- a/tests/Fixtures/php7.php +++ b/tests/Fixtures/php7.php @@ -13,3 +13,15 @@ public function foo() $o = new class implements foo { }; + +$o = new class() { + public function foo() + { + } +}; + +$o = new class() extends stdClass { +}; + +$o = new class() implements foo { +};