Skip to content

Commit 8a41917

Browse files
committed
Avoid new deprecations in twig
1 parent c71b02f commit 8a41917

32 files changed

+280
-170
lines changed

.gitattributes

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1+
/bin export-ignore
2+
/build export-ignore
13
/tests export-ignore
4+
/tools export-ignore
25
/examples export-ignore
36
/docker export-ignore
47
/vendor-bin export-ignore
58
/.editorconfig export-ignore
69
/.gitattributes export-ignore
710
/.gitignore export-ignore
8-
/.travis.yml export-ignore
9-
/captainhook.json export-ignore
10-
/phpstan.neon export-ignore
11-
/phpstan-baseline.neon export-ignore
12-
/phpunit.xml.dist export-ignore
13-
/psalm.xml export-ignore
14-
/psalm-baseline.xml export-ignore
15-
/ruleset.xml export-ignore
11+
/.travis.yml export-ignore

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/vendor
44
/vendor-bin/**/vendor
55
/vendor-bin/**/composer.lock
6-
/.phpunit.result.cache
7-
/.phpcs-cache
86
/tests/_output
97
/tests/_reports
10-
/build
8+
/build
9+
/tools/cache/*
10+
!/tools/cache/.gitkeep

.travis.yml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PHP Syntax for Twig
22
===================
33

4-
[![Build Status](https://img.shields.io/travis/com/squirrelphp/twig-php-syntax.svg)](https://travis-ci.com/squirrelphp/twig-php-syntax) [![Test Coverage](https://api.codeclimate.com/v1/badges/56ed1e15544f2bb7609e/test_coverage)](https://codeclimate.com/github/squirrelphp/twig-php-syntax/test_coverage) ![PHPStan](https://img.shields.io/badge/style-level%208-success.svg?style=flat-round&label=phpstan) [![Packagist Version](https://img.shields.io/packagist/v/squirrelphp/twig-php-syntax.svg?style=flat-round)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![PHP Version](https://img.shields.io/packagist/php-v/squirrelphp/twig-php-syntax.svg)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![Software License](https://img.shields.io/badge/license-MIT-success.svg?style=flat-round)](LICENSE)
4+
![Test Coverage](https://img.shields.io/badge/style-100%25-success.svg?style=flat-round&label=test%20coverage) ![PHPStan](https://img.shields.io/badge/style-level%2max-success.svg?style=flat-round&label=phpstan) [![Packagist Version](https://img.shields.io/packagist/v/squirrelphp/twig-php-syntax.svg?style=flat-round)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![PHP Version](https://img.shields.io/packagist/php-v/squirrelphp/twig-php-syntax.svg)](https://packagist.org/packages/squirrelphp/twig-php-syntax) [![Software License](https://img.shields.io/badge/license-MIT-success.svg?style=flat-round)](LICENSE)
55

66
Enables syntax known from PHP in Twig, so PHP developers can more easily create and edit Twig templates. This is especially useful for small projects, where the PHP developers end up writing Twig templates and it is not worth it to have a slightly different syntax in your templates.
77

bin/vendorbin

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env php
2+
<?php
3+
error_reporting(E_ALL); // Report everything, even notices
4+
set_time_limit(0); // No time limit for console commands
5+
6+
$projectDir = dirname(__DIR__);
7+
8+
$composerRunType = $_SERVER['argv'][1] ?? 'outdated';
9+
10+
require $projectDir.'/vendor/autoload.php';
11+
12+
$sourceFinder = new \Symfony\Component\Finder\Finder();
13+
$sourceFinder->in($projectDir . '/vendor-bin')->directories()->depth(0)->sortByName();
14+
15+
/** @var array<string, \Symfony\Component\Process\Process> $tools */
16+
$tools = [];
17+
18+
foreach ($sourceFinder as $directory) {
19+
$toolName = $directory->getFilename();
20+
21+
$options = [
22+
'--ansi',
23+
];
24+
25+
if ($composerRunType === 'update') {
26+
$options[] = '--no-progress';
27+
}
28+
29+
$process = new \Symfony\Component\Process\Process(['composer', $composerRunType, ...$options]);
30+
if (isset($_SERVER['COMPOSER_CACHE_DIR'])) {
31+
$process->setEnv(['COMPOSER_CACHE_DIR' => $_SERVER['COMPOSER_CACHE_DIR']]);
32+
}
33+
$process->setWorkingDirectory($projectDir . '/vendor-bin/' . $toolName);
34+
$process->start();
35+
$process->wait();
36+
37+
echo 'Running composer ' . $composerRunType . ' for ' . $toolName . ' ...' . "\n";
38+
39+
$processOutput = \trim($process->getOutput());
40+
41+
if ($composerRunType === 'update') {
42+
$processOutput = \trim($processOutput . "\n" . $process->getErrorOutput());
43+
}
44+
45+
if (\strlen($processOutput) > 0) {
46+
echo $processOutput . "\n";
47+
}
48+
}

