From e1686c3c6cfc60b2aa4f46cd14fc45fca5fd4534 Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Thu, 2 Dec 2021 22:21:09 -0800 Subject: [PATCH 1/2] Cast attr to string to prevent a PHP deprecation warning in 8.1 --- Michelf/MarkdownExtra.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Michelf/MarkdownExtra.php b/Michelf/MarkdownExtra.php index 060a4ae..7fdbdbf 100644 --- a/Michelf/MarkdownExtra.php +++ b/Michelf/MarkdownExtra.php @@ -229,7 +229,7 @@ protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $ } // Split on components - preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr, $matches); + preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', (string)$attr, $matches); $elements = $matches[0]; // Handle classes and IDs (only first ID taken into account) From 6b1fcad9f2d3d3608f3ddc9889efd9e77b237429 Mon Sep 17 00:00:00 2001 From: Kevin Boyd Date: Mon, 16 Jun 2025 21:37:39 -0700 Subject: [PATCH 2/2] Update the call to preg_match_all to coalesce an empty string on $attr --- Michelf/MarkdownExtra.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Michelf/MarkdownExtra.php b/Michelf/MarkdownExtra.php index 7fdbdbf..4f79ff7 100644 --- a/Michelf/MarkdownExtra.php +++ b/Michelf/MarkdownExtra.php @@ -229,7 +229,7 @@ protected function doExtraAttributes($tag_name, $attr, $defaultIdValue = null, $ } // Split on components - preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', (string)$attr, $matches); + preg_match_all('/[#.a-z][-_:a-zA-Z0-9=]+/', $attr ?? '', $matches); $elements = $matches[0]; // Handle classes and IDs (only first ID taken into account)