1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

Fix psalm errors

This commit is contained in:
Aidan Woods 2021-10-11 19:23:44 +01:00
parent 98aab22002
commit ca16d7573d
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9
11 changed files with 16 additions and 19 deletions

View File

@ -30,5 +30,10 @@
<PossiblyNullReference> <PossiblyNullReference>
<errorLevel type="suppress"><directory name="tests/src" /></errorLevel> <errorLevel type="suppress"><directory name="tests/src" /></errorLevel>
</PossiblyNullReference> </PossiblyNullReference>
<InternalMethod>
<errorLevel type="suppress">
<directory name="tests" />
</errorLevel>
</InternalMethod>
</issueHandlers> </issueHandlers>
</psalm> </psalm>

View File

@ -82,7 +82,7 @@ final class BlockQuote implements ContinuableBlock
return new self($Lines); return new self($Lines);
} }
if (! $Context->precedingEmptyLines() > 0) { if (!($Context->precedingEmptyLines() > 0)) {
$indentOffset = $Context->line()->indentOffset() + $Context->line()->indent(); $indentOffset = $Context->line()->indentOffset() + $Context->line()->indent();
$Lines = $this->Lines->appendingTextLines($Context->line()->text(), $indentOffset); $Lines = $this->Lines->appendingTextLines($Context->line()->text(), $indentOffset);

View File

@ -35,7 +35,7 @@ final class IndentedCode implements ContinuableBlock
State $State, State $State,
Block $Block = null Block $Block = null
) { ) {
if (isset($Block) && $Block instanceof Paragraph && ! $Context->precedingEmptyLines() > 0) { if (isset($Block) && $Block instanceof Paragraph && ! ($Context->precedingEmptyLines() > 0)) {
return null; return null;
} }

View File

@ -134,7 +134,7 @@ final class TList implements ContinuableBlock
$listStart !== 1 $listStart !== 1
&& isset($Block) && isset($Block)
&& $Block instanceof Paragraph && $Block instanceof Paragraph
&& ! $Context->precedingEmptyLines() > 0 && ! ($Context->precedingEmptyLines() > 0)
) { ) {
return null; return null;
} }
@ -248,7 +248,7 @@ final class TList implements ContinuableBlock
); );
} }
if (! $Context->precedingEmptyLines() > 0) { if (! ($Context->precedingEmptyLines() > 0)) {
$text = $Context->line()->ltrimBodyUpto($requiredIndent); $text = $Context->line()->ltrimBodyUpto($requiredIndent);
$Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingTextLines( $Lis[\count($Lis) -1] = $Lis[\count($Lis) -1]->appendingTextLines(

View File

@ -112,7 +112,6 @@ final class Table implements AcquisitioningBlock, ContinuableBlock
if ( if (
! \preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches) ! \preg_match_all('/(?:(\\\\[|])|[^|`]|`[^`]++`|`)++/', $row, $matches)
|| ! isset($matches[0]) || ! isset($matches[0])
|| ! \is_array($matches[0])
) { ) {
return null; return null;
} }

View File

@ -48,6 +48,7 @@ final class DefinitionBook implements MutableConfigurable
return null; return null;
} }
/** @return static */
public function isolatedCopy(): self public function isolatedCopy(): self
{ {
return new self($this->book); return new self($this->book);

View File

@ -37,6 +37,7 @@ final class SlugRegister implements MutableConfigurable
return $this->register[$slug] ?? 0; return $this->register[$slug] ?? 0;
} }
/** @return static */
public function isolatedCopy(): self public function isolatedCopy(): self
{ {
return new self($this->register); return new self($this->register);

View File

@ -15,7 +15,6 @@ use Erusev\Parsedown\Configurables\BlockTypes;
use Erusev\Parsedown\Configurables\InlineTypes; use Erusev\Parsedown\Configurables\InlineTypes;
use Erusev\Parsedown\Configurables\RecursionLimiter; use Erusev\Parsedown\Configurables\RecursionLimiter;
use Erusev\Parsedown\Html\Renderable; use Erusev\Parsedown\Html\Renderable;
use Erusev\Parsedown\Html\Renderables\Text;
use Erusev\Parsedown\Parsing\Excerpt; use Erusev\Parsedown\Parsing\Excerpt;
use Erusev\Parsedown\Parsing\Line; use Erusev\Parsedown\Parsing\Line;
use Erusev\Parsedown\Parsing\Lines; use Erusev\Parsedown\Parsing\Lines;

View File

@ -30,16 +30,11 @@ class CommonMarkTestWeak extends CommonMarkTestStrict
{ {
$textLevelElements = \array_keys(Element::TEXT_LEVEL_ELEMENTS); $textLevelElements = \array_keys(Element::TEXT_LEVEL_ELEMENTS);
\array_walk( $textLevelElements = \array_map(
$textLevelElements, function ($e) { return \preg_quote($e, '/'); },
/** $textLevelElements
* @param string &$element
* @return void
*/
function (&$element) {
$element = \preg_quote($element, '/');
}
); );
$this->textLevelElementRegex = '\b(?:' . \implode('|', $textLevelElements) . ')\b'; $this->textLevelElementRegex = '\b(?:' . \implode('|', $textLevelElements) . ')\b';
parent::__construct($name, $data, $dataName); parent::__construct($name, $data, $dataName);

View File

@ -75,10 +75,7 @@ class ParsedownTest extends TestCase
foreach ($this->dirs as $dir) { foreach ($this->dirs as $dir) {
$Folder = new \DirectoryIterator($dir); $Folder = new \DirectoryIterator($dir);
foreach ($Folder as $File) { foreach ($Folder as $File) {
/** @var $File DirectoryIterator */
if (! $File->isFile()) { if (! $File->isFile()) {
continue; continue;
} }

View File

@ -32,7 +32,7 @@ final class StateTest extends TestCase
/** /**
* @return void * @return void
* @throws \PHPUnit\Framework\ExpectationFailedException * @throws \PHPUnit\Framework\Exception
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
*/ */
public function testStateCloneVisibility() public function testStateCloneVisibility()