composer.json

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,26 @@
1717
}
1818
],
1919
"require": {
20-
"php": ">=7.2.5",
21-
"twig/twig": "^3.9"
20+
"php": ">=8.2",
21+
"twig/twig": "^3.15"
2222
},
2323
"require-dev": {
24-
"bamarni/composer-bin-plugin": "^1.3",
25-
"captainhook/plugin-composer": "^5.0",
26-
"phpunit/phpunit": "^10.0"
24+
"captainhook/captainhook-phar": "^5.0",
25+
"captainhook/hook-installer": "^1.0",
26+
"phpunit/phpunit": "^10.0",
27+
"symfony/finder": "^7.0",
28+
"symfony/process": "^7.0"
2729
},
2830
"config": {
2931
"sort-packages": false,
3032
"allow-plugins": {
31-
"bamarni/composer-bin-plugin": true,
32-
"captainhook/plugin-composer": true
33+
"captainhook/captainhook-phar": true,
34+
"captainhook/hook-installer": true
35+
}
36+
},
37+
"extra": {
38+
"captainhook": {
39+
"config": "tools/captainhook.json"
3340
}
3441
},
3542
"autoload": {
@@ -43,20 +50,18 @@
4350
}
4451
},
4552
"scripts": {
46-
"phpstan": "vendor/bin/phpstan analyse",
47-
"phpstan_full": "vendor/bin/phpstan clear-result-cache && vendor/bin/phpstan analyse",
48-
"phpstan_base": "vendor/bin/phpstan analyse --generate-baseline",
49-
"psalm": "vendor/bin/psalm --show-info=false",
50-
"psalm_full": "vendor/bin/psalm --clear-cache && vendor/bin/psalm --show-info=false",
51-
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
52-
"phpunit": "vendor/bin/phpunit --colors=always",
53-
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
54-
"phpunit_migrate": "vendor/bin/phpunit --configuration=phpunit.xml.dist --migrate-configuration",
55-
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports",
56-
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
57-
"phpcs_diff": "vendor/bin/phpcs -s --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
58-
"phpcs_fix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
59-
"binupdate": "@composer bin all update --ansi",
60-
"bininstall": "@composer bin all install --ansi"
53+
"phpstan": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
54+
"phpstan_full": "rm -Rf tools/cache/phpstan && vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
55+
"phpstan_base": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon --generate-baseline=tools/phpstan-baseline.php",
56+
"psalm": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false",
57+
"psalm_full": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --clear-cache && vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false",
58+
"psalm_base": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --set-baseline=tools/psalm-baseline.xml",
59+
"phpunit": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --colors=always",
60+
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-html=tests/_reports",
61+
"phpcs": "vendor-bin/phpcs/vendor/bin/phpcs --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
62+
"phpcs_diff": "vendor-bin/phpcs/vendor/bin/phpcs -s --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
63+
"phpcs_fix": "vendor-bin/phpcs/vendor/bin/phpcbf --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
64+
"binupdate": "bin/vendorbin update",
65+
"binoutdated": "bin/vendorbin outdated"
6166
}
6267
}

docker/compose/composer.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
services:
2+
composer:
3+
image: thecodingmachine/php:8.2-v4-cli
4+
container_name: squirrel_composer
5+
working_dir: /usr/src/app
6+
command: [ "composer", "${COMPOSER_COMMAND}", "--ansi" ]
7+
logging:
8+
driver: "none"
9+
volumes:
10+
- .:/usr/src/app
11+
- "$HOME/.cache/composer:/tmp/composer_cache"
12+
environment:
13+
COMPOSER_CACHE_DIR: "/tmp/composer_cache"
14+
COMPOSER_ROOT_VERSION: 'dev-master'
15+
# Basic config for CLI commands
16+
PHP_INI_ERROR_REPORTING: "E_ALL"
17+
PHP_INI_MEMORY_LIMIT: "1g"
18+
PHP_INI_MAX_EXECUTION_TIME: 3600
19+
# Enable Opcache + JIT
20+
PHP_INI_OPCACHE__ENABLE_CLI: 1
21+
PHP_INI_OPCACHE__MEMORY_CONSUMPTION: 256
22+
PHP_INI_OPCACHE__VALIDATE_TIMESTAMPS: 0
23+
PHP_INI_JIT_BUFFER_SIZE: "256m"
24+
# For code coverage
25+
PHP_EXTENSION_XDEBUG: 1
26+
XDEBUG_MODE: coverage

docker/composer

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
# Get directory of this script
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4+
5+
COMPOSER_COMMAND="$@" docker compose -f "$DIR/compose/composer.yml" --project-directory "$DIR/.." --project-name=squirrel_composer up --abort-on-container-exit --exit-code-from=composer --no-log-prefix composer 2>&1

phpstan-baseline.neon

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

phpstan.neon

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

0 commit comments

Comments
 (0)