From b5becae048e2bb9a1af41f5759569947e09b1bdb Mon Sep 17 00:00:00 2001 From: Kevin Wenger Date: Fri, 17 May 2024 16:15:20 +0200 Subject: [PATCH] fix PHPStan extends unknown class ckeditor --- .gitlab-ci.yml | 2 +- CHANGELOG.md | 1 + composer.json | 2 +- phpstan.neon | 9 +++++++++ src/Plugin/Filter/NbspCleanerFilter.php | 12 ++++-------- 5 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 phpstan.neon diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0d875be..6a70616 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -34,7 +34,7 @@ variables: # Opt in to testing previous & next minor (Drupal 10.0.x and 10.2.x). OPT_IN_TEST_PREVIOUS_MINOR: '1' OPT_IN_TEST_NEXT_MINOR: '1' - # The 4.x branch of the CDN module requires PHP >=8.1, rather than core's >=7.4. + # The 3.x branch of the NBSP module requires Drupal 10.x minimum. CORE_PREVIOUS_PHP_MIN: '8.1' # Opt in to testing $CORE_MAJOR_DEVELOPMENT (currently Drupal 11). OPT_IN_TEST_NEXT_MAJOR: '1' diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc65d4..002ed87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - fix tests on Drupal 10.2+ using HTML5 filter - fix issue #3432756: Splitting the links in two +- fix PHPStan extends unknown class ckeditor ### Removed - removed translation-files - Issue #3365383 diff --git a/composer.json b/composer.json index 14161f3..1d81e79 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "drupal/nbsp", "description": "Minimal module to insert a non-breaking space ( ) into the content by pressing Ctrl+Space or using the provided button.", "type": "drupal-module", - "homepage": "https://www.drupal.org/sandbox/wengerk/nbsp", + "homepage": "https://www.drupal.org/project/nbsp", "authors": [ { "name": "Antistatique", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..c4819cf --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,9 @@ +includes: + - phar://phpstan.phar/conf/bleedingEdge.neon + +parameters: + level: 1 + reportUnmatchedIgnoredErrors: false + ignoreErrors: + # new static() is a best practice in Drupal, so we cannot fix that. + - "#^Unsafe usage of new static#" diff --git a/src/Plugin/Filter/NbspCleanerFilter.php b/src/Plugin/Filter/NbspCleanerFilter.php index 051afc9..58e0c99 100644 --- a/src/Plugin/Filter/NbspCleanerFilter.php +++ b/src/Plugin/Filter/NbspCleanerFilter.php @@ -58,16 +58,12 @@ protected function swapNbspHtml($text) { $xpath = new \DOMXPath($document); foreach ($xpath->query('//span[@class="nbsp"]') as $node) { - if (!empty($node)) { - // PHP DOM replacing the nbsp-span with nbsp character. - $node->parentNode->replaceChild(new \DOMText(self::UTF_8_NBSP), $node); - } + // PHP DOM replacing the nbsp-span with nbsp character. + $node->parentNode->replaceChild(new \DOMText(self::UTF_8_NBSP), $node); } foreach ($xpath->query('//nbsp') as $node) { - if (!empty($node)) { - // PHP DOM replacing the nbsp-tag with nbsp character. - $node->parentNode->replaceChild(new \DOMText(self::UTF_8_NBSP), $node); - } + // PHP DOM replacing the nbsp-tag with nbsp character. + $node->parentNode->replaceChild(new \DOMText(self::UTF_8_NBSP), $node); } return Html::serialize($document);