diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 499fcea..00d9a0b 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -2,7 +2,7 @@ parameters:
ignoreErrors:
-
message: "#^Function phpDocumentor\\\\Guides\\\\DependencyInjection\\\\template not found\\.$#"
- count: 7
+ count: 8
path: src/DependencyInjection/GuidesPhpDomainExtension.php
-
diff --git a/resources/config/php-domain.php b/resources/config/php-domain.php
index 75e6cea..01bac95 100644
--- a/resources/config/php-domain.php
+++ b/resources/config/php-domain.php
@@ -8,6 +8,7 @@
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use T3Docs\GuidesPhpDomain\Directives\Php\ConstDirective;
+use T3Docs\GuidesPhpDomain\Directives\Php\StaticMethodDirective;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
use T3Docs\GuidesPhpDomain\Directives\Php\EnumDirective;
@@ -33,6 +34,7 @@
->set(InterfaceDirective::class)
->set(MethodDirective::class)
->set(NamespaceDirective::class)
+ ->set(StaticMethodDirective::class)
->set(FullyQualifiedNameService::class)
->set(MethodNameService::class)
->set(NamespaceRepository::class)
diff --git a/resources/template/html/body/directive/php/method.html.twig b/resources/template/html/body/directive/php/method.html.twig
index 5036e5e..ba0f36e 100644
--- a/resources/template/html/body/directive/php/method.html.twig
+++ b/resources/template/html/body/directive/php/method.html.twig
@@ -1,6 +1,9 @@
-
- {{ renderNode(node.methodName) }}
+ {%- for modifier in node.modifiers -%}
+ {{- renderNode(modifier) }}{{ ' ' -}}
+ {%- endfor -%}
+ {{- renderNode(node.methodName) -}}
-
{{ renderNode(node.value) }}
diff --git a/resources/template/html/body/directive/php/modifier.html.twig b/resources/template/html/body/directive/php/modifier.html.twig
new file mode 100644
index 0000000..6b3f765
--- /dev/null
+++ b/resources/template/html/body/directive/php/modifier.html.twig
@@ -0,0 +1 @@
+{{ node.type }}
diff --git a/src/DependencyInjection/GuidesPhpDomainExtension.php b/src/DependencyInjection/GuidesPhpDomainExtension.php
index a02aaea..329fa17 100644
--- a/src/DependencyInjection/GuidesPhpDomainExtension.php
+++ b/src/DependencyInjection/GuidesPhpDomainExtension.php
@@ -15,6 +15,7 @@
use T3Docs\GuidesPhpDomain\Nodes\PhpComponentNode;
use T3Docs\GuidesPhpDomain\Nodes\PhpConstNode;
use T3Docs\GuidesPhpDomain\Nodes\PhpMethodNode;
+use T3Docs\GuidesPhpDomain\Nodes\PhpModifierNode;
use T3Docs\GuidesPhpDomain\Nodes\PhpNamespaceNode;
use function dirname;
@@ -44,6 +45,7 @@ public function prepend(ContainerBuilder $container): void
template(PhpConstNode::class, 'body/directive/php/const.html.twig'),
template(PhpNamespaceNode::class, 'body/directive/php/namespace.html.twig'),
template(PhpMethodNode::class, 'body/directive/php/method.html.twig'),
+ template(PhpModifierNode::class, 'body/directive/php/modifier.html.twig'),
template(MemberNameNode::class, 'body/directive/php/memberName.html.twig'),
template(MethodNameNode::class, 'body/directive/php/methodName.html.twig'),
],
diff --git a/src/Directives/Php/StaticMethodDirective.php b/src/Directives/Php/StaticMethodDirective.php
new file mode 100644
index 0000000..11fbe2e
--- /dev/null
+++ b/src/Directives/Php/StaticMethodDirective.php
@@ -0,0 +1,51 @@
+addGenericLink($this->getName(), $this->getName());
+ }
+
+ public function getName(): string
+ {
+ return 'php:staticmethod';
+ }
+
+ protected function processSub(
+ BlockContext $blockContext,
+ CollectionNode $collectionNode,
+ Directive $directive,
+ ): Node|null {
+ $name = $this->methodNameService->getMethodName(trim($directive->getData()));
+ $id = $this->anchorReducer->reduceAnchor($name->toString());
+
+ return new PhpMethodNode(
+ $id,
+ $name,
+ $collectionNode->getChildren(),
+ [new PhpModifierNode(PhpModifierNode::STATIC)]
+ );
+ }
+}
diff --git a/src/Nodes/PhpMethodNode.php b/src/Nodes/PhpMethodNode.php
index 0035000..14322ae 100644
--- a/src/Nodes/PhpMethodNode.php
+++ b/src/Nodes/PhpMethodNode.php
@@ -11,11 +11,13 @@ final class PhpMethodNode extends PhpMemberNode
private const TYPE = 'method';
/**
* @param Node[] $value
+ * @param PhpModifierNode[] $modifiers
*/
public function __construct(
string $id,
private readonly MethodNameNode $methodName,
array $value = [],
+ private readonly array $modifiers = [],
) {
parent::__construct($id, self::TYPE, $methodName->toString(), $value);
}
@@ -24,4 +26,12 @@ public function getMethodName(): MethodNameNode
{
return $this->methodName;
}
+
+ /**
+ * @return PhpModifierNode[]
+ */
+ public function getModifiers(): array
+ {
+ return $this->modifiers;
+ }
}
diff --git a/src/Nodes/PhpModifierNode.php b/src/Nodes/PhpModifierNode.php
new file mode 100644
index 0000000..d23a76a
--- /dev/null
+++ b/src/Nodes/PhpModifierNode.php
@@ -0,0 +1,27 @@
+
+ */
+final class PhpModifierNode extends AbstractNode
+{
+ public const STATIC = 'static';
+ public function __construct(
+ private readonly string $type,
+ ) {
+ $this->value = $type;
+ }
+
+ public function getType(): string
+ {
+ return $this->type;
+ }
+}
diff --git a/tests/integration/static-method/expected/index.html b/tests/integration/static-method/expected/index.html
new file mode 100644
index 0000000..5b2ec74
--- /dev/null
+++ b/tests/integration/static-method/expected/index.html
@@ -0,0 +1,20 @@
+
+
+
PHP static method
+
+
+ - static
+
+doSomething
+(
+string $whatever)
+: string
+
+ -
+
Do something
+
+
+
+
+
+
diff --git a/tests/integration/static-method/input/index.rst b/tests/integration/static-method/input/index.rst
new file mode 100644
index 0000000..87e81bc
--- /dev/null
+++ b/tests/integration/static-method/input/index.rst
@@ -0,0 +1,7 @@
+=================
+PHP static method
+=================
+
+.. php:staticmethod:: doSomething(string $whatever): string
+
+ Do something