mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Require integer-keyed lists so that array_merge result is predictable
This commit is contained in:
parent
fe1355ef9e
commit
dbc0efeec0
@ -20,7 +20,7 @@ use Erusev\Parsedown\Configurable;
|
|||||||
*/
|
*/
|
||||||
final class BlockTypes implements Configurable
|
final class BlockTypes implements Configurable
|
||||||
{
|
{
|
||||||
/** @var array<array-key, class-string<Block>[]> */
|
/** @var array<array-key, array<int, class-string<Block>>> */
|
||||||
private static $defaultBlockTypes = [
|
private static $defaultBlockTypes = [
|
||||||
'#' => [Header::class],
|
'#' => [Header::class],
|
||||||
'*' => [Rule::class, TList::class],
|
'*' => [Rule::class, TList::class],
|
||||||
@ -47,20 +47,20 @@ final class BlockTypes implements Configurable
|
|||||||
'~' => [FencedCode::class],
|
'~' => [FencedCode::class],
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var class-string<Block>[] */
|
/** @var array<int, class-string<Block>> */
|
||||||
private static $defaultUnmarkedBlockTypes = [
|
private static $defaultUnmarkedBlockTypes = [
|
||||||
IndentedCode::class,
|
IndentedCode::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array<array-key, class-string<Block>[]> */
|
/** @var array<array-key, array<int, class-string<Block>>> */
|
||||||
private $blockTypes;
|
private $blockTypes;
|
||||||
|
|
||||||
/** @var class-string<Block>[] */
|
/** @var array<int, class-string<Block>> */
|
||||||
private $unmarkedBlockTypes;
|
private $unmarkedBlockTypes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<array-key, class-string<Block>[]> $blockTypes
|
* @param array<array-key, array<int, class-string<Block>>> $blockTypes
|
||||||
* @param class-string<Block>[] $unmarkedBlockTypes
|
* @param array<int, class-string<Block>> $unmarkedBlockTypes
|
||||||
*/
|
*/
|
||||||
public function __construct(array $blockTypes, array $unmarkedBlockTypes)
|
public function __construct(array $blockTypes, array $unmarkedBlockTypes)
|
||||||
{
|
{
|
||||||
@ -79,7 +79,7 @@ final class BlockTypes implements Configurable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $marker
|
* @param string $marker
|
||||||
* @param class-string<Block>[] $newBlockTypes
|
* @param array<int, class-string<Block>> $newBlockTypes
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function settingMarked($marker, array $newBlockTypes)
|
public function settingMarked($marker, array $newBlockTypes)
|
||||||
@ -91,7 +91,7 @@ final class BlockTypes implements Configurable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class-string<Block>[] $newUnmarkedBlockTypes
|
* @param array<int, class-string<Block>> $newUnmarkedBlockTypes
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function settingUnmarked(array $newUnmarkedBlockTypes)
|
public function settingUnmarked(array $newUnmarkedBlockTypes)
|
||||||
@ -100,7 +100,7 @@ final class BlockTypes implements Configurable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class-string<Block>[] $removeBlockTypes
|
* @param array<int, class-string<Block>> $removeBlockTypes
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function removing(array $removeBlockTypes)
|
public function removing(array $removeBlockTypes)
|
||||||
@ -108,8 +108,8 @@ final class BlockTypes implements Configurable
|
|||||||
return new self(
|
return new self(
|
||||||
\array_map(
|
\array_map(
|
||||||
/**
|
/**
|
||||||
* @param class-string<Block>[] $blockTypes
|
* @param array<int, class-string<Block>> $blockTypes
|
||||||
* @return class-string<Block>[]
|
* @return array<int, class-string<Block>>
|
||||||
*/
|
*/
|
||||||
function ($blockTypes) use ($removeBlockTypes) {
|
function ($blockTypes) use ($removeBlockTypes) {
|
||||||
return \array_diff($blockTypes, $removeBlockTypes);
|
return \array_diff($blockTypes, $removeBlockTypes);
|
||||||
@ -122,7 +122,7 @@ final class BlockTypes implements Configurable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $marker
|
* @param string $marker
|
||||||
* @return class-string<Block>[]
|
* @return array<int, class-string<Block>>
|
||||||
*/
|
*/
|
||||||
public function markedBy($marker)
|
public function markedBy($marker)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ final class BlockTypes implements Configurable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return class-string<Block>[]
|
* @return array<int, class-string<Block>>
|
||||||
*/
|
*/
|
||||||
public function unmarked()
|
public function unmarked()
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ use Erusev\Parsedown\Configurable;
|
|||||||
*/
|
*/
|
||||||
final class InlineTypes implements Configurable
|
final class InlineTypes implements Configurable
|
||||||
{
|
{
|
||||||
/** @var array<array-key, class-string<Inline>[]> */
|
/** @var array<array-key, array<int, class-string<Inline>>> */
|
||||||
private static $defaultInlineTypes = [
|
private static $defaultInlineTypes = [
|
||||||
'!' => [Image::class],
|
'!' => [Image::class],
|
||||||
'*' => [Emphasis::class],
|
'*' => [Emphasis::class],
|
||||||
@ -38,14 +38,14 @@ final class InlineTypes implements Configurable
|
|||||||
"\n" => [HardBreak::class, SoftBreak::class],
|
"\n" => [HardBreak::class, SoftBreak::class],
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var array<array-key, class-string<Inline>[]> */
|
/** @var array<array-key, array<int, class-string<Inline>>> */
|
||||||
private $inlineTypes;
|
private $inlineTypes;
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $inlineMarkers;
|
private $inlineMarkers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array<array-key, class-string<Inline>[]> $inlineTypes
|
* @param array<array-key, array<int, class-string<Inline>>> $inlineTypes
|
||||||
*/
|
*/
|
||||||
public function __construct(array $inlineTypes)
|
public function __construct(array $inlineTypes)
|
||||||
{
|
{
|
||||||
@ -60,15 +60,15 @@ final class InlineTypes implements Configurable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param class-string<Inline>[] $removeInlineTypes
|
* @param array<int, class-string<Inline>> $removeInlineTypes
|
||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function removing(array $removeInlineTypes)
|
public function removing(array $removeInlineTypes)
|
||||||
{
|
{
|
||||||
return new self(\array_map(
|
return new self(\array_map(
|
||||||
/**
|
/**
|
||||||
* @param class-string<Inline>[] $inlineTypes
|
* @param array<int, class-string<Inline>> $inlineTypes
|
||||||
* @return class-string<Inline>[]
|
* @return array<int, class-string<Inline>>
|
||||||
*/
|
*/
|
||||||
function ($inlineTypes) use ($removeInlineTypes) {
|
function ($inlineTypes) use ($removeInlineTypes) {
|
||||||
return \array_diff($inlineTypes, $removeInlineTypes);
|
return \array_diff($inlineTypes, $removeInlineTypes);
|
||||||
@ -79,7 +79,7 @@ final class InlineTypes implements Configurable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $marker
|
* @param string $marker
|
||||||
* @return class-string<Inline>[]
|
* @return array<int, class-string<Inline>>
|
||||||
*/
|
*/
|
||||||
public function markedBy($marker)
|
public function markedBy($marker)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user