Skip to content

Commit a237bff

Browse files
committed
upgrade to php 8.1 and fix dry run
1 parent d672c4c commit a237bff

File tree

13 files changed

+235
-171
lines changed

13 files changed

+235
-171
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
matrix:
1717
operating-system: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
18-
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
18+
php-versions: [ '8.1', '8.2', '8.3', '8.4', '8.5' ]
1919
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
2020
steps:
2121
- name: Checkout

.php-cs-fixer.dist.php

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,54 @@
2121
'header' => $header,
2222
'comment_type' => 'PHPDoc',
2323
'location' => 'after_open',
24-
'separate' => 'bottom'
24+
'separate' => 'bottom',
2525
],
26-
'@PHP74Migration' => true,
27-
'@PHP74Migration:risky' => true,
28-
'@Symfony' => true,
29-
'@Symfony:risky' => true,
30-
'concat_space' => [
31-
'spacing' => 'one',
32-
],
33-
'array_indentation' => true,
26+
27+
// Migration Rules
28+
'@PHP8x1Migration' => true,
29+
'@PHP8x1Migration:risky' => true,
30+
'@PHPUnit10x0Migration:risky' => true,
31+
32+
// Doctrine Rules
33+
'@DoctrineAnnotation' => true,
34+
35+
// In no presets
36+
'attribute_empty_parentheses' => true,
37+
'heredoc_closing_marker' => true,
38+
'multiline_string_to_heredoc' => true,
39+
'numeric_literal_separator' => true,
40+
'ordered_attributes' => true,
41+
'php_unit_attributes' => true,
42+
'return_to_yield_from' => true,
43+
'phpdoc_tag_casing' => true,
44+
'phpdoc_param_order' => true,
45+
'mb_str_functions' => true,
46+
'date_time_immutable' => true,
47+
'ordered_interfaces' => true,
3448
'general_phpdoc_annotation_remove' => [
35-
'annotations' => [
36-
'expectedDeprecation'
37-
]
49+
'annotations' => ['expectedDeprecation'],
3850
],
39-
'use_arrow_functions' => true,
40-
'control_structure_braces' => true,
41-
'control_structure_continuation_position' => true,
42-
'self_static_accessor' => true,
43-
'ordered_interfaces' => true,
44-
'phpdoc_var_annotation_correct_order' => true,
45-
'return_assignment' => true,
46-
'no_useless_else' => true,
47-
'no_superfluous_elseif' => true,
48-
'no_useless_return' => true,
49-
'multiline_comment_opening_closing' => true,
50-
'no_null_property_initialization' => true,
51-
'operator_linebreak' => true,
52-
'method_chaining_indentation' => true,
53-
'strict_param' => true,
54-
'strict_comparison' => true,
51+
'phpdoc_array_type' => true,
52+
'phpdoc_list_type' => true,
53+
'general_attribute_remove' => true,
54+
'multiline_promoted_properties' => true,
55+
'new_expression_parentheses' => true,
56+
'no_useless_printf' => true,
57+
58+
// PER-CS3.0 Rules
59+
'@PER-CS3x0:risky' => true,
60+
61+
// PHP-CS-Fixer Rules
62+
'@PhpCsFixer' => true,
63+
'@PhpCsFixer:risky' => true,
64+
65+
// Symfony Rules
66+
'@Symfony' => true,
67+
'@Symfony:risky' => true,
68+
'concat_space' => ['spacing' => 'one'],
69+
70+
// Disable rule causing issues
71+
'multiline_whitespace_before_semicolons' => true,
5572
])
5673
->setFinder($finder)
5774
->setLineEnding(PHP_EOL);

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717

1818
| Version | PHP | Documentation |
1919
|---------|------|---------------|
20-
| ^2.1 | ^7.4 | current |
20+
| ^3.0 | ^8.1 | current |
2121

2222
### Requirements
2323

24-
- `PHP` >= 7.4
2524
- php-extension `ext-mbstring`
2625

