Skip to content

Commit 487ce3a

Browse files
authored
Merge pull request #98 from jtojnar/backports
[1.x] Backport fixes
2 parents 5638357 + 0bae412 commit 487ce3a

File tree

9 files changed

+102
-85
lines changed

9 files changed

+102
-85
lines changed

.github/workflows/coding-standards.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ on:
44
pull_request:
55
branches:
66
- master
7+
- 1.x
78
push:
89
branches:
910
- master
11+
- 1.x
1012

1113
env:
1214
SYMFONY_PHPUNIT_VERSION: 7.5
1315

1416
jobs:
1517
coding-standards:
1618
name: "CS Fixer & PHPStan"
17-
runs-on: "ubuntu-20.04"
19+
runs-on: "ubuntu-22.04"
1820

1921
strategy:
2022
matrix:
@@ -23,7 +25,7 @@ jobs:
2325

2426
steps:
2527
- name: "Checkout"
26-
uses: "actions/checkout@v2"
28+
uses: "actions/checkout@v4"
2729

2830
- name: "Install PHP"
2931
uses: "shivammathur/setup-php@v2"
@@ -39,7 +41,7 @@ jobs:
3941
run: "composer require phpstan/phpstan phpstan/phpstan-phpunit --dev --no-progress --no-suggest"
4042

4143
- name: "Install dependencies with Composer"
42-
uses: "ramsey/composer-install@v1"
44+
uses: "ramsey/composer-install@v3"
4345
with:
4446
composer-options: "--optimize-autoloader --prefer-dist"
4547

.github/workflows/continuous-integration.yml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ on:
44
pull_request:
55
branches:
66
- "master"
7+
- "1.x"
78
push:
89
branches:
910
- "master"
11+
- "1.x"
1012

1113
env:
1214
fail-fast: true
1315

1416
jobs:
1517
phpunit:
1618
name: "PHPUnit (PHP ${{ matrix.php }})"
17-
runs-on: "ubuntu-20.04"
19+
runs-on: "ubuntu-22.04"
1820

1921
strategy:
2022
matrix:
@@ -26,10 +28,14 @@ jobs:
2628
- "7.3"
2729
- "7.4"
2830
- "8.0"
31+
- "8.1"
32+
- "8.2"
33+
- "8.3"
34+
- "8.4"
2935

3036
steps:
3137
- name: "Checkout"
32-
uses: "actions/checkout@v2"
38+
uses: "actions/checkout@v4"
3339
with:
3440
fetch-depth: 2
3541

@@ -38,23 +44,17 @@ jobs:
3844
with:
3945
php-version: "${{ matrix.php }}"
4046
coverage: "none"
41-
tools: composer:v1
47+
tools: composer:v2
4248
extensions: tidy
4349
ini-values: "date.timezone=Europe/Paris"
4450
env:
4551
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4652

47-
- name: "Force PHPUnit version"
48-
if: matrix.php >= '7.2'
49-
run: "echo $SYMFONY_PHPUNIT_VERSION"
50-
env:
51-
SYMFONY_PHPUNIT_VERSION: 7.5
52-
5353
- name: "Remove useless deps"
5454
run: "composer remove friendsofphp/php-cs-fixer --dev --no-progress --no-update"
5555

5656
- name: "Install dependencies with Composer"
57-
uses: "ramsey/composer-install@v1"
57+
uses: "ramsey/composer-install@v3"
5858
with:
5959
composer-options: "--optimize-autoloader --prefer-dist"
6060

@@ -66,7 +66,7 @@ jobs:
6666

6767
phpunit-coverage:
6868
name: "PHPUnit coverage (PHP ${{ matrix.php }})"
69-
runs-on: "ubuntu-20.04"
69+
runs-on: "ubuntu-22.04"
7070

7171
strategy:
7272
matrix:
@@ -75,7 +75,7 @@ jobs:
7575

7676
steps:
7777
- name: "Checkout"
78-
uses: "actions/checkout@v2"
78+
uses: "actions/checkout@v4"
7979
with:
8080
fetch-depth: 2
8181

@@ -84,7 +84,7 @@ jobs:
8484
with:
8585
php-version: "${{ matrix.php }}"
8686
coverage: "xdebug"
87-
tools: composer:v1
87+
tools: composer:v2
8888
extensions: tidy
8989
ini-values: "date.timezone=Europe/Paris"
9090
env:
@@ -94,7 +94,7 @@ jobs:
9494
run: "composer remove friendsofphp/php-cs-fixer --dev --no-progress --no-update"
9595

9696
- name: "Install dependencies with Composer"
97-
uses: "ramsey/composer-install@v1"
97+
uses: "ramsey/composer-install@v3"
9898
with:
9999
composer-options: "--optimize-autoloader --prefer-dist"
100100

@@ -103,8 +103,6 @@ jobs:
103103

104104
- name: "Run PHPUnit (with coverage)"
105105
run: "php vendor/bin/simple-phpunit -v --coverage-clover build/logs/clover.xml"
106-
env:
107-
SYMFONY_PHPUNIT_VERSION: 7.5
108106

109107
- name: "Retrieve Coveralls phar"
110108
run: "wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.2/php-coveralls.phar"
@@ -119,7 +117,7 @@ jobs:
119117

120118
phpunit-lowest:
121119
name: "PHPUnit lowest deps (PHP ${{ matrix.php }})"
122-
runs-on: "ubuntu-20.04"
120+
runs-on: "ubuntu-22.04"
123121

124122
strategy:
125123
matrix:
@@ -128,7 +126,7 @@ jobs:
128126

