-
Notifications
You must be signed in to change notification settings - Fork 246
Compatibility with phpDocumentor Reflection Dockbloc 3 #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33243a4
Upgrade to reflection-docblock 3
dunglas 671b5ef
Fix @stof and @sroze comments
dunglas d3e7b56
Add backward compatibility
theofidry 6d73d78
Add tag retriever
theofidry ff2743f
Minor fix
theofidry 3ab2245
Remove unneeded paranthesis
theofidry 2a3f7ca
Mark tag retrievers as internal
dunglas 9a81b72
Require phpdocumentor/reflection-docblock ^3.0.2
dunglas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
69 changes: 69 additions & 0 deletions
69
src/Prophecy/PhpDocumentor/ClassAndInterfaceTagRetriever.php
This file contains hidden or 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,69 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Prophecy. | ||
| * (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
| * Marcello Duarte <marcello.duarte@gmail.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Prophecy\PhpDocumentor; | ||
|
|
||
| use phpDocumentor\Reflection\DocBlock\Tag\MethodTag as LegacyMethodTag; | ||
| use phpDocumentor\Reflection\DocBlock\Tags\Method; | ||
|
|
||
| /** | ||
| * @author Théo FIDRY <theo.fidry@gmail.com> | ||
| * | ||
| * @internal | ||
| */ | ||
| final class ClassAndInterfaceTagRetriever implements MethodTagRetrieverInterface | ||
| { | ||
| private $classRetriever; | ||
|
|
||
| public function __construct(MethodTagRetrieverInterface $classRetriever = null) | ||
| { | ||
| if (null !== $classRetriever) { | ||
| $this->classRetriever = $classRetriever; | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| $this->classRetriever = class_exists('phpDocumentor\Reflection\DocBlockFactory') && class_exists('phpDocumentor\Reflection\Types\ContextFactory') | ||
| ? new ClassTagRetriever() | ||
| : new LegacyClassTagRetriever() | ||
| ; | ||
| } | ||
|
|
||
| /** | ||
| * @param \ReflectionClass $reflectionClass | ||
| * | ||
| * @return LegacyMethodTag[]|Method[] | ||
| */ | ||
| public function getTagList(\ReflectionClass $reflectionClass) | ||
| { | ||
| return array_merge( | ||
| $this->classRetriever->getTagList($reflectionClass), | ||
| $this->getInterfacesTagList($reflectionClass) | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * @param \ReflectionClass $reflectionClass | ||
| * | ||
| * @return LegacyMethodTag[]|Method[] | ||
| */ | ||
| private function getInterfacesTagList(\ReflectionClass $reflectionClass) | ||
| { | ||
| $interfaces = $reflectionClass->getInterfaces(); | ||
| $tagList = array(); | ||
|
|
||
| foreach($interfaces as $interface) { | ||
| $tagList = array_merge($tagList, $this->classRetriever->getTagList($interface)); | ||
| } | ||
|
|
||
| return $tagList; | ||
| } | ||
| } |
This file contains hidden or 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,52 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Prophecy. | ||
| * (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
| * Marcello Duarte <marcello.duarte@gmail.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Prophecy\PhpDocumentor; | ||
|
|
||
| use phpDocumentor\Reflection\DocBlock\Tags\Method; | ||
| use phpDocumentor\Reflection\DocBlockFactory; | ||
| use phpDocumentor\Reflection\Types\ContextFactory; | ||
|
|
||
| /** | ||
| * @author Théo FIDRY <theo.fidry@gmail.com> | ||
| * | ||
| * @internal | ||
| */ | ||
| final class ClassTagRetriever implements MethodTagRetrieverInterface | ||
| { | ||
| private $docBlockFactory; | ||
| private $contextFactory; | ||
|
|
||
| public function __construct() | ||
| { | ||
| $this->docBlockFactory = DocBlockFactory::createInstance(); | ||
| $this->contextFactory = new ContextFactory(); | ||
| } | ||
|
|
||
| /** | ||
| * @param \ReflectionClass $reflectionClass | ||
| * | ||
| * @return Method[] | ||
| */ | ||
| public function getTagList(\ReflectionClass $reflectionClass) | ||
| { | ||
| try { | ||
| $phpdoc = $this->docBlockFactory->create( | ||
| $reflectionClass, | ||
| $this->contextFactory->createFromReflector($reflectionClass) | ||
| ); | ||
|
|
||
| return $phpdoc->getTagsByName('method'); | ||
| } catch (\InvalidArgumentException $e) { | ||
| return array(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,35 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Prophecy. | ||
| * (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
| * Marcello Duarte <marcello.duarte@gmail.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Prophecy\PhpDocumentor; | ||
|
|
||
| use phpDocumentor\Reflection\DocBlock; | ||
| use phpDocumentor\Reflection\DocBlock\Tag\MethodTag as LegacyMethodTag; | ||
|
|
||
| /** | ||
| * @author Théo FIDRY <theo.fidry@gmail.com> | ||
| * | ||
| * @internal | ||
| */ | ||
| final class LegacyClassTagRetriever implements MethodTagRetrieverInterface | ||
| { | ||
| /** | ||
| * @param \ReflectionClass $reflectionClass | ||
| * | ||
| * @return LegacyMethodTag[] | ||
| */ | ||
| public function getTagList(\ReflectionClass $reflectionClass) | ||
| { | ||
| $phpdoc = new DocBlock($reflectionClass->getDocComment()); | ||
|
|
||
| return $phpdoc->getTagsByName('method'); | ||
| } | ||
| } |
30 changes: 30 additions & 0 deletions
30
src/Prophecy/PhpDocumentor/MethodTagRetrieverInterface.php
This file contains hidden or 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,30 @@ | ||
| <?php | ||
|
|
||
| /* | ||
| * This file is part of the Prophecy. | ||
| * (c) Konstantin Kudryashov <ever.zet@gmail.com> | ||
| * Marcello Duarte <marcello.duarte@gmail.com> | ||
| * | ||
| * For the full copyright and license information, please view the LICENSE | ||
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Prophecy\PhpDocumentor; | ||
|
|
||
| use phpDocumentor\Reflection\DocBlock\Tag\MethodTag as LegacyMethodTag; | ||
| use phpDocumentor\Reflection\DocBlock\Tags\Method; | ||
|
|
||
| /** | ||
| * @author Théo FIDRY <theo.fidry@gmail.com> | ||
| * | ||
| * @internal | ||
| */ | ||
| interface MethodTagRetrieverInterface | ||
| { | ||
| /** | ||
| * @param \ReflectionClass $reflectionClass | ||
| * | ||
| * @return LegacyMethodTag[]|Method[] | ||
| */ | ||
| public function getTagList(\ReflectionClass $reflectionClass); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please mark this interface and all its implementations as
@internalThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done