Skip to content

Commit b20b135

Browse files
committed
Project cleanup + strings dependency upgrade
1 parent a248949 commit b20b135

File tree

20 files changed

+275
-59
lines changed

20 files changed

+275
-59
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: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,33 @@
2020
}
2121
],
2222
"require": {
23-
"php": ">=8.1",
24-
"symfony/dependency-injection": "^5.0|^6.0|^7.0",
23+
"php": ">=8.2",
24+
"symfony/dependency-injection": "^7.0",
2525
"squirrelphp/debug": "^2.0",
26-
"squirrelphp/strings": "^1.0"
26+
"squirrelphp/strings": "^2.0"
2727
},
2828
"require-dev": {
29-
"bamarni/composer-bin-plugin": "^1.3",
30-
"captainhook/plugin-composer": "^5.0",
31-
"phpunit/phpunit": "^10.0",
32-
"symfony/form": "^5.0|^6.0|^7.0",
33-
"symfony/twig-bundle": "^5.0|^6.0|^7.0"
29+
"captainhook/captainhook-phar": "^5.0",
30+
"captainhook/hook-installer": "^1.0",
31+
"phpunit/phpunit": "^11.2",
32+
"symfony/finder": "^7.0",
33+
"symfony/form": "^7.0",
34+
"symfony/process": "^7.0",
35+
"symfony/twig-bundle": "^7.0"
3436
},
3537
"suggest": {
3638
"squirrelphp/strings-bundle": "Symfony integration of squirrelphp/strings"
3739
},
3840
"config": {
3941
"sort-packages": false,
4042
"allow-plugins": {
41-
"bamarni/composer-bin-plugin": true,
42-
"captainhook/plugin-composer": true
43+
"captainhook/captainhook-phar": true,
44+
"captainhook/hook-installer": true
45+
}
46+
},
47+
"extra": {
48+
"captainhook": {
49+
"config": "tools/captainhook.json"
4350
}
4451
},
4552
"autoload": {
@@ -53,18 +60,19 @@
5360
}
5461
},
5562
"scripts": {
56-
"phpstan": "vendor/bin/phpstan analyse",
57-
"phpstan_full": "vendor/bin/phpstan clear-result-cache && vendor/bin/phpstan analyse",
58-
"phpstan_base": "vendor/bin/phpstan analyse --generate-baseline",
59-
"psalm": "vendor/bin/psalm --show-info=false",
60-
"psalm_full": "vendor/bin/psalm --clear-cache && vendor/bin/psalm --show-info=false",
61-
"psalm_base": "vendor/bin/psalm --set-baseline=psalm-baseline.xml",
62-
"phpunit": "vendor/bin/phpunit --colors=always",
63-
"phpunit_clover": "vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml",
64-
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html tests/_reports",
65-
"phpcs": "vendor/bin/phpcs --standard=ruleset.xml --extensions=php --cache=.phpcs-cache --colors src tests",
66-
"phpcsfix": "vendor/bin/phpcbf --standard=ruleset.xml --extensions=php --cache=.phpcs-cache src tests",
67-
"binupdate": "@composer bin all update --ansi",
68-
"bininstall": "@composer bin all install --ansi"
63+
"phpstan": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
64+
"phpstan_full": "rm -Rf tools/cache/phpstan && vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon",
65+
"phpstan_base": "vendor-bin/phpstan/vendor/bin/phpstan analyse --configuration=tools/phpstan.neon --generate-baseline=tools/phpstan-baseline.php",
66+
"psalm": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --show-info=false",
67+
"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",
68+
"psalm_base": "vendor-bin/psalm/vendor/bin/psalm --config=tools/psalm.xml --set-baseline=tools/psalm-baseline.xml",
69+
"phpunit": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --colors=always",
70+
"phpunit_clover": "vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-text --coverage-clover build/logs/clover.xml",
71+
"coverage": "XDEBUG_MODE=coverage vendor/bin/phpunit --configuration=tools/phpunit.xml.dist --coverage-html=tests/_reports",
72+
"phpcs": "vendor-bin/phpcs/vendor/bin/phpcs --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
73+
"phpcs_diff": "vendor-bin/phpcs/vendor/bin/phpcs -s --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
74+
"phpcs_fix": "vendor-bin/phpcs/vendor/bin/phpcbf --standard=tools/ruleset.xml --extensions=php --cache=tools/cache/.phpcs-cache --colors src tests",
75+
"binupdate": "bin/vendorbin update",
76+
"binoutdated": "bin/vendorbin outdated"
6977
}
7078
}

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-v5-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.neon

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

src/DependencyInjection/Compiler/StringFilterPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Squirrel\Strings\Filter\NormalizeToAlphanumericLowercaseFilter;
1717
use Squirrel\Strings\Filter\RemoveEmailsFilter;
1818
use Squirrel\Strings\Filter\RemoveExcessSpacesFilter;
19-
use Squirrel\Strings\Filter\RemoveHTMLTagCharacters;
19+
use Squirrel\Strings\Filter\RemoveHTMLTagCharactersFilter;
2020
use Squirrel\Strings\Filter\RemoveHTMLTagsFilter;
2121
use Squirrel\Strings\Filter\RemoveNonAlphabeticFilter;
2222
use Squirrel\Strings\Filter\RemoveNonAlphanumericFilter;
@@ -66,7 +66,7 @@ class StringFilterPass implements CompilerPassInterface
6666
RemoveExcessSpacesFilter::class,
6767
RemoveEmailsFilter::class,
6868
RemoveHTMLTagsFilter::class,
69-
RemoveHTMLTagCharacters::class,
69+
RemoveHTMLTagCharactersFilter::class,
7070
RemoveNonAlphanumericFilter::class,
7171
RemoveNonAlphabeticFilter::class,
7272
RemoveNonAsciiAndControlCharactersFilter::class,

0 commit comments

Comments
 (0)