Skip to content

Commit 96b368b

Browse files
committed
Upgrade bundled php-cs-fixer.phar to 3.92.5
1 parent 08192e1 commit 96b368b

10 files changed

Lines changed: 50 additions & 14 deletions

File tree

CONTRIBUTING.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,48 @@ composer update
3232
composer update --working-dir=tools/phpstan
3333
composer update --working-dir=tools/phpstan/includes
3434
```
35-
3635
Run PHPStan with:
3736

3837
```bash
3938
tools/phpstan/vendor/bin/phpstan
4039
```
40+
41+
## Style Checking
42+
43+
This project uses [PHP CS Fixer](https://cs.symfony.com/) to ensure code style consistency.
44+
45+
Install the required dependencies with:
46+
47+
```bash
48+
composer update --working-dir=tools/php-cs-fixer
49+
```
50+
51+
To fix the code style, run:
52+
53+
```bash
54+
tools/php-cs-fixer/vendor/bin/php-cs-fixer fix
55+
```
56+
57+
## Bundled PHP CS Fixer
58+
59+
The PHP-CS-Fixer package is bundled with this project and used by some makers.
60+
61+
To update the Phar file to the latest version, run:
62+
63+
```bash
64+
curl -fsSLo src/Resources/bin/php-cs-fixer.phar https://cs.symfony.com/download/php-cs-fixer-v3.phar
65+
chmod a+x src/Resources/bin/php-cs-fixer.phar
66+
```
67+
68+
Get the version of the downloaded Phar file:
69+
70+
```bash
71+
php src/Resources/bin/php-cs-fixer.phar --version
72+
```
73+
74+
Update the `BUNDLED_PHP_CS_FIXER_VERSION` constant in `src/Util/TemplateLinter.php`:
75+
76+
```diff
77+
- public const BUNDLED_PHP_CS_FIXER_VERSION = '3.49.0';
78+
+ public const BUNDLED_PHP_CS_FIXER_VERSION = '3.92.5';
79+
```
2.69 MB
Binary file not shown.

src/Util/TemplateLinter.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
*/
2626
final class TemplateLinter
2727
{
28-
// Version must match bundled version file name. e.g. php-cs-fixer-v3.49.9.phar
29-
public const BUNDLED_PHP_CS_FIXER_VERSION = '3.49.0';
28+
public const BUNDLED_PHP_CS_FIXER_VERSION = '3.92.5';
3029

3130
private bool $usingBundledPhpCsFixer = true;
3231
private bool $usingBundledPhpCsFixerConfig = true;
@@ -100,7 +99,7 @@ private function setBinary(): void
10099
{
101100
// Use Bundled PHP-CS-Fixer
102101
if (null === $this->phpCsFixerBinaryPath) {
103-
$this->phpCsFixerBinaryPath = \sprintf('%s/Resources/bin/php-cs-fixer-v%s.phar', \dirname(__DIR__), self::BUNDLED_PHP_CS_FIXER_VERSION);
102+
$this->phpCsFixerBinaryPath = \sprintf('%s/Resources/bin/php-cs-fixer.phar', \dirname(__DIR__));
104103

105104
return;
106105
}

templates/serializer/Normalizer.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class <?= $class_name ?> implements NormalizerInterface
88
{
99
public function __construct(
1010
#[Autowire(service: 'serializer.normalizer.object')]
11-
private NormalizerInterface $normalizer
11+
private NormalizerInterface $normalizer,
1212
) {
1313
}
1414

templates/validator/Constraint.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
public function __construct(
1616
public string $mode = 'strict',
1717
?array $groups = null,
18-
mixed $payload = null
18+
mixed $payload = null,
1919
) {
2020
parent::__construct([], $groups, $payload);
2121
}

tests/Util/TemplateLinterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ public function testPhpCsFixerVersion(): void
4242
{
4343
$this->markTestSkippedOnWindows();
4444

45-
$fixerPath = \sprintf('%s/src/Resources/bin/php-cs-fixer-v%s.phar', \dirname(__DIR__, 2), TemplateLinter::BUNDLED_PHP_CS_FIXER_VERSION);
45+
$fixerPath = \sprintf('%s/src/Resources/bin/php-cs-fixer.phar', \dirname(__DIR__, 2));
4646

47-
$process = Process::fromShellCommandline(\sprintf('%s -V', $fixerPath));
47+
$process = Process::fromShellCommandline(\sprintf('PHP_CS_FIXER_IGNORE_ENV=1 %s -V', $fixerPath));
4848

4949
$process->run();
5050

tests/fixtures/make-serializer-normalizer/EntityFixtureNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class EntityFixtureNormalizer implements NormalizerInterface
1010
{
1111
public function __construct(
1212
#[Autowire(service: 'serializer.normalizer.object')]
13-
private NormalizerInterface $normalizer
13+
private NormalizerInterface $normalizer,
1414
) {
1515
}
1616

tests/fixtures/make-serializer-normalizer/FooBarNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class FooBarNormalizer implements NormalizerInterface
99
{
1010
public function __construct(
1111
#[Autowire(service: 'serializer.normalizer.object')]
12-
private NormalizerInterface $normalizer
12+
private NormalizerInterface $normalizer,
1313
) {
1414
}
1515

tests/fixtures/make-validator/expected/FooBar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ final class FooBar extends Constraint
1414
public function __construct(
1515
public string $mode = 'strict',
1616
?array $groups = null,
17-
mixed $payload = null
17+
mixed $payload = null,
1818
) {
1919
parent::__construct([], $groups, $payload);
2020
}

tools/php-cs-fixer/composer.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"require": {
3-
"friendsofphp/php-cs-fixer": "^3.75"
3+
"friendsofphp/php-cs-fixer": "^3.92"
44
}
55
}
6-
7-

0 commit comments

Comments
 (0)