mirror of
https://github.com/erusev/parsedown.git
synced 2023-08-10 21:13:06 +03:00
Constant arrays to static vars for PHP 5.5
This commit is contained in:
@@ -45,7 +45,7 @@ final class Markup implements ContinuableBlock
|
||||
if (\preg_match('/^<[\/]?+(\w*)(?:[ ]*+'.self::REGEX_HTML_ATTRIBUTE.')*+[ ]*+(\/)?>/', $Context->line()->text(), $matches)) {
|
||||
$element = \strtolower($matches[1]);
|
||||
|
||||
if (\array_key_exists($element, Element::TEXT_LEVEL_ELEMENTS)) {
|
||||
if (\array_key_exists($element, Element::$TEXT_LEVEL_ELEMENTS)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,14 @@ final class Emphasis implements Inline
|
||||
/** @var 'em'|'strong' */
|
||||
private $type;
|
||||
|
||||
const STRONG_REGEX = [
|
||||
/** @var array{*: string, _: string} */
|
||||
private static $STRONG_REGEX = [
|
||||
'*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*+[*])+?)[*]{2}(?![*])/s',
|
||||
'_' => '/^__((?:\\\\_|[^_]|_[^_]*+_)+?)__(?!_)/us',
|
||||
];
|
||||
|
||||
const EM_REGEX = [
|
||||
/** @var array{*: string, _: string} */
|
||||
private static $EM_REGEX = [
|
||||
'*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s',
|
||||
'_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us',
|
||||
];
|
||||
@@ -56,9 +58,9 @@ final class Emphasis implements Inline
|
||||
|
||||
$marker = $Excerpt->text()[0] === '*' ? '*' : '_';
|
||||
|
||||
if ($Excerpt->text()[1] === $marker and \preg_match(self::STRONG_REGEX[$marker], $Excerpt->text(), $matches)) {
|
||||
if ($Excerpt->text()[1] === $marker and \preg_match(self::$STRONG_REGEX[$marker], $Excerpt->text(), $matches)) {
|
||||
$emphasis = 'strong';
|
||||
} elseif (\preg_match(self::EM_REGEX[$marker], $Excerpt->text(), $matches)) {
|
||||
} elseif (\preg_match(self::$EM_REGEX[$marker], $Excerpt->text(), $matches)) {
|
||||
$emphasis = 'em';
|
||||
} else {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user