1
0
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:
Aidan Woods 2019-01-30 19:39:00 +00:00
parent fe1355ef9e
commit dbc0efeec0
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
2 changed files with 20 additions and 20 deletions

View File

@ -20,7 +20,7 @@ use Erusev\Parsedown\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 = [
'#' => [Header::class],
'*' => [Rule::class, TList::class],
@ -47,20 +47,20 @@ final class BlockTypes implements Configurable
'~' => [FencedCode::class],
];
/** @var class-string<Block>[] */
/** @var array<int, class-string<Block>> */
private static $defaultUnmarkedBlockTypes = [
IndentedCode::class,
];
/** @var array<array-key, class-string<Block>[]> */
/** @var array<array-key, array<int, class-string<Block>>> */
private $blockTypes;
/** @var class-string<Block>[] */
/** @var array<int, class-string<Block>> */
private $unmarkedBlockTypes;
/**
* @param array<array-key, class-string<Block>[]> $blockTypes
* @param class-string<Block>[] $unmarkedBlockTypes
* @param array<array-key, array<int, class-string<Block>>> $blockTypes
* @param array<int, class-string<Block>> $unmarkedBlockTypes
*/
public function __construct(array $blockTypes, array $unmarkedBlockTypes)
{
@ -79,7 +79,7 @@ final class BlockTypes implements Configurable
/**
* @param string $marker
* @param class-string<Block>[] $newBlockTypes
* @param array<int, class-string<Block>> $newBlockTypes
* @return self
*/
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
*/
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
*/
public function removing(array $removeBlockTypes)
@ -108,8 +108,8 @@ final class BlockTypes implements Configurable
return new self(
\array_map(
/**
* @param class-string<Block>[] $blockTypes
* @return class-string<Block>[]
* @param array<int, class-string<Block>> $blockTypes
* @return array<int, class-string<Block>>
*/
function ($blockTypes) use ($removeBlockTypes) {
return \array_diff($blockTypes, $removeBlockTypes);
@ -122,7 +122,7 @@ final class BlockTypes implements Configurable
/**
* @param string $marker
* @return class-string<Block>[]
* @return array<int, class-string<Block>>
*/
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()
{

View File

@ -23,7 +23,7 @@ use Erusev\Parsedown\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 = [
'!' => [Image::class],
'*' => [Emphasis::class],
@ -38,14 +38,14 @@ final class InlineTypes implements Configurable
"\n" => [HardBreak::class, SoftBreak::class],
];
/** @var array<array-key, class-string<Inline>[]> */
/** @var array<array-key, array<int, class-string<Inline>>> */
private $inlineTypes;
/** @var string */
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)
{
@ -60,15 +60,15 @@ final class InlineTypes implements Configurable
}
/**
* @param class-string<Inline>[] $removeInlineTypes
* @param array<int, class-string<Inline>> $removeInlineTypes
* @return self
*/
public function removing(array $removeInlineTypes)
{
return new self(\array_map(
/**
* @param class-string<Inline>[] $inlineTypes
* @return class-string<Inline>[]
* @param array<int, class-string<Inline>> $inlineTypes
* @return array<int, class-string<Inline>>
*/
function ($inlineTypes) use ($removeInlineTypes) {
return \array_diff($inlineTypes, $removeInlineTypes);
@ -79,7 +79,7 @@ final class InlineTypes implements Configurable
/**
* @param string $marker
* @return class-string<Inline>[]
* @return array<int, class-string<Inline>>
*/
public function markedBy($marker)
{