Skip to content

Commit

Permalink
Additional test for conflicts between PHPDoc types and return statement
Browse files Browse the repository at this point in the history
  • Loading branch information
iangreenleaf committed Apr 25, 2010
1 parent 0a0e64d commit 24f56d7
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/RenameMethodTest.php
Expand Up @@ -507,6 +507,55 @@ function getF() {
}
\$q = new Quark();
\$q->b()->baz();
EOL;
$this->renameAndCompare($orig, $expected);
}

/**
* This is a question of taste, since there's no "right" way to handle
* this kind of conflict. I choose to give PHPDoc types more weight than
* the guesses made by the static typer.
*/
public function testPHPDocReturnOverridesReturnStatement() {
$orig = <<<EOL
<?php
class Quark {
/**
* @return Quack
*/
function a() {
return new Foo();
}
/**
* @return Foo
*/
function b() {
return new Quack();
}
}
\$q = new Quark();
\$q->a()->bar();
\$q->b()->bar();
EOL;
$expected = <<<EOL
<?php
class Quark {
/**
* @return Quack
*/
function a() {
return new Foo();
}
/**
* @return Foo
*/
function b() {
return new Quack();
}
}
\$q = new Quark();
\$q->a()->bar();
\$q->b()->baz();
EOL;
$this->renameAndCompare($orig, $expected);
}
Expand Down

0 comments on commit 24f56d7

Please sign in to comment.