Skip to content

Commit 3613516

Browse files
PedroTrollerJoris Makjorismak
authored
Release (#211)
* refactor: apply new coding standards * fix compatibility with 3.59.3 * fix compatibility with 3.59.3 (#210) Co-authored-by: Joris Mak <j.mak@nobears.nl> * refactor: apply new coding standards --------- Co-authored-by: Joris Mak <j.mak@nobears.nl> Co-authored-by: Joris Mak <47725838+jorismak@users.noreply.github.com>
1 parent a0c9d6d commit 3613516

24 files changed

+96
-65
lines changed

.circleci/config.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,29 @@ workflows:
106106
- documentation:
107107
matrix:
108108
parameters:
109-
php-version: ["8.2"]
109+
php-version:
110+
- "8.3"
110111
- tests:
111112
matrix:
112113
parameters:
113-
php-version: ["8.0", "8.1", "8.2"]
114+
php-version:
115+
- "8.1"
116+
- "8.2"
117+
- "8.3"
114118
- tests-with-future-mode:
115119
matrix:
116120
parameters:
117-
php-version: ["8.0", "8.1", "8.2"]
121+
php-version:
122+
- "8.1"
123+
- "8.2"
124+
- "8.3"
118125
- tests-with-lowest-dependencies:
119126
matrix:
120127
parameters:
121-
php-version: ["8.0", "8.1", "8.2"]
128+
php-version:
129+
- "8.1"
130+
- "8.2"
131+
- "8.3"
122132
- release-test
123133
- release:
124134
requires:

.php-cs-fixer.dist.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
use PedroTroller\CS\Fixer\Fixers;
66
use PedroTroller\CS\Fixer\RuleSetFactory;
7+
use PhpCsFixer\Config;
8+
use PhpCsFixer\Finder;
79

8-
return (new PhpCsFixer\Config())
10+
return (new Config())
911
->setRiskyAllowed(true)
1012
->setRules(
1113
RuleSetFactory::create()
1214
->per(2, true)
1315
->phpCsFixer(true)
14-
->php(8.0, true)
16+
->php(8.1, true)
1517
->pedrotroller(true)
1618
->enable('align_multiline_comment')
1719
->enable('array_indentation')
@@ -34,7 +36,7 @@
3436
->setUsingCache(false)
3537
->registerCustomFixers(new Fixers())
3638
->setFinder(
37-
PhpCsFixer\Finder::create()
39+
Finder::create()
3840
->in(__DIR__)
3941
->append([__FILE__, __DIR__.'/bin/doc'])
4042
)

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,12 @@ Prohibited functions MUST BE commented on as prohibited
384384

385385
### Available options
386386

387-
- `functions` (*optional*): The function names to be marked how prohibited
388-
- default: `var_dump`, `dump`, `die`
389-
390387
- `comment` (*optional*): The prohibition message to put in the comment
391388
- default: `@TODO remove this line`
392389

390+
- `functions` (*optional*): The function names to be marked how prohibited
391+
- default: `var_dump`, `dump`, `die`
392+
393393
### Configuration examples
394394

395395
```php
@@ -511,18 +511,18 @@ If the declaration of a method is too long, the arguments of this method MUST BE
511511

512512
### Available options
513513

514-
- `max-args` (*optional*): The maximum number of arguments allowed with splitting the arguments into several lines (use `false` to disable this feature)
515-
- default: `3`
516-
517-
- `max-length` (*optional*): The maximum number of characters allowed with splitting the arguments into several lines
518-
- default: `120`
519-
520514
- `automatic-argument-merge` (*optional*): If both conditions are met (the line is not too long and there are not too many arguments), then the arguments are put back inline
521515
- default: `true`
522516

523517
- `inline-attributes` (*optional*): In the case of a split, the declaration of the attributes of the arguments of the method will be on the same line as the arguments themselves
524518
- default: `false`
525519

520+
- `max-args` (*optional*): The maximum number of arguments allowed with splitting the arguments into several lines (use `false` to disable this feature)
521+
- default: `3`
522+
523+
- `max-length` (*optional*): The maximum number of characters allowed with splitting the arguments into several lines
524+
- default: `120`
525+
526526
### Configuration examples
527527

528528
```php

bin/Utils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
final class Utils
66
{
7-
public static function arrayToString(array $array = null)
7+
public static function arrayToString(?array $array = null)
88
{
99
if (null === $array) {
1010
return;

bin/doc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/usr/bin/env php
22
<?php
33

4+
declare(strict_types=1);
5+
46
use PedroTroller\CS\Fixer\AbstractFixer;
7+
use PedroTroller\CS\Fixer\Fixers;
58
use PhpCsFixer\Fixer\ConfigurableFixerInterface;
69
use PhpCsFixer\FixerConfiguration\FixerOptionInterface;
710
use PhpCsFixer\FixerDefinition\CodeSample;
@@ -80,7 +83,7 @@ $fixers = array_map(static function (AbstractFixer $fixer) {
8083
];
8184
}, $samples),
8285
];
83-
}, iterator_to_array(new PedroTroller\CS\Fixer\Fixers()));
86+
}, [...(new Fixers())]);
8487

