Skip to content

Commit 8b8da19

Browse files
authored
Merge pull request #57 from pug-php/fix/typing
Fix #58 Handle new Symfony Twig service key
2 parents f36cc82 + bd52014 commit 8b8da19

File tree

9 files changed

+127
-49
lines changed

9 files changed

+127
-49
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Hello,
2+
3+
I encountered an issue when:
4+
5+
**Provide here exact steps and/or minimal code chunk to reproduce the issue**
6+
7+
Pug-Symfony version: **PUT HERE YOUR PUG-SYMFONY VERSION (exact version, not the range)**
8+
9+
PHP version: **PUT HERE YOUR PHP VERSION**
10+
11+
I expected to get:
12+
13+
```
14+
Put here expected result
15+
```
16+
17+
But I actually get:
18+
19+
```
20+
Put here the current error/output you get instead
21+
```
22+
23+
Thanks!

.github/workflows/coverage.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
tests:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: ['ubuntu-latest']
17+
php: ['7.4']
18+
19+
name: PHP ${{ matrix.php }} - ${{ matrix.os }}
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
tools: composer:v2
29+
coverage: xdebug
30+
31+
- name: Install dependencies
32+
run: composer update --prefer-dist --no-progress --no-suggest --prefer-stable ${{ matrix.php >= 8 && '--ignore-platform-req=php' || '' }};
33+
34+
- name: Run test suite
35+
run: vendor/bin/phpunit --verbose --coverage-text --coverage-clover=coverage.xml
36+
37+
- name: Code Climate Test Reporter
38+
if: matrix.coverage
39+
uses: aktions/codeclimate-test-reporter@v1
40+
with:
41+
codeclimate-test-reporter-id: ${{ secrets.CC_TEST_REPORTER_ID }}
42+
command: after-build -t clover
43+
env:
44+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
45+
continue-on-error: true
46+
47+
- name: Coverage
48+
if: matrix.coverage
49+
run: bash <(curl -s https://codecov.io/bash)
50+
env:
51+
PHP_VERSION: ${{ matrix.php }}

.github/workflows/tests.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
tests:
11+
runs-on: ${{ matrix.os }}
12+
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: ['ubuntu-latest', 'windows-latest']
17+
php: ['7.2', '7.3', '7.4', '8.0', '8.1']
18+
19+
name: PHP ${{ matrix.php }} - ${{ matrix.os }}
20+
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Setup PHP
25+
uses: shivammathur/setup-php@v2
26+
with:
27+
php-version: ${{ matrix.php }}
28+
tools: composer:v2
29+
coverage: none
30+
31+
- name: Install dependencies
32+
run: composer update --prefer-dist --no-progress --no-suggest --prefer-stable ${{ matrix.php >= 8 && '--ignore-platform-req=php' || '' }};
33+
34+
- name: Run test suite
35+
run: vendor/bin/phpunit --verbose --no-coverage

.travis.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Pug-Symfony
22
[![Latest Stable Version](https://poser.pugx.org/pug-php/pug-symfony/v/stable.png)](https://packagist.org/packages/pug-php/pug-symfony)
3-
[![Build Status](https://travis-ci.org/pug-php/pug-symfony.svg?branch=master)](https://travis-ci.org/pug-php/pug-symfony)
3+
[![GitHub Actions](https://github.com/pug-php/pug-symfony/workflows/Tests/badge.svg)](https://github.com/pug-php/pug-symfony/actions)
44
[![StyleCI](https://styleci.io/repos/61784988/shield?style=flat)](https://styleci.io/repos/61784988)
55
[![Test Coverage](https://codeclimate.com/github/pug-php/pug-symfony/badges/coverage.svg)](https://codecov.io/github/pug-php/pug-symfony?branch=master)
66

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"description": "Pug template engine for Symfony",
77
"type": "library",
88
"require": {
9-
"php": "^7.2.5",
9+
"php": "^7.2.5 || ^8.0",
1010
"phug/component": "^1.1.0",
1111
"pug/installer": "^1.0.0",
1212
"pug-php/pug": "^3.4.0",

src/Pug/Symfony/Traits/HelpersHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ protected function enhanceTwig(): void
313313
$this->twig = Environment::fromTwigEnvironment($this->twig, $this, $this->container);
314314

315315
$services = static::getPrivateProperty($this->container, 'services', $propertyAccessor);
316-
$services['twig'] = $this->twig;
316+
$key = isset($services['.container.private.twig']) ? '.container.private.twig' : 'twig';
317+
$services[$key] = $this->twig;
317318
$propertyAccessor->setValue($this->container, $services);
318319
}
319320

tests/Pug/InstallerTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,15 @@ public function testTestInstall()
4848
self::assertTrue(PugSymfonyEngine::install(new Event('update', new Composer(), $io), $projectDir));
4949
self::assertSame(['Bundle added to config/bundles.php'], $io->getLastOutput());
5050
self::assertFileExists(__DIR__.'/../../installed');
51-
$expected = preg_replace('/(\S)\s+=>/', '$1 =>', file_get_contents(__DIR__.'/../project-s5/config/bundles.php'));
52-
$actual = preg_replace('/(\S)\s+=>/', '$1 =>', file_get_contents("$projectDir/config/bundles.php"));
51+
$getContent = static function (string $file): string {
52+
return preg_replace(
53+
'/(\S)\s+=>/',
54+
'$1 =>',
55+
str_replace("\r", '', file_get_contents($file))
56+
);
57+
};
58+
$expected = $getContent(__DIR__.'/../project-s5/config/bundles.php');
59+
$actual = $getContent("$projectDir/config/bundles.php");
5360
self::assertSame($expected, $actual);
5461

5562
unlink(__DIR__.'/../../installed');

tests/Pug/TestKernel.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ public function setProjectDirectory(string $projectDirectory): void
4242
$this->projectDirectory = $projectDirectory;
4343
}
4444

45-
public function getLogDir()
45+
public function getLogDir(): string
4646
{
4747
return sys_get_temp_dir().'/pug-symfony-log';
4848
}
4949

50-
public function getRootDir()
50+
public function getRootDir(): string
5151
{
5252
return realpath(__DIR__.'/../project-s5');
5353
}
@@ -57,14 +57,14 @@ public function getRootDir()
5757
*
5858
* @throws Exception
5959
*/
60-
public function registerContainerConfiguration(LoaderInterface $loader)
60+
public function registerContainerConfiguration(LoaderInterface $loader): void
6161
{
6262
parent::registerContainerConfiguration($loader);
6363
$loader->load(__DIR__.'/../project-s5/config/packages/framework.yaml');
6464
$loader->load($this->containerConfigurator);
6565
}
6666

67-
public function getCacheDir()
67+
public function getCacheDir(): string
6868
{
6969
return sys_get_temp_dir().'/pug-symfony-cache';
7070
}
@@ -73,7 +73,7 @@ public function getCacheDir()
7373
* Override the parent method to force recompiling the container.
7474
* For performance reasons the container is also not dumped to disk.
7575
*/
76-
protected function initializeContainer()
76+
protected function initializeContainer(): void
7777
{
7878
$this->container = $this->buildContainer();
7979
$this->container->compile();

0 commit comments

Comments
 (0)