2726
### Installation

composer.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
],
1818
"homepage": "https://github.com/mathiasreker/php-chmod",
1919
"require": {
20-
"php": ">=7.4",
20+
"php": "^8.1",
2121
"ext-mbstring": "*",
22-
"symfony/finder": "^4.4 || ^5.4 || ^6.4 || ^7.0"
22+
"symfony/finder": "^6.4 || ^7.1 || ^8.0"
2323
},
2424
"require-dev": {
25-
"ergebnis/composer-normalize": "^2.28",
26-
"friendsofphp/php-cs-fixer": "^3.45",
27-
"phpstan/phpstan": "^1.10 || ^2.0",
28-
"phpunit/phpunit": "^9.6"
25+
"ergebnis/composer-normalize": "^2.48",
26+
"friendsofphp/php-cs-fixer": "^3.91",
27+
"phpstan/phpstan": "^2.1",
28+
"phpunit/phpunit": "^10.5",
29+
"rector/rector": "^2.2"
2930
},
3031
"autoload": {
3132
"psr-4": {
@@ -48,6 +49,7 @@
4849
"cs-check": "./vendor/bin/php-cs-fixer fix . --dry-run --diff",
4950
"cs-fix": "./vendor/bin/php-cs-fixer fix .",
5051
"phpstan": "./vendor/bin/phpstan analyse src/ --level=9",
52+
"rector": "./vendor/bin/rector process",
5153
"test": "./vendor/bin/phpunit --bootstrap vendor/autoload.php --colors=always tests/"
5254
}
5355
}

rector.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the php-chmod package.
5+
* (c) Mathias Reker <github@reker.dk>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
declare(strict_types=1);
11+
12+
use Rector\Config\RectorConfig;
13+
use Rector\Php84\Rector\Param\ExplicitNullableParamTypeRector;
14+
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
15+
16+
return RectorConfig::configure()
17+
->withPhpSets(php81: true)
18+
->withIndent()
19+
->withPreparedSets(
20+
deadCode: true,
21+
codeQuality: true,
22+
codingStyle: true,
23+
typeDeclarations: true,
24+
privatization: true,
25+
naming: true,
26+
instanceOf: true,
27+
earlyReturn: true,
28+
rectorPreset: true,
29+
phpunitCodeQuality: true,
30+
symfonyCodeQuality: true,
31+
)
32+
->withAttributesSets()
33+
->withSkipPath(__DIR__ . '/vendor')
34+
->withPaths([__DIR__])
35+
->withoutParallel()
36+
->withSkip(
37+
[
38+
PreferPHPUnitThisCallRector::class,
39+
]
40+
)
41+
->withRules(
42+
[
43+
ExplicitNullableParamTypeRector::class,
44+
]
45+
);

src/Exception/InvalidArgumentException.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of the php-chmod package.
45
* (c) Mathias Reker <github@reker.dk>

src/Model/Scanner.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of the php-chmod package.
45
* (c) Mathias Reker <github@reker.dk>
@@ -19,48 +20,48 @@ final class Scanner
1920
*/
2021
private const INVALID_PERMISSION = 'Invalid permission.';
2122

22-
private int $defaultFileMode = 0644;
23+
private int $defaultFileMode = 0o644;
2324

24-
private int $defaultDirectoryMode = 0755;
25+
private int $defaultDirectoryMode = 0o755;
2526

2627
private bool $isExcludedFiles = false;
2728

2829
private bool $isExcludedDirectories = false;
2930

3031
/**
31-
* @var string[]
32+
* @var list<string>
3233
*/
3334
private array $excludedPaths = [];
3435

3536
/**
36-
* @var int[]
37+
* @var list<int>
3738
*/
3839
private array $excludedFileModes = [];
3940

4041
/**
41-
* @var int[]
42+
* @var list<int>
4243
*/
4344
private array $excludedDirectoryModes = [];
4445

