From 148a46438614f28a555ed692ccc865122312751f Mon Sep 17 00:00:00 2001 From: Halleck45 Date: Mon, 25 Aug 2014 19:13:53 +0200 Subject: [PATCH] bug : names of dependencies when dependency is instanciated --- src/Hal/Component/OOP/Extractor/Searcher.php | 2 +- .../Hal/Component/OOP/MethodExtractorTest.php | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Hal/Component/OOP/Extractor/Searcher.php b/src/Hal/Component/OOP/Extractor/Searcher.php index 8bf839c5..825c3d73 100644 --- a/src/Hal/Component/OOP/Extractor/Searcher.php +++ b/src/Hal/Component/OOP/Extractor/Searcher.php @@ -66,7 +66,7 @@ public function getPrevious(&$n, TokenCollection $tokens) { */ public function getFollowingName(&$n, TokenCollection $tokens) { $n = $n + 2; - return $this->getUnder(array('{', ' ', ';'), $n, $tokens); + return $this->getUnder(array('{', ' ', ';', '('), $n, $tokens); } /** diff --git a/tests/Hal/Component/OOP/MethodExtractorTest.php b/tests/Hal/Component/OOP/MethodExtractorTest.php index db1d9eff..229b4123 100644 --- a/tests/Hal/Component/OOP/MethodExtractorTest.php +++ b/tests/Hal/Component/OOP/MethodExtractorTest.php @@ -129,4 +129,27 @@ public function provideCodeForReturns() { , array(0, 'a(); }') ); } + + /** + * @dataProvider provideCodeForNew + * @group wip + */ + public function testConstructorAreFound($expected, $code) { + $searcher = new Searcher(); + $methodExtractor = new MethodExtractor($searcher); + + $tokens = new TokenCollection(token_get_all($code)); + $n = 1; + $method = $methodExtractor->extract($n, $tokens); + + $this->assertEquals($expected, $method->getDependencies()); + } + + public function provideCodeForNew() { + return array( + array(array(), '