forked from phpspec/prophecy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the handling of invalid phpdoc tags
Such tags are represented by an InvalidTag instance rather than a Method tag, but the name might still be `method`. As we want to ignore invalid tags (that's the reason to catch exceptions), these tags are filtered out.
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
|
||
namespace Fixtures\Prophecy; | ||
|
||
|
||
/** | ||
* @method string name(string $gender = null) | ||
* @method mixed randomElement(array $array = array('a', 'b', 'c')) | ||
*/ | ||
class WithPhpdocClass | ||
{ | ||
public function __call($name, $arguments) | ||
{ | ||
// TODO: Implement __call() method. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Tests\Prophecy\Doubler\ClassPatch; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Prophecy\Doubler\ClassPatch\MagicCallPatch; | ||
use Prophecy\Doubler\Generator\ClassMirror; | ||
|
||
class MagicCallPatchTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_supports_classes_with_invalid_tags() | ||
{ | ||
$class = new \ReflectionClass('Fixtures\Prophecy\WithPhpdocClass'); | ||
|
||
$mirror = new ClassMirror(); | ||
$classNode = $mirror->reflect($class, array()); | ||
|
||
$patch = new MagicCallPatch(); | ||
|
||
$patch->apply($classNode); | ||
|
||
$this->assertTrue($classNode->hasMethod('name')); | ||
} | ||
} |