gl-website-deployer/vendor/doctrine/rst-parser/tests/RefInsideDirective/VersionAddedDirective.php

46 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2024-11-19 08:02:04 +01:00
<?php
declare(strict_types=1);
namespace Doctrine\Tests\RST\RefInsideDirective;
use Doctrine\RST\Directives\SubDirective;
use Doctrine\RST\Nodes\Node;
use Doctrine\RST\Parser;
use function sprintf;
use function strip_tags;
class VersionAddedDirective extends SubDirective
{
public function getName(): string
{
return 'versionadded';
}
/** @param string[] $options */
public function processSub(
Parser $parser,
?Node $document,
string $variable,
string $data,
array $options
): ?Node {
return $parser->getNodeFactory()->createCallableNode(
static function () use ($data, $document): string {
$nodeValue = '';
if ($document !== null) {
$nodeValue = $document->render();
}
return sprintf(
'<div class="versionadded"><p><span class="versionmodified">New in version %s: </span>%s</p></div>',
$data,
strip_tags($nodeValue, '<a><code>')
);
}
);
}
}