Skip to content

Commit 944ec6e

Browse files
committed
Require PHP 8.4, allow Symfony 8 + streamline configuration
1 parent 0ea9e4d commit 944ec6e

29 files changed

+302
-80
lines changed

.editorconfig

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,4 @@ insert_final_newline = false
1111

1212
[*.php]
1313

14-
end_of_line = lf
15-
charset = utf-8
16-
indent_style = space
17-
indent_size = 4
18-
insert_final_newline = true
19-
trim_trailing_whitespace = true
14+
insert_final_newline = true

.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

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: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,27 @@
1919
}
2020
],
2121
"require": {
22-
"php": ">=8.0",
23-
"symfony/validator": "^6.0|^7.0"
22+
"php": ">=8.4",
23+
"symfony/validator": "^7.0|^8.0"
2424
},
2525
"require-dev": {
26-
"bamarni/composer-bin-plugin": "^1.3",
27-
"captainhook/plugin-composer": "^5.0",
28-
"phpunit/phpunit": "^10.0",
29-
"mockery/mockery": "^1.0"
26+
"captainhook/captainhook-phar": "^5.0",
27+
"captainhook/hook-installer": "^1.0",
28+
"phpunit/phpunit": "^12.0",
29+
"mockery/mockery": "^1.0",
30+
"symfony/finder": "^8.0",
31+
"symfony/process": "^8.0"
3032
},
3133
"config": {
3234
"sort-packages": false,
3335
"allow-plugins": {
34-
"bamarni/composer-bin-plugin": true,
35-
"captainhook/plugin-composer": true
36+
"captainhook/captainhook-phar": true,
37+
"captainhook/hook-installer": true
38+
}
39+
},
40+
"extra": {
41+
"captainhook": {
42+
"config": "tools/captainhook.json"
3643
}
3744
},
3845
"autoload": {
@@ -47,18 +54,19 @@
4754
}
4855
},
4956
"scripts": {
50-
"phpstan": "vendor/bin/phpstan analyse",
51-
"phpstan_full": "vendor/bin/phpstan clear-result-cache && vendor/bin/phpstan analyse",
52-
"phpstan_base": "vendor/bin/phpstan analyse --generate-baseline",
53-
"psalm": "vendor/bin/psalm --show-info=false",
54-
"psalm_full": "vendor/bin/psalm --clear-cache && vendor/bin/psalm --show-info=false",
55-
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
56-
"phpunit": "vendor/bin/phpunit --colors=always",
57-
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
58-
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports",
59-
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=src/Cascade.php --colors src tests",
60-
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --ignore=src/Cascade.php src tests",
61-
"binupdate": "@composer bin all update --ansi",
62-
"bininstall": "@composer bin all install --ansi"
57+
"phpstan": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
58+
"phpstan_full": "rm -Rf tools/cache/phpstan && vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
59+
"phpstan_base": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon --generate-baseline=tools/phpstan-baseline.php",
60+
"psalm": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false",
61+
"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",
62+
"psalm_base": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --set-baseline=tools/psalm-baseline.xml",
63+
"phpunit": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --colors=always",
64+
"phpunit_clover": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-text --coverage-clover build/logs/clover.xml",
65+
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-html=tests/_reports",
66+
"phpcs": "vendor-bin/phpcs/vendor/bin/phpcs --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
67+
"phpcs_diff": "vendor-bin/phpcs/vendor/bin/phpcs -s --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
68+
"phpcs_fix": "vendor-bin/phpcs/vendor/bin/phpcbf --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
69+
"binupdate": "bin/vendorbin update",
70+
"binoutdated": "bin/vendorbin outdated"
6371
}
6472
}

