Skip to content

Commit

Permalink
adjusted code for Psalm ^5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderer committed Jan 14, 2023
1 parent 3072ceb commit 0093f35
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/Parser/RegularParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ private function shortcode(array &$names)
}

$this->beginBacktrack();
/** @psalm-suppress MixedArgumentTypeCoercion */
$contentMatchedShortcodes = $this->shortcode($names);
if(\is_string($contentMatchedShortcodes)) {
$closingName = $contentMatchedShortcodes;
Expand Down
4 changes: 3 additions & 1 deletion src/Serializer/XmlSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public function unserialize($text)
if($shortcode->length !== 1) {
throw new \InvalidArgumentException('Invalid shortcode XML!');
}
/** @psalm-suppress PossiblyNullArgument */
$name = $this->getAttribute($shortcode->item(0), 'name');

$bbCode = $this->getValue($xpath->query('/shortcode/bbCode'));
Expand All @@ -98,6 +99,7 @@ public function unserialize($text)
for($i = 0; $i < $elements->length; $i++) {
$node = $elements->item($i);

/** @psalm-suppress PossiblyNullReference */
$parameters[$this->getAttribute($node, 'name')] = $node->hasChildNodes() ? $node->nodeValue : null;
}

Expand All @@ -111,6 +113,7 @@ public function unserialize($text)
*/
private function getValue(\DOMNodeList $node)
{
/** @psalm-suppress PossiblyNullReference,PossiblyNullPropertyFetch */
return $node->length === 1 && $node->item(0)->hasChildNodes()
? $node->item(0)->nodeValue
: null;
Expand All @@ -119,7 +122,6 @@ private function getValue(\DOMNodeList $node)
/**
* @param \DOMNode $node
* @param string $name
* @psalm-suppress UnusedParam
*
* @return string
*/
Expand Down
5 changes: 4 additions & 1 deletion src/Serializer/YamlSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ public function serialize(ShortcodeInterface $shortcode)
*/
public function unserialize($text)
{
/** @psalm-var array{name:string,parameters:array<string,string|null>,bbCode:string|null,content:string|null}|null $data */
/**
* @psalm-var array{name:string,parameters:array<string,string|null>,bbCode:string|null,content:string|null}|null $data
* @psalm-suppress ReservedWord
*/
$data = Yaml::parse($text);

if(!is_array($data)) {
Expand Down

0 comments on commit 0093f35

Please # to comment.