PHP code example of symplify / better-phpdoc-parser
1. Go to this page and download the library: Download symplify/better-phpdoc-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Symplify\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Symplify\BetterPhpDocParser\Printer\PhpDocInfoPrinter;
class SomeClass
{
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, PhpDocInfoPrinter $phpDocInfoPrinter)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->phpDocInfoPrinter = $phpDocInfoPrinter;
}
public function changeDocBlockAndPrintItBack(): string
{
$docComment = '/** @var Type $variable */';
$phpDocInfo = $this->phpDocInfoFactory->createFrom($docComment);
// modify `$phpDocInfo` using its methods
return $this->phpDocInfoPrinter->printFormatPreserving($phpDocInfo);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.