129127
steps:
130128
- name: "Checkout"
131-
uses: "actions/checkout@v2"
129+
uses: "actions/checkout@v4"
132130
with:
133131
fetch-depth: 2
134132

@@ -137,7 +135,7 @@ jobs:
137135
with:
138136
php-version: "${{ matrix.php }}"
139137
coverage: "none"
140-
tools: composer:v1
138+
tools: composer:v2
141139
extensions: tidy
142140
ini-values: "date.timezone=Europe/Paris"
143141
env:
@@ -147,7 +145,7 @@ jobs:
147145
run: "composer remove friendsofphp/php-cs-fixer --dev --no-progress --no-update"
148146

149147
- name: "Install dependencies with Composer"
150-
uses: "ramsey/composer-install@v1"
148+
uses: "ramsey/composer-install@v3"
151149
with:
152150
composer-options: "--optimize-autoloader --prefer-dist"
153151
dependency-versions: "lowest"
@@ -157,11 +155,9 @@ jobs:
157155

158156
- name: "Run PHPUnit"
159157
run: "php vendor/bin/simple-phpunit -v"
160-
env:
161-
SYMFONY_PHPUNIT_VERSION: 7.5
162158

163159
phpunit-composerv2:
164-
name: "PHPUnit with Composer v2 (PHP ${{ matrix.php }})"
160+
name: "PHPUnit with Composer v1 (PHP ${{ matrix.php }})"
165161
runs-on: "ubuntu-20.04"
166162

167163
strategy:
@@ -180,7 +176,7 @@ jobs:
180176
with:
181177
php-version: "${{ matrix.php }}"
182178
coverage: "none"
183-
tools: composer:v2
179+
tools: composer:v1
184180
extensions: tidy
185181
ini-values: "date.timezone=Europe/Paris"
186182
env:
@@ -199,5 +195,3 @@ jobs:
199195

200196
- name: "Run PHPUnit"
201197
run: "php vendor/bin/simple-phpunit -v"
202-
env:
203-
SYMFONY_PHPUNIT_VERSION: 7.5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ coverage/
33
composer.lock
44
.php_cs.cache
55
.phpunit.result.cache
6+
phpstan.neon

.php-cs-fixer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
'strict_comparison' => true,
2727
'strict_param' => true,
2828
'concat_space' => ['spacing' => 'one'],
29+
// Pulled in by @Symfony, we cannot add property types until we bump PHP to ≥ 7.4
30+
'no_null_property_initialization' => false,
31+
// Pulled in by @Symfony with `const` but const visibility requires PHP ≥ 7.1
32+
'visibility_required' => ['elements' => ['method', 'property']],
2933
])
3034
->setFinder($finder)
3135
;

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"require-dev": {
3333
"friendsofphp/php-cs-fixer": "^2.14",
3434
"monolog/monolog": "^1.24|^2.1",
35-
"symfony/phpunit-bridge": "^4.4|^5.3"
35+
"symfony/phpunit-bridge": "^4.4|^5.3|^6.0|^7.0"
3636
},
3737
"suggest": {
3838
"ext-tidy": "Used to clean up given HTML and to avoid problems with bad HTML structure."
@@ -42,5 +42,10 @@
4242
},
4343
"autoload-dev": {
4444
"psr-4": { "Tests\\Readability\\": "tests/" }
45+
},
46+
"scripts": {
47+
"fix": "php-cs-fixer fix --verbose --diff",
48+
"phpstan": "phpstan analyze --memory-limit 512M",
49+
"test": "simple-phpunit -v"
4550
}
4651
}

phpstan.neon renamed to phpstan.dist.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ parameters:
66

77
# https://github.com/phpstan/phpstan/issues/694#issuecomment-350724288
88
bootstrapFiles:
9-
- vendor/bin/.phpunit/phpunit-7.5-0/vendor/autoload.php
9+
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
1010

1111
includes:
1212
- vendor/phpstan/phpstan-phpunit/extension.neon

src/JSLikeHTMLElement.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class JSLikeHTMLElement extends \DOMElement
3939
/**
4040
* Used for setting innerHTML like it's done in JavaScript:.
4141
*
42-
* @code
42+
* ```php
4343
* $div->innerHTML = '<h2>Chapter 2</h2><p>The story begins...</p>';
44-
* @endcode
44+
* ```
4545
*/
4646
public function __set($name, $value)
4747
{
@@ -79,14 +79,13 @@ public function __set($name, $value)
7979
} else {
8080
// $value is probably ill-formed
8181
$f = new \DOMDocument();
82-
$value = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8');
8382

8483
// Using <htmlfragment> will generate a warning, but so will bad HTML
8584
// (and by this point, bad HTML is what we've got).
8685
// We use it (and suppress the warning) because an HTML fragment will
8786
// be wrapped around <html><body> tags which we don't really want to keep.
8887
// Note: despite the warning, if loadHTML succeeds it will return true.
89-
$result = $f->loadHTML('<htmlfragment>' . $value . '</htmlfragment>');
88+
$result = $f->loadHTML('<meta charset="utf-8"><htmlfragment>' . $value . '</htmlfragment>');
9089

9190
if ($result) {
9291
$import = $f->getElementsByTagName('htmlfragment')->item(0);
@@ -105,9 +104,9 @@ public function __set($name, $value)
105104
/**
106105
* Used for getting innerHTML like it's done in JavaScript:.
107106
*
108-
* @code
107+
* ```php
109108
* $string = $div->innerHTML;
110-
* @endcode
109+
* ```
111110
*/
112111
public function __get($name)
113112
{

0 commit comments

Comments
 (0)