This commit is contained in:
Paolo A
2024-08-13 13:44:16 +00:00
parent 1bbb23088d
commit e796d76612
4001 changed files with 30101 additions and 40075 deletions

View File

@@ -14,62 +14,24 @@ declare(strict_types=1);
namespace League\CommonMark\Extension\Footnote\Node;
use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Cursor;
use League\CommonMark\Node\Block\AbstractBlock;
use League\CommonMark\Reference\ReferenceInterface;
use League\CommonMark\Reference\ReferenceableInterface;
/**
* @method children() AbstractBlock[]
*/
final class Footnote extends AbstractBlock
final class Footnote extends AbstractBlock implements ReferenceableInterface
{
/**
* @var FootnoteBackref[]
*/
private $backrefs = [];
/**
* @var ReferenceInterface
*/
private $reference;
/** @psalm-readonly */
private ReferenceInterface $reference;
public function __construct(ReferenceInterface $reference)
{
parent::__construct();
$this->reference = $reference;
}
public function canContain(AbstractBlock $block): bool
{
return true;
}
public function isCode(): bool
{
return false;
}
public function matchesNextLine(Cursor $cursor): bool
{
return false;
}
public function getReference(): ReferenceInterface
{
return $this->reference;
}
public function addBackref(FootnoteBackref $backref): self
{
$this->backrefs[] = $backref;
return $this;
}
/**
* @return FootnoteBackref[]
*/
public function getBackrefs(): array
{
return $this->backrefs;
}
}

View File

@@ -14,19 +14,22 @@ declare(strict_types=1);
namespace League\CommonMark\Extension\Footnote\Node;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Node\Inline\AbstractInline;
use League\CommonMark\Reference\ReferenceInterface;
use League\CommonMark\Reference\ReferenceableInterface;
/**
* Link from the footnote on the bottom of the document back to the reference
*/
final class FootnoteBackref extends AbstractInline
final class FootnoteBackref extends AbstractInline implements ReferenceableInterface
{
/** @var ReferenceInterface */
private $reference;
/** @psalm-readonly */
private ReferenceInterface $reference;
public function __construct(ReferenceInterface $reference)
{
parent::__construct();
$this->reference = $reference;
}

View File

@@ -14,26 +14,8 @@ declare(strict_types=1);
namespace League\CommonMark\Extension\Footnote\Node;
use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\Cursor;
use League\CommonMark\Node\Block\AbstractBlock;
/**
* @method children() AbstractBlock[]
*/
final class FootnoteContainer extends AbstractBlock
{
public function canContain(AbstractBlock $block): bool
{
return $block instanceof Footnote;
}
public function isCode(): bool
{
return false;
}
public function matchesNextLine(Cursor $cursor): bool
{
return false;
}
}

View File

@@ -14,27 +14,30 @@ declare(strict_types=1);
namespace League\CommonMark\Extension\Footnote\Node;
use League\CommonMark\Inline\Element\AbstractInline;
use League\CommonMark\Node\Inline\AbstractInline;
use League\CommonMark\Reference\ReferenceInterface;
use League\CommonMark\Reference\ReferenceableInterface;
final class FootnoteRef extends AbstractInline
final class FootnoteRef extends AbstractInline implements ReferenceableInterface
{
/** @var ReferenceInterface */
private $reference;
private ReferenceInterface $reference;
/** @var string|null */
private $content;
/** @psalm-readonly */
private ?string $content = null;
/**
* @param ReferenceInterface $reference
* @param string|null $content
* @param array<mixed> $data
* @param array<mixed> $data
*/
public function __construct(ReferenceInterface $reference, ?string $content = null, array $data = [])
{
parent::__construct();
$this->reference = $reference;
$this->content = $content;
$this->data = $data;
$this->content = $content;
if (\count($data) > 0) {
$this->data->import($data);
}
}
public function getReference(): ReferenceInterface
@@ -42,11 +45,9 @@ final class FootnoteRef extends AbstractInline
return $this->reference;
}
public function setReference(ReferenceInterface $reference): FootnoteRef
public function setReference(ReferenceInterface $reference): void
{
$this->reference = $reference;
return $this;
}
public function getContent(): ?string