Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
127 lines (112 loc) · 4.93 KB

File metadata and controls

127 lines (112 loc) · 4.93 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
if (!file_exists(__DIR__.'/src')) {
exit(0);
}
$fileHeaderParts = [
<<<'EOF'
This file is part of the Symfony package.
(c) Fabien Potencier <fabien@symfony.com>
EOF,
<<<'EOF'
For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
EOF,
];
return (new PhpCsFixer\Config())
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
->setRules([
'@PHP8x1Migration' => true, // take lowest version from `git grep -h '"php"' **/composer.json | uniq | sort`
'@PHP8x1Migration:risky' => true,
'@PHPUnit9x1Migration:risky' => true, // take version from src/Symfony/Bridge/PhpUnit/phpunit.xml.dist#L4
'@Symfony' => true,
'@Symfony:risky' => true,
'header_comment' => [
'header' => implode('', $fileHeaderParts),
'validator' => implode('', [
'/',
preg_quote($fileHeaderParts[0], '/'),
'(?P<EXTRA>.*)??',
preg_quote($fileHeaderParts[1], '/'),
'/s',
]),
],
'modern_serialization_methods' => false,
'php_unit_attributes' => true,
])
->setRuleCustomisationPolicy(new class implements PhpCsFixer\Config\RuleCustomisationPolicyInterface {
public function getPolicyVersionForCache(): string
{
return hash_file('xxh128', __FILE__);
}
public function getRuleCustomisers(): array
{
return [
'php_unit_attributes' => static function (SplFileInfo $file) {
// temporary hack due to bug: https://github.com/symfony/symfony/issues/62734
if (!$file instanceof Symfony\Component\Finder\SplFileInfo) {
return false;
}
$relativePathname = $file->getRelativePathname();
// For packages/namespaces that are part of public API and
// as such are not bound to any specific PHPUnit version,
// we have to keep both annotations and attributes.
if (
str_starts_with($relativePathname, 'Symfony/Bridge/PhpUnit/')
|| str_starts_with($relativePathname, 'Symfony/Contracts/')
|| str_contains($relativePathname, '/Test/') // public namespace, do not mistake it with `/Tests/`
) {
$fixer = new PhpCsFixer\Fixer\PhpUnit\PhpUnitAttributesFixer();
$fixer->configure(['keep_annotations' => true]);
return $fixer;
}
// Keep the default configuration for other files
return true;
},
'void_return' => static function (SplFileInfo $file) {
// temporary hack due to bug: https://github.com/symfony/symfony/issues/62734
if (!$file instanceof Symfony\Component\Finder\SplFileInfo) {
return false;
}
$relativePathname = $file->getRelativePathname();
if (
str_contains($relativePathname, '/Tests/') // don't touch test files, as massive change with little benefit - as outside of public contract anyway
|| str_contains($relativePathname, '/Test/') // public namespace not following the rule, do not mistake it with `/Tests/`
|| str_starts_with($relativePathname, 'Symfony/Contracts/') // rule not yet followed in current MAJOR
) {
return false;
}
return true;
},
];
}
})
->setRiskyAllowed(true)
->setFinder(
(new PhpCsFixer\Finder())
->in(__DIR__.'/src')
->append([__FILE__])
->notPath('#/Fixtures/#')
->exclude([
'Symfony/Component/Emoji/Resources/',
'Symfony/Component/Intl/Resources/data/',
'Symfony/Component/String/Resources/data/',
])
// Support for older PHPunit version
->notPath('#Symfony/Bridge/PhpUnit/.*Mock\.php#')
->notPath('#Symfony/Bridge/PhpUnit/.*Legacy#')
// auto-generated proxies
->notPath('#Symfony/Component/Cache/Traits/Re.*Proxy\.php#')
// svg
->notPath('Symfony/Component/ErrorHandler/Resources/assets/images/symfony-ghost.svg.php')
// HTML templates
->notPath('#Symfony/.*\.html\.php#')
)
;
Morty Proxy This is a proxified and sanitized view of the page, visit original site.