diff --git a/app/Helpers/Markdown.php b/app/Helpers/Markdown.php index 76293cef24..7d7f74cff1 100644 --- a/app/Helpers/Markdown.php +++ b/app/Helpers/Markdown.php @@ -165,7 +165,7 @@ protected function lines(array $lines) $indent = 0; - while (isset($line[$indent]) and $line[$indent] === ' ') { + while (isset($line[$indent]) && $line[$indent] === ' ') { $indent++; } @@ -231,7 +231,7 @@ protected function lines(array $lines) // ~ - if (isset($CurrentBlock) and !isset($CurrentBlock['type']) and !isset($CurrentBlock['interrupted'])) { + if (isset($CurrentBlock) && !isset($CurrentBlock['type']) && !isset($CurrentBlock['interrupted'])) { $CurrentBlock['element']['text'] .= "\n".$text; } else { $Blocks[] = $CurrentBlock; @@ -244,7 +244,7 @@ protected function lines(array $lines) // ~ - if (isset($CurrentBlock['continuable']) and $this->isBlockCompletable($CurrentBlock['type'])) { + if (isset($CurrentBlock['continuable']) && $this->isBlockCompletable($CurrentBlock['type'])) { $CurrentBlock = $this->{'block'.$CurrentBlock['type'].'Complete'}($CurrentBlock); } @@ -289,7 +289,7 @@ protected function isBlockCompletable($Type) protected function blockCode($Line, $Block = null) { - if (isset($Block) and !isset($Block['type']) and !isset($Block['interrupted'])) { + if (isset($Block) && !isset($Block['type']) && !isset($Block['interrupted'])) { return; } @@ -344,11 +344,11 @@ protected function blockCodeComplete($Block) protected function blockComment($Line) { - if ($this->markupEscaped or $this->safeMode) { + if ($this->markupEscaped || $this->safeMode) { return; } - if (isset($Line['text'][3]) and $Line['text'][3] === '-' and $Line['text'][2] === '-' and $Line['text'][1] === '!') { + if (isset($Line['text'][3]) && $Line['text'][3] === '-' && $Line['text'][2] === '-' && $Line['text'][1] === '!') { $Block = [ 'markup' => $Line['body'], ]; @@ -450,7 +450,7 @@ protected function blockHeader($Line) if (isset($Line['text'][1])) { $level = 1; - while (isset($Line['text'][$level]) and $Line['text'][$level] === '#') { + while (isset($Line['text'][$level]) && $Line['text'][$level] === '#') { $level++; } @@ -513,7 +513,7 @@ protected function blockList($Line) protected function blockListContinue($Line, array $Block) { - if ($Block['indent'] === $Line['indent'] and preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) { + if ($Block['indent'] === $Line['indent'] && preg_match('/^'.$Block['pattern'].'(?:[ ]+(.*)|$)/', $Line['text'], $matches)) { if (isset($Block['interrupted'])) { $Block['li']['text'][] = ''; @@ -539,7 +539,7 @@ protected function blockListContinue($Line, array $Block) return $Block; } - if ($Line['text'][0] === '[' and $this->blockReference($Line)) { + if ($Line['text'][0] === '[' && $this->blockReference($Line)) { return $Block; } @@ -597,7 +597,7 @@ protected function blockQuote($Line) protected function blockQuoteContinue($Line, array $Block) { - if ($Line['text'][0] === '>' and preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) { + if ($Line['text'][0] === '>' && preg_match('/^>[ ]?(.*)/', $Line['text'], $matches)) { if (isset($Block['interrupted'])) { $Block['element']['text'][] = ''; @@ -637,7 +637,7 @@ protected function blockRule($Line) protected function blockSetextHeader($Line, array $Block = null) { - if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) { + if (!isset($Block) || isset($Block['type']) || isset($Block['interrupted'])) { return; } @@ -653,7 +653,7 @@ protected function blockSetextHeader($Line, array $Block = null) protected function blockMarkup($Line) { - if ($this->markupEscaped or $this->safeMode) { + if ($this->markupEscaped || $this->safeMode) { return; } @@ -675,13 +675,13 @@ protected function blockMarkup($Line) $remainder = substr($Line['text'], $length); if (trim($remainder) === '') { - if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) { + if (isset($matches[2]) || in_array($matches[1], $this->voidElements)) { $Block['closed'] = true; $Block['void'] = true; } } else { - if (isset($matches[2]) or in_array($matches[1], $this->voidElements)) { + if (isset($matches[2]) || in_array($matches[1], $this->voidElements)) { return; } @@ -755,11 +755,11 @@ protected function blockReference($Line) protected function blockTable($Line, array $Block = null) { - if (!isset($Block) or isset($Block['type']) or isset($Block['interrupted'])) { + if (!isset($Block) || isset($Block['type']) || isset($Block['interrupted'])) { return; } - if (strpos($Block['element']['text'], '|') !== false and rtrim($Line['text'], ' -:|') === '') { + if (strpos($Block['element']['text'], '|') !== false && rtrim($Line['text'], ' -:|') === '') { $alignments = []; $divider = $Line['text']; @@ -858,7 +858,7 @@ protected function blockTableContinue($Line, array $Block) return; } - if ($Line['text'][0] === '|' or strpos($Line['text'], '|')) { + if ($Line['text'][0] === '|' || strpos($Line['text'], '|')) { $Elements = []; $row = $Line['text']; @@ -958,7 +958,7 @@ public function line($text, $nonNestables = []) foreach ($this->InlineTypes[$marker] as $inlineType) { // check to see if the current inline type is nestable in the current context - if (!empty($nonNestables) and in_array($inlineType, $nonNestables)) { + if (!empty($nonNestables) && in_array($inlineType, $nonNestables)) { continue; } @@ -970,7 +970,7 @@ public function line($text, $nonNestables = []) // makes sure that the inline belongs to "our" marker - if (isset($Inline['position']) and $Inline['position'] > $markerPosition) { + if (isset($Inline['position']) && $Inline['position'] > $markerPosition) { continue; } @@ -1039,7 +1039,7 @@ protected function inlineCode($Excerpt) protected function inlineEmailTag($Excerpt) { - if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) { + if (strpos($Excerpt['text'], '>') !== false && preg_match('/^<((mailto:)?\S+?@\S+?)>/i', $Excerpt['text'], $matches)) { $url = $matches[1]; if (!isset($matches[2])) { @@ -1067,7 +1067,7 @@ protected function inlineEmphasis($Excerpt) $marker = $Excerpt['text'][0]; - if ($Excerpt['text'][1] === $marker and preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) { + if ($Excerpt['text'][1] === $marker && preg_match($this->StrongRegex[$marker], $Excerpt['text'], $matches)) { $emphasis = 'strong'; } elseif (preg_match($this->EmRegex[$marker], $Excerpt['text'], $matches)) { $emphasis = 'em'; @@ -1087,7 +1087,7 @@ protected function inlineEmphasis($Excerpt) protected function inlineEscapeSequence($Excerpt) { - if (isset($Excerpt['text'][1]) and in_array($Excerpt['text'][1], $this->specialCharacters)) { + if (isset($Excerpt['text'][1]) && in_array($Excerpt['text'][1], $this->specialCharacters)) { return [ 'markup' => $Excerpt['text'][1], 'extent' => 2, @@ -1097,7 +1097,7 @@ protected function inlineEscapeSequence($Excerpt) protected function inlineImage($Excerpt) { - if (!isset($Excerpt['text'][1]) or $Excerpt['text'][1] !== '[') { + if (!isset($Excerpt['text'][1]) || $Excerpt['text'][1] !== '[') { return; } @@ -1190,25 +1190,25 @@ protected function inlineLink($Excerpt) protected function inlineMarkup($Excerpt) { - if ($this->markupEscaped or $this->safeMode or strpos($Excerpt['text'], '>') === false) { + if ($this->markupEscaped || $this->safeMode || strpos($Excerpt['text'], '>') === false) { return; } - if ($Excerpt['text'][1] === '/' and preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches)) { + if ($Excerpt['text'][1] === '/' && preg_match('/^<\/\w[\w-]*[ ]*>/s', $Excerpt['text'], $matches)) { return [ 'markup' => $matches[0], 'extent' => strlen($matches[0]), ]; } - if ($Excerpt['text'][1] === '!' and preg_match('/^/s', $Excerpt['text'], $matches)) { + if ($Excerpt['text'][1] === '!' && preg_match('/^/s', $Excerpt['text'], $matches)) { return [ 'markup' => $matches[0], 'extent' => strlen($matches[0]), ]; } - if ($Excerpt['text'][1] !== ' ' and preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) { + if ($Excerpt['text'][1] !== ' ' && preg_match('/^<\w[\w-]*(?:[ ]*'.$this->regexHtmlAttribute.')*[ ]*\/?>/s', $Excerpt['text'], $matches)) { return [ 'markup' => $matches[0], 'extent' => strlen($matches[0]), @@ -1218,7 +1218,7 @@ protected function inlineMarkup($Excerpt) protected function inlineSpecialCharacter($Excerpt) { - if ($Excerpt['text'][0] === '&' and !preg_match('/^&#?\w+;/', $Excerpt['text'])) { + if ($Excerpt['text'][0] === '&' && !preg_match('/^&#?\w+;/', $Excerpt['text'])) { return [ 'markup' => '&', 'extent' => 1, @@ -1241,7 +1241,7 @@ protected function inlineStrikethrough($Excerpt) return; } - if ($Excerpt['text'][1] === '~' and preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) { + if ($Excerpt['text'][1] === '~' && preg_match('/^~~(?=\S)(.+?)(?<=\S)~~/', $Excerpt['text'], $matches)) { return [ 'extent' => strlen($matches[0]), 'element' => [ @@ -1255,7 +1255,7 @@ protected function inlineStrikethrough($Excerpt) protected function inlineUrl($Excerpt) { - if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') { + if ($this->urlsLinked !== true || !isset($Excerpt['text'][2]) || $Excerpt['text'][2] !== '/') { return; } @@ -1280,7 +1280,7 @@ protected function inlineUrl($Excerpt) protected function inlineUrlTag($Excerpt) { - if (strpos($Excerpt['text'], '>') !== false and preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) { + if (strpos($Excerpt['text'], '>') !== false && preg_match('/^<(\w+:\/{2}[^ >]+)>/i', $Excerpt['text'], $matches)) { $url = $matches[1]; return [ @@ -1372,7 +1372,7 @@ protected function li($lines) $trimmedMarkup = trim($markup); - if (!in_array('', $lines) and substr($trimmedMarkup, 0, 3) === '

') { + if (!in_array('', $lines) && substr($trimmedMarkup, 0, 3) === '

') { $markup = $trimmedMarkup; $markup = substr($markup, 3);