Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade phpstan #231

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip

## [Unreleased][unreleased]

### Fixed

- Fixed missing type checks and coercions

## [5.1.0] - 2022-03-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"require-dev": {
"mikehaertl/php-shellcommand": "^1.1.0",
"phpstan/phpstan": "^0.12.99",
"phpstan/phpstan": "^1.8.8",
"phpunit/phpunit": "^8.5 || ^9.2",
"scrutinizer/ocular": "^1.6",
"unleashedtech/php-coding-standard": "^2.7",
Expand Down
2 changes: 1 addition & 1 deletion src/Converter/LinkConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ private function isValidEmail(string $email): bool

private function shouldStrip(): bool
{
return $this->config->getOption('strip_placeholder_links') ?? false;
return \boolval($this->config->getOption('strip_placeholder_links') ?? false);
}
}
4 changes: 2 additions & 2 deletions src/Converter/ListItemConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function convert(ElementInterface $element): string
}

if ($listType === 'ul') {
$listItemStyle = $this->config->getOption('list_item_style', '-');
$listItemStyleAlternate = $this->config->getOption('list_item_style_alternate');
$listItemStyle = \strval($this->config->getOption('list_item_style', '-'));
$listItemStyleAlternate = \strval($this->config->getOption('list_item_style_alternate', ''));
if (! isset($this->listItemStyle)) {
$this->listItemStyle = $listItemStyleAlternate ?: $listItemStyle;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Converter/TableConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function convert(ElementInterface $element): string
}

$value = \str_replace("\n", ' ', $value);
$value = \str_replace('|', $this->config->getOption('table_pipe_escape') ?? '\|', $value);
$value = \str_replace('|', \strval($this->config->getOption('table_pipe_escape') ?? '\|'), $value);

return '| ' . \trim($value) . ' ';
case 'thead':
Expand Down
2 changes: 2 additions & 0 deletions src/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ public function getChildren(): array
{
$ret = [];
foreach ($this->node->childNodes as $node) {
/** @psalm-suppress RedundantCondition */
\assert($node instanceof \DOMNode);
$ret[] = new self($node);
}

Expand Down
2 changes: 1 addition & 1 deletion src/HtmlConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ protected function convertToMarkdown(ElementInterface $element): string
$tag = $element->getTagName();

// Strip nodes named in remove_nodes
$tagsToRemove = \explode(' ', $this->getConfig()->getOption('remove_nodes') ?? '');
$tagsToRemove = \explode(' ', \strval($this->getConfig()->getOption('remove_nodes') ?? ''));
if (\in_array($tag, $tagsToRemove, true)) {
return '';
}
Expand Down