docker/compose/captainhook.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
captainhook:
3+
image: thecodingmachine/php:8.4-v5-cli
4+
container_name: squirrel_captainhook
5+
tty: true
6+
working_dir: /usr/src/app
7+
volumes:
8+
- ../..:/usr/src/app
9+
environment:
10+
# Basic config for CLI commands
11+
PHP_INI_ERROR_REPORTING: "E_ALL"
12+
PHP_INI_MEMORY_LIMIT: "1g"
13+
PHP_INI_MAX_EXECUTION_TIME: 3600
14+
# Enable Opcache + JIT
15+
PHP_INI_OPCACHE__ENABLE_CLI: 1
16+
PHP_INI_OPCACHE__MEMORY_CONSUMPTION: 256
17+
PHP_INI_OPCACHE__VALIDATE_TIMESTAMPS: 0
18+
PHP_INI_JIT_BUFFER_SIZE: "256m"

docker/compose/composer.yml

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

docker/compose/coverage.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
services:
2+
coverage:
3+
image: thecodingmachine/php:8.4-v5-cli
4+
container_name: squirrel_coverage
5+
tty: true
6+
working_dir: /usr/src/app
7+
command: [ "vendor/bin/phpunit", "--configuration=tools/phpunit.xml.dist", "--colors=always", "--coverage-html", "tests/_reports"]
8+
volumes:
9+
- .:/usr/src/app
10+
- "$HOME/.cache/composer:/tmp/composer_cache"
11+
environment:
12+
# Basic config for CLI commands
13+
PHP_INI_ERROR_REPORTING: "E_ALL"
14+
PHP_INI_MEMORY_LIMIT: "1g"
15+
PHP_INI_MAX_EXECUTION_TIME: 3600
16+
# Enable Opcache, disable JIT
17+
PHP_INI_OPCACHE__ENABLE_CLI: 1
18+
PHP_INI_OPCACHE__MEMORY_CONSUMPTION: 256
19+
PHP_INI_OPCACHE__VALIDATE_TIMESTAMPS: 0
20+
PHP_INI_OPCACHE__JIT: "disable"
21+
# Composer config to use global cache
22+
COMPOSER_CACHE_DIR: "/tmp/composer_cache"
23+
COMPOSER_ROOT_VERSION: 'dev-master'
24+
# Enable XDEBUG for coverage
25+
PHP_EXTENSION_XDEBUG: 1
26+
XDEBUG_MODE: coverage
27+
#PHP_EXTENSION_PCOV: 1
28+
# Install all composer dependencies before running tests + delete previous coverage report
29+
STARTUP_COMMAND_1: composer --no-interaction --no-progress --no-scripts --no-plugins --quiet install
30+
STARTUP_COMMAND_2: rm -rf /usr/src/app/tests/_reports/*

docker/compose/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
services:
2+
test:
3+
image: thecodingmachine/php:8.4-v5-cli
4+
container_name: squirrel_test
5+
tty: true
6+
working_dir: /usr/src/app
7+
command: ["vendor/bin/phpunit", "--configuration=tools/phpunit.xml.dist", "--colors=always"]
8+
volumes:
9+
- .:/usr/src/app
10+
- "$HOME/.cache/composer:/tmp/composer_cache"
11+
environment:
12+
# Basic config for CLI commands
13+
PHP_INI_ERROR_REPORTING: "E_ALL"
14+
PHP_INI_MEMORY_LIMIT: "1g"
15+
PHP_INI_MAX_EXECUTION_TIME: 3600
16+
# Enable Opcache, disable JIT
17+
PHP_INI_OPCACHE__ENABLE_CLI: 1
18+
PHP_INI_OPCACHE__MEMORY_CONSUMPTION: 256
19+
PHP_INI_OPCACHE__VALIDATE_TIMESTAMPS: 0
20+
PHP_INI_OPCACHE__JIT: "disable"
21+
# Composer config to use global cache
22+
COMPOSER_CACHE_DIR: "/tmp/composer_cache"
23+
COMPOSER_ROOT_VERSION: 'dev-master'
24+
# Install all composer dependencies before running tests
25+
STARTUP_COMMAND_1: composer --no-interaction --no-progress --no-scripts --no-plugins --quiet install

docker/composer

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
# Remove all running docker containers
6+
COMPOSER_COMMAND="$@" docker compose -f "$DIR/compose/composer.yml" --project-directory "$DIR/.." --project-name=squirrel_composer down --volumes --remove-orphans
7+
8+
# Run composer with given arguments
9+
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

0 commit comments

Comments
 (0)