Skip to content

Commit

Permalink
bug : names of dependencies when dependency is instanciated
Browse files Browse the repository at this point in the history
  • Loading branch information
Halleck45 committed Sep 1, 2014
1 parent 7d53b88 commit 148a464
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Hal/Component/OOP/Extractor/Searcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
23 changes: 23 additions & 0 deletions tests/Hal/Component/OOP/MethodExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,27 @@ public function provideCodeForReturns() {
, array(0, '<?php public function bar() { $x->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(), '<?php public function foo() { return 1; }')
, array(array('A'), '<?php public function bar() { new A(); }')
, array(array('A'), '<?php public function bar() { new A(1,2,3); }')
);
}
}

0 comments on commit 148a464

Please sign in to comment.