8588
$loader = new FilesystemLoader([__DIR__]);
8689
$twig = new Environment($loader);

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
"description": "PHP-CS-FIXER : my custom fixers",
44
"license": "MIT",
55
"require": {
6-
"php": "^8.0"
6+
"php": "^8.1",
7+
"friendsofphp/php-cs-fixer": ">=3.59.3"
78
},
89
"require-dev": {
9-
"friendsofphp/php-cs-fixer": "^3.28",
10+
"friendsofphp/php-cs-fixer": "^3.60",
1011
"phpspec/phpspec": "^7.0",
1112
"sebastian/diff": "^4.0",
1213
"twig/twig": "^3.3",
1314
"webmozart/assert": "^1.10"
1415
},
16+
"minimum-stability": "dev",
17+
"prefer-stable": true,
1518
"autoload": {
1619
"psr-4": {
1720
"PedroTroller\\CS\\Fixer\\": "src/PedroTroller/CS/Fixer"
@@ -31,19 +34,17 @@
3134
"dev-master": "3.x-dev"
3235
}
3336
},
34-
"minimum-stability": "dev",
35-
"prefer-stable": true,
3637
"scripts": {
37-
"tests": [
38-
"tests\\Runner::run",
39-
"tests\\Orchestra::run",
40-
"phpspec run -fpretty"
38+
"lint": [
39+
"@php-cs-fixer"
4140
],
4241
"php-cs-fixer": [
4342
"php-cs-fixer fix --dry-run -vvv --diff"
4443
],
45-
"lint": [
46-
"@php-cs-fixer"
44+
"tests": [
45+
"tests\\Runner::run",
46+
"tests\\Orchestra::run",
47+
"phpspec run -fpretty"
4748
]
4849
}
4950
}

src/PedroTroller/CS/Fixer/AbstractFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function isCandidate(Tokens $tokens): bool
2323

2424
public function getName(): string
2525
{
26-
return sprintf('PedroTroller/%s', parent::getName());
26+
return \sprintf('PedroTroller/%s', parent::getName());
2727
}
2828

2929
/**
@@ -45,7 +45,7 @@ public function getDefinition(): FixerDefinitionInterface
4545
return new FixerDefinition(
4646
$this->getDocumentation(),
4747
array_map(
48-
fn (array $configutation = null) => new CodeSample($this->getSampleCode(), $configutation),
48+
fn (?array $configutation = null) => new CodeSample($this->getSampleCode(), $configutation),
4949
$this->getSampleConfigurations()
5050
)
5151
);

src/PedroTroller/CS/Fixer/Behat/OrderBehatStepsFixer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
use PedroTroller\CS\Fixer\Priority;
99
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
1010
use PhpCsFixer\Fixer\ConfigurableFixerInterface;
11+
use PhpCsFixer\Fixer\ConfigurableFixerTrait;
1112
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
1213
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1314
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
1415
use PhpCsFixer\Tokenizer\Tokens;
1516

1617
final class OrderBehatStepsFixer extends AbstractOrderedClassElementsFixer implements ConfigurableFixerInterface
1718
{
19+
use ConfigurableFixerTrait;
20+
1821
public const ANNOTATION_PRIORITIES = [
1922
'@BeforeSuite',
2023
'@AfterSuite',
@@ -126,7 +129,7 @@ public function getDocumentation(): string
126129
return 'Step definition methods in Behat contexts MUST BE ordered by annotation and method name.';
127130
}
128131

129-
public function getConfigurationDefinition(): FixerConfigurationResolverInterface
132+
public function createConfigurationDefinition(): FixerConfigurationResolverInterface
130133
{
131134
return new FixerConfigurationResolver([
132135
(new FixerOptionBuilder('instanceof', 'Parent class or interface of your behat context classes.'))

src/PedroTroller/CS/Fixer/ClassNotation/OrderedWithGetterAndSetterFirstFixer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ private function getMethodsNames(array $elements): array
152152
$methods = [];
153153

154154
foreach ($this->getPropertiesNames($elements) as $name) {
155-
$methods[] = sprintf('get%s', ucfirst($name));
156-
$methods[] = sprintf('is%s', ucfirst($name));
157-
$methods[] = sprintf('has%s', ucfirst($name));
155+
$methods[] = \sprintf('get%s', ucfirst($name));
156+
$methods[] = \sprintf('is%s', ucfirst($name));
157+
$methods[] = \sprintf('has%s', ucfirst($name));
158158
$methods[] = lcfirst($name);
159-
$methods[] = sprintf('set%s', ucfirst($name));
159+
$methods[] = \sprintf('set%s', ucfirst($name));
160160
}
161161

162162
return $methods;

src/PedroTroller/CS/Fixer/CodingStyle/ExceptionsPunctuationFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,6 @@ private function cleanupMessage(Token $token): Token
152152
return $token;
153153
}
154154

155-
return new Token([T_CONSTANT_ENCAPSED_STRING, sprintf('%s%s.%s', $quotes, implode('', $chars), $quotes)]);
155+
return new Token([T_CONSTANT_ENCAPSED_STRING, \sprintf('%s%s.%s', $quotes, implode('', $chars), $quotes)]);
156156
}
157157
}

0 commit comments

Comments
 (0)