Skip to content

Commit 2d24d33

Browse files
committed
Drop Phug < 1
1 parent 735a5a1 commit 2d24d33

4 files changed

Lines changed: 23 additions & 16 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
3939
- name: Install dependencies
4040
if: steps.composer-cache.outputs.cache-hit != 'true'
41-
run: composer update --prefer-dist --prefer-${{ matrix.setup }} --no-progress --no-interaction
41+
run: composer update --prefer-dist --prefer-${{ matrix.setup }} --no-progress --no-interaction ${{ matrix.php >= 8.1 && '--ignore-platform-req=php' || '' }}
4242

4343
- name: Run test suite
4444
run: vendor/bin/phpunit --no-coverage --verbose

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
],
1212
"require": {
1313
"php": ">=7.0",
14-
"phug/compiler": "^0.5.0 || ^1.0.0",
15-
"phug/formatter": "^0.5.42 || ^1.0.0"
14+
"phug/compiler": "^1.0.0",
15+
"phug/formatter": "^1.0.0"
1616
},
1717
"require-dev": {
18-
"phug/phug": "^0.3.2 || ^1.0.0",
18+
"phug/phug": "^1.0.0",
1919
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5",
2020
"machy8/xhtml-formatter": "^1.0",
2121
"js-phpize/js-phpize-phug": "^2.1"

src/PhugBemto/PhugBemto.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function __construct(ModuleContainerInterface $container)
1212
parent::__construct($container);
1313

1414
$file = realpath(__DIR__ . '/../../bemto.pug');
15-
$includes = $container->getOption('includes');
15+
$includes = $container->getOption('includes') ?? [];
1616

1717
if (!in_array($file, $includes)) {
1818
$includes[] = $file;

tests/AbstractTestCase.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,19 @@ abstract class AbstractTestCase extends TestCase
2222
/**
2323
* @throws \Phug\RendererException
2424
*/
25-
protected function setUp()
25+
protected function getRenderer(): Renderer
2626
{
27-
parent::setUp();
28-
$this->renderer = new Renderer([
29-
'debug' => true,
30-
'execution_max_time' => 180000,
31-
'modules' => array_merge([
32-
PhugBemto::class,
33-
], $this->modules),
34-
]);
27+
if (!isset($this->renderer)) {
28+
$this->renderer = new Renderer([
29+
'debug' => true,
30+
'execution_max_time' => 180000,
31+
'modules' => array_merge([
32+
PhugBemto::class,
33+
], $this->modules),
34+
]);
35+
}
36+
37+
return $this->renderer;
3538
}
3639

3740
protected function renderFile($sourceFile)
@@ -40,13 +43,13 @@ protected function renderFile($sourceFile)
4043
$actualOutput = null;
4144

4245
try {
43-
$actualOutput = $this->renderer->renderFile($sourceFile);
46+
$actualOutput = $this->getRenderer()->renderFile($sourceFile);
4447
} catch (\Throwable $exception) {
4548
$error = $exception;
4649

4750
try {
4851
$debugFile = __DIR__ . '/../debug.php';
49-
file_put_contents($debugFile, $this->renderer->compileFile($sourceFile));
52+
file_put_contents($debugFile, $this->getRenderer()->compileFile($sourceFile));
5053
include $debugFile;
5154
} catch (\Throwable $exception) {
5255
throw new \Exception('Error in ' . $sourceFile . "\n" . $exception->getMessage(), 0, $exception);
@@ -72,6 +75,10 @@ protected static function htmlStandardize($html)
7275
$html = preg_replace('/([a-z"\'])\/>/', '$1 />', $html);
7376
$html = preg_replace('/(<[a-z][^>]*)\s\/>/', '$1>', $html);
7477

78+
if (version_compare(PHP_VERSION, '8.1.0-dev', '>=')) {
79+
$html = str_replace('&#039;', "'", $html);
80+
}
81+
7582
return $html;
7683
}
7784

0 commit comments

Comments
 (0)