Example of how to render classes PHPDoc
- Dominant language
- PHP
- Stars
- 41
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Description
Hey Jasny,
Not really an issue, but wanted to share some code for those looking to get phpdoc for classes in an array.
This does get the default properties and methods available in the class provided. Could definitely use some tweaking
I didn't see any example on your site, so decided I may be able to figure it out. Now I'm seeing its going to take a lot longer than I expected to create markdown files from some classes with PHPDoc comments, but I might circle back around to it later.
```php
use Jasny\PhpdocParser\PhpdocParser;
use Jasny\PhpdocParser\Set\PhpDocumentor;
use Jasny\PhpdocParser\Tag\Summery;
include 'vendor/autoload.php';
$cls = new ReflectionClass('Jasny\PhpdocParser\PhpdocParser');
$doc = $cls->getDocComment();
$tags = PhpDocumentor::tags()->with([new Summery()]);
$parser = new PhpdocParser($tags);
$meta = $parser->parse($doc);
$foundProperties = $cls->getDefaultProperties();
$getMethods = $cls->getMethods();
$foundMethods = [];
foreach($getMethods as $methodAry){
$docMethod = $cls->getMethod($methodAry->name)->getDocComment();
$foundMethods[$methodAry->name] = $parser->parse($docMethod);
}
echo print_r($meta,1).PHP_EOL
.print_r($foundProperties,1).PHP_EOL
.print_r($foundMethods,1).PHP_EOL;
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Review the shared PHP example, especially its ReflectionClass and PhpdocParser setup, alongside the project's existing site examples. Confirm whether a documentation example is wanted and where examples are maintained; done would be a reviewed, maintained example showing class metadata and parsed PHPDoc.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100