Skip to content

Commit

Permalink
Bumped the requirements for s9e/sweetdom
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Dec 21, 2023
1 parent d490cd3 commit 25714e6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,43 @@ on:
branches: [ master ]

jobs:
tests:
outdated:
runs-on: ubuntu-latest
container: setupphp/node@sha256:9271c0a914deb70c1717ec113410c9d43e48123d0ed398bb696f00f4f0ef15ba

strategy:
matrix:
php-version:
- "8.1"

steps:
- uses: "actions/checkout@v3"
- uses: "shivammathur/setup-php@v2"
with:
php-version: ${{ matrix.php-version }}

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: php-outdated

- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress

- name: Run test suite
run: composer run-script test

current:
runs-on: ubuntu-latest
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"

steps:
- uses: "actions/checkout@v3"
Expand All @@ -29,7 +59,7 @@ jobs:
uses: actions/cache@v3
with:
path: vendor
key: php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}
key: php-${{ matrix.php-version }}

- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
"keywords": ["bbcode","bbcodes","blog","censor","embed","emoji","emoticons","engine","forum","html","markdown","markup","media","parser","shortcodes"],
"license": "MIT",
"require": {
"php": "~8.1.22 || ~8.2.9 || ^8.3",
"php": "^8.1",
"ext-dom": "*",
"ext-filter": "*",
"lib-pcre": ">=8.13",

"s9e/regexp-builder": "^1.4",
"s9e/sweetdom": "^3.0"
"s9e/sweetdom": "^3.3"
},
"require-dev": {
"code-lts/doctum": "*",
Expand Down
7 changes: 6 additions & 1 deletion src/Utils/ParsedDOM/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace s9e\TextFormatter\Utils\ParsedDOM;

use const LIBXML_NSCLEAN, SORT_STRING, false;
use function ksort, substr, strpos;
use function class_alias, class_exists, ksort, substr, strpos;
use s9e\SweetDOM\Document as SweetDocument;
use s9e\TextFormatter\Configurator\Validators\TagName;
use s9e\TextFormatter\Configurator\Validators\AttributeName;
Expand All @@ -26,6 +26,11 @@ public function __construct(string $version = '1.0', string $encoding = 'utf-8')
{
parent::__construct($version, $encoding);

// Create an alias to whichever SweetDOM\Element subclass is used on current PHP version
if (!class_exists(SweetElement::class, false))
{
class_alias($this->getNodesNamespace() . '\\Element', SweetElement::class, false);
}
$this->registerNodeClass('DOMElement', Element::class);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/ParsedDOM/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
use DOMNode;
use const SORT_STRING;
use function count, ksort, preg_match;
use s9e\SweetDOM\Element as SweetElement;

// This requires the SweetElement class to be aliased to the correct s9e\SweetDOM\Element subclass
class Element extends SweetElement
{
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Configurator/Helpers/TemplateModifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function ($m)
'/\\$[0-9]+/',
function ($m, $node)
{
return ['literal', get_class($node)];
return ['literal', preg_replace('(SweetDOM\\\\\\K.*\\\\)', '', get_class($node))];
},
'<b id="s9e\\SweetDOM\\Attr">s9e\\SweetDOM\\Text</b>'
],
Expand Down

0 comments on commit 25714e6

Please sign in to comment.