forked from PHP-CS-Fixer/PHP-CS-Fixer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.php-cs-fixer.php-lowest.php
More file actions
60 lines (49 loc) · 1.94 KB
/
.php-cs-fixer.php-lowest.php
File metadata and controls
60 lines (49 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
/*
* This file is part of PHP CS Fixer.
*
* (c) Fabien Potencier <fabien@symfony.com>
* Dariusz Rumiński <dariusz.ruminski@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
use PhpCsFixer\Config;
use PhpCsFixer\Future;
if (\PHP_VERSION_ID < 7_04_00 || \PHP_VERSION_ID >= 7_05_00) {
fwrite(\STDERR, "PHP CS Fixer's config for PHP-LOWEST can be executed only on lowest supported PHP version - ~7.4.0.\n");
fwrite(\STDERR, "Running it on higher PHP version would falsy expect more changes, eg `mixed` type on PHP 8.\n");
exit(1);
}
$config = require __DIR__.'/.php-cs-fixer.dist.php';
Closure::bind(
static function (Config $config): void { $config->name = 'PHP-LOWEST'.(Future::isFutureModeEnabled() ? ' (future mode)' : ''); },
null,
Config::class,
)($config);
$config->getFinder()->notPath([
// @TODO 4.0 change interface to be fully typehinted and remove the exceptions from this list
'src/DocBlock/Annotation.php',
'src/Doctrine/Annotation/Tokens.php',
'src/Tokenizer/Tokens.php',
// @TODO add `mixed` return type to `ExecutorWithoutErrorHandler::execute` when PHP 8.0+ is required and remove the exception from this list
'src/ExecutorWithoutErrorHandler.php',
]);
$typesMap = [
'T' => 'mixed',
'TFixerInputConfig' => 'array',
'TFixerComputedConfig' => 'array',
'TFixer' => '\PhpCsFixer\AbstractFixer',
'_PhpTokenKind' => 'int|string',
'_PhpTokenArray' => 'array{0: int, 1: string}',
'_PhpTokenArrayPartial' => 'array{0: int, 1?: string}',
'_PhpTokenPrototype' => '_PhpTokenArray|string',
'_PhpTokenPrototypePartial' => '_PhpTokenArrayPartial|string',
];
$config->setRules([
'phpdoc_to_param_type' => ['types_map' => $typesMap],
'phpdoc_to_return_type' => ['types_map' => $typesMap],
'phpdoc_to_property_type' => ['types_map' => $typesMap],
]);
return $config;