diff --git a/fixtures/WithPhpdocClass.php b/fixtures/WithPhpdocClass.php new file mode 100644 index 000000000..3f42c3c42 --- /dev/null +++ b/fixtures/WithPhpdocClass.php @@ -0,0 +1,17 @@ +contextFactory->createFromReflector($reflectionClass) ); - return $phpdoc->getTagsByName('method'); + $methods = array(); + + foreach ($phpdoc->getTagsByName('method') as $tag) { + if ($tag instanceof Method) { + $methods[] = $tag; + } + } + + return $methods; } catch (\InvalidArgumentException $e) { return array(); } diff --git a/tests/Doubler/ClassPatch/MagicCallPatchTest.php b/tests/Doubler/ClassPatch/MagicCallPatchTest.php new file mode 100644 index 000000000..989998adc --- /dev/null +++ b/tests/Doubler/ClassPatch/MagicCallPatchTest.php @@ -0,0 +1,32 @@ +reflect($class, array()); + + $patch = new MagicCallPatch(); + + $patch->apply($classNode); + + // Newer phpDocumentor versions allow reading valid method tags, even when some other tags are invalid + if (class_exists('phpDocumentor\Reflection\DocBlockFactory') && class_exists('phpDocumentor\Reflection\Types\ContextFactory')) { + $this->assertTrue($classNode->hasMethod('name')); + } + + $this->assertFalse($classNode->hasMethod('randomElement')); + } +}