4546
/**
46-
* @var string[]
47+
* @var list<string>
4748
*/
4849
private array $paths = [];
4950

5051
/**
51-
* @var string[]
52+
* @var list<string>
5253
*/
5354
private array $excludedNames = [];
5455

5556
/**
56-
* @var string[]
57+
* @var list<string>
5758
*/
5859
private array $names = [];
5960

6061
/**
6162
* Get excluded permissions for files.
6263
*
63-
* @return int[]
64+
* @return list<int>
6465
*/
6566
public function getExcludedFileModes(): array
6667
{
@@ -70,7 +71,7 @@ public function getExcludedFileModes(): array
7071
/**
7172
* Set excluded permissions for files.
7273
*
73-
* @param int[] $excludedFileModes
74+
* @param list<int> $excludedFileModes
7475
*/
7576
public function setExcludedFileModes(array $excludedFileModes): self
7677
{
@@ -96,7 +97,7 @@ private function isValidMode(int $mode): bool
9697
/**
9798
* Get excluded permissions for directories.
9899
*
99-
* @return int[]
100+
* @return list<int>
100101
*/
101102
public function getExcludedDirectoryModes(): array
102103
{
@@ -106,7 +107,7 @@ public function getExcludedDirectoryModes(): array
106107
/**
107108
* Set excluded permissions for directories.
108109
*
109-
* @param int[] $excludedDirectoryModes
110+
* @param list<int> $excludedDirectoryModes
110111
*/
111112
public function setExcludedDirectoryModes(array $excludedDirectoryModes): self
112113
{
@@ -124,7 +125,7 @@ public function setExcludedDirectoryModes(array $excludedDirectoryModes): self
124125
/**
125126
* Get paths matching the search pattern.
126127
*
127-
* @return string[]
128+
* @return list<string>
128129
*/
129130
public function getPaths(): array
130131
{
@@ -134,7 +135,7 @@ public function getPaths(): array
134135
/**
135136
* Set paths.
136137
*
137-
* @param string[] $paths
138+
* @param list<string> $paths
138139
*/
139140
public function setPaths(array $paths): self
140141
{
@@ -146,7 +147,7 @@ public function setPaths(array $paths): self
146147
/**
147148
* Get names that directories/files must not match.
148149
*
149-
* @return string[]
150+
* @return list<string>
150151
*/
151152
public function getExcludedNames(): array
152153
{
@@ -156,7 +157,7 @@ public function getExcludedNames(): array
156157
/**
157158
* Get names that directories/files must match.
158159
*
159-
* @return string[]
160+
* @return list<string>
160161
*/
161162
public function getNames(): array
162163
{
@@ -166,7 +167,7 @@ public function getNames(): array
166167
/**
167168
* Set names the directories/files must match.
168169
*
169-
* @param string[] $names
170+
* @param list<string> $names
170171
*/
171172
public function setNames(array $names): self
172173
{
@@ -178,7 +179,7 @@ public function setNames(array $names): self
178179
/**
179180
* Get paths that directories/files must not match.
180181
*
181-
* @return string[]
182+
* @return list<string>
182183
*/
183184
public function getExcludedPaths(): array
184185
{
@@ -188,7 +189,7 @@ public function getExcludedPaths(): array
188189
/**
189190
* Set excluded paths.
190191
*
191-
* @param string[] $excludedPaths
192+
* @param list<string> $excludedPaths
192193
*/
193194
public function setExcludedPaths(array $excludedPaths): self
194195
{
@@ -200,7 +201,7 @@ public function setExcludedPaths(array $excludedPaths): self
200201
/**
201202
* Set names that directories/files must match.
202203
*
203-
* @param string[] $excludedNames
204+
* @param list<string> $excludedNames
204205
*/
205206
public function setExcludeNames(array $excludedNames): self
206207
{

src/Scanner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* This file is part of the php-chmod package.
45
* (c) Mathias Reker <github@reker.dk>

0 commit comments

Comments
 (0)