Skip to content

Commit

Permalink
fix: arrayIterator + null string warnings
Browse files Browse the repository at this point in the history
* arrayIterator warning for the \MarkdownExtended\Util\ContentCollection object in PHP 8
* add a validation on an eventually null string
  • Loading branch information
e-picas committed Feb 15, 2024
1 parent c282786 commit a2c79a5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -55,7 +55,7 @@
},
"scripts": {
"doc": "phpdoc project:run --sourcecode --cache-folder=/tmp/phpdoc-cache/ --force -v",
"test": "php ./bin/phpunit --no-coverage --no-logging --testdox",
"test": "php ./bin/phpunit --no-coverage --no-logging --testdox --verbose",
"test-coverage": "php ./bin/phpunit --debug",
"metrics": "php ./bin/phpmetrics --config=.phpmetrics.yml src/",
"dedup": "php ./bin/phpcpd --exclude=src/MarkdownExtendedDev/ src/",
Expand Down
2 changes: 2 additions & 0 deletions src/MarkdownExtended/Util/ContentCollection.php
Expand Up @@ -38,6 +38,7 @@ public function __construct(array $data = [])
*
* @throws \MarkdownExtended\Exception\UnexpectedValueException it the argument does not implement `\MarkdownExtended\API\ContentInterface`
*/
#[\ReturnTypeWillChange]
public function append($content)
{
if (!is_object($content) || !Kernel::valid($content, Kernel::TYPE_CONTENT)) {
Expand All @@ -61,6 +62,7 @@ public function append($content)
*
* @throws \MarkdownExtended\Exception\UnexpectedValueException it the argument does not implement `\MarkdownExtended\API\ContentInterface`
*/
#[\ReturnTypeWillChange]
public function offsetSet($index, $content)
{
if (!is_object($content) || !Kernel::valid($content, Kernel::TYPE_CONTENT)) {
Expand Down
2 changes: 1 addition & 1 deletion src/MarkdownExtended/Util/Helper.php
Expand Up @@ -42,7 +42,7 @@ public static function escapeCodeContent($code)
*/
public static function fillPlaceholders($text, $replacement)
{
return str_replace('%%', $replacement, $text);
return !is_null($text) ? str_replace('%%', $replacement, $text) : $text;
}

/**
Expand Down

0 comments on commit a2c79a5

Please sign in to comment.