-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
109 additions
and
0 deletions.
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
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,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace T3Docs\GuidesPhpDomain\Directives\Php; | ||
|
||
use phpDocumentor\Guides\Nodes\CollectionNode; | ||
use phpDocumentor\Guides\Nodes\Node; | ||
use phpDocumentor\Guides\ReferenceResolvers\AnchorReducer; | ||
use phpDocumentor\Guides\RestructuredText\Directives\SubDirective; | ||
use phpDocumentor\Guides\RestructuredText\Parser\BlockContext; | ||
use phpDocumentor\Guides\RestructuredText\Parser\Directive; | ||
use phpDocumentor\Guides\RestructuredText\Parser\Productions\Rule; | ||
use phpDocumentor\Guides\RestructuredText\TextRoles\GenericLinkProvider; | ||
use Psr\Log\LoggerInterface; | ||
use T3Docs\GuidesPhpDomain\Nodes\PhpClassNode; | ||
use T3Docs\GuidesPhpDomain\Nodes\PhpInterfaceNode; | ||
use T3Docs\GuidesPhpDomain\Nodes\PhpModifierNode; | ||
use T3Docs\GuidesPhpDomain\Nodes\PhpStructNode; | ||
use T3Docs\GuidesPhpDomain\PhpDomain\FullyQualifiedNameService; | ||
use T3Docs\GuidesPhpDomain\PhpDomain\ModifierService; | ||
|
||
final class StructDirective extends SubDirective | ||
{public function __construct( | ||
Rule $startingRule, | ||
GenericLinkProvider $genericLinkProvider, | ||
private readonly FullyQualifiedNameService $fullyQualifiedNameService, | ||
private readonly AnchorReducer $anchorReducer, | ||
) { | ||
parent::__construct($startingRule); | ||
$genericLinkProvider->addGenericLink($this->getName(), $this->getName()); | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return 'php:struct'; | ||
} | ||
|
||
protected function processSub( | ||
BlockContext $blockContext, | ||
CollectionNode $collectionNode, | ||
Directive $directive, | ||
): Node|null { | ||
$name = trim($directive->getData()); | ||
$fqn = $this->fullyQualifiedNameService->getFullyQualifiedName($name, true); | ||
$id = $this->anchorReducer->reduceAnchor($fqn->toString()); | ||
|
||
return new PhpStructNode( | ||
$id, | ||
$fqn, | ||
$collectionNode->getChildren(), | ||
null, | ||
[], | ||
); | ||
} | ||
} |
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,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace T3Docs\GuidesPhpDomain\Nodes; | ||
|
||
use phpDocumentor\Guides\Nodes\Node; | ||
|
||
final class PhpStructNode extends PhpComponentNode | ||
{ | ||
private const TYPE = 'struct'; | ||
/** | ||
* @param Node $members | ||
* @param Node $value | ||
*/ | ||
public function __construct( | ||
string $id, | ||
FullyQualifiedNameNode $name, | ||
array $value = [], | ||
PhpNamespaceNode|null $namespace = null, | ||
array $members = [], | ||
) { | ||
parent::__construct($id, self::TYPE, $name, $value, $namespace, $members); | ||
} | ||
} |
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,20 @@ | ||
<!-- content start --> | ||
<div class="section" id="php-static-method"> | ||
<h1>PHP static method</h1> | ||
|
||
<dl class="php method"> | ||
<dt class="sig sig-object php" id="dosomething"><span class="sig-name modifier"><span class="pre">static</span></span> | ||
|
||
<span class="sig-name descname"><span class="pre">doSomething</span></span> | ||
<span class="sig-paren">(</span> | ||
<em class="sig-param"><span class="pre">string $whatever</span></em><span class="sig-paren">)</span> | ||
<em class="sig-returns"><span class="pre">: string</span></em> | ||
</dt> | ||
<dd> | ||
<p>Do something</p> | ||
</dd> | ||
</dl> | ||
|
||
</div> | ||
|
||
<!-- content end --> |
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 @@ | ||
app.WARNING: Directive `.. php:staticmethod::` is deprecated use directive `.. php:method::` with option `:static:` instead. {"rst-file":"index.rst"} [] |
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,5 @@ | ||
================= | ||
PHP static method | ||
================= | ||
|
||
.. php:struct:: Employee |