Skip to content

Commit f2cd330

Browse files
committed
minor #5008 Enhancement: Social justification applied (gbyrka-fingo)
This PR was squashed before being merged into the 2.15 branch. Discussion ---------- Enhancement: Social justification applied The time has come to rename functionalities that for some might sound racist. Once this is approved I'll rename annotation-black-list and annotation-white-list in the master branch. Commits ------- 9c4120b Enhancement: Social justification applied
2 parents c0d6a34 + 9c4120b commit f2cd330

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

README.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ apply (the rule names must be separated by a comma):
193193
194194
$ php php-cs-fixer.phar fix /path/to/dir --rules=line_ending,full_opening_tag,indentation_type
195195
196-
You can also blacklist the rules you don't want by placing a dash in front of the rule name, if this is more convenient,
196+
You can also exclude the rules you don't want by placing a dash in front of the rule name, if this is more convenient,
197197
using ``-name_of_fixer``:
198198

199199
.. code-block:: bash
200200
201201
$ php php-cs-fixer.phar fix /path/to/dir --rules=-full_opening_tag,-indentation_type
202202
203-
When using combinations of exact and blacklist rules, applying exact rules along with above blacklisted results:
203+
When using combinations of exact and exclude rules, applying exact rules along with above excluded results:
204204

205205
.. code-block:: bash
206206
@@ -677,8 +677,8 @@ Choose from the list of available rules:
677677
Configuration options:
678678

679679
- ``annotation-black-list`` (``array``): class level annotations tags that must be
680-
omitted to fix the class, even if all of the white list ones are used
681-
as well. (case insensitive); defaults to ``['@final', '@Entity',
680+
omitted to fix the class, even if all of the excluded ones are used as
681+
well. (case insensitive); defaults to ``['@final', '@Entity',
682682
'@ORM\\Entity', '@ORM\\Mapping\\Entity', '@Mapping\\Entity']``
683683
- ``annotation-white-list`` (``array``): class level annotations tags that must be
684684
set in order to fix the class. (case insensitive); defaults to
@@ -1972,7 +1972,7 @@ Both ``exclude`` and ``notPath`` methods accept only relative paths to the ones
19721972
See `Symfony\\Finder <https://symfony.com/doc/current/components/finder.html>`_
19731973
online documentation for other `Finder` methods.
19741974

1975-
You may also use a blacklist for the rules instead of the above shown whitelist approach.
1975+
You may also use an exclude list for the rules instead of the above shown include approach.
19761976
The following example shows how to use all ``Symfony`` rules but the ``full_opening_tag`` rule.
19771977

19781978
.. code-block:: php

src/Console/Command/HelpCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ public static function getHelpCopy()
9494
9595
<info>$ php %command.full_name% /path/to/dir --rules=line_ending,full_opening_tag,indentation_type</info>
9696
97-
You can also blacklist the rules you don't want by placing a dash in front of the rule name, if this is more convenient,
97+
You can also exclude the rules you don't want by placing a dash in front of the rule name, if this is more convenient,
9898
using <comment>-name_of_fixer</comment>:
9999
100100
<info>$ php %command.full_name% /path/to/dir --rules=-full_opening_tag,-indentation_type</info>
101101
102-
When using combinations of exact and blacklist rules, applying exact rules along with above blacklisted results:
102+
When using combinations of exact and exclude rules, applying exact rules along with above excluded results:
103103
104104
<info>$ php %command.full_name% /path/to/project --rules=@Symfony,-@PSR1,-blank_line_before_statement,strict_comparison</info>
105105
@@ -203,7 +203,7 @@ public static function getHelpCopy()
203203
See `Symfony\Finder` (<url>https://symfony.com/doc/current/components/finder.html</url>)
204204
online documentation for other `Finder` methods.
205205
206-
You may also use a blacklist for the rules instead of the above shown whitelist approach.
206+
You may also use an exclude list for the rules instead of the above shown include approach.
207207
The following example shows how to use all ``Symfony`` rules but the ``full_opening_tag`` rule.
208208
209209
<?php

src/Fixer/ClassNotation/FinalInternalClassFixer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function configure(array $configuration = null)
4444
);
4545

4646
if (\count($intersect)) {
47-
throw new InvalidFixerConfigurationException($this->getName(), sprintf('Annotation cannot be used in both the white- and black list, got duplicates: "%s".', implode('", "', array_keys($intersect))));
47+
throw new InvalidFixerConfigurationException($this->getName(), sprintf('Annotation cannot be used in both the include and exclude list, got duplicates: "%s".', implode('", "', array_keys($intersect))));
4848
}
4949
}
5050

@@ -152,7 +152,7 @@ protected function createConfigurationDefinition()
152152
->setDefault(['@internal'])
153153
->setNormalizer($annotationsNormalizer)
154154
->getOption(),
155-
(new FixerOptionBuilder('annotation-black-list', 'Class level annotations tags that must be omitted to fix the class, even if all of the white list ones are used as well. (case insensitive)'))
155+
(new FixerOptionBuilder('annotation-black-list', 'Class level annotations tags that must be omitted to fix the class, even if all of the excluded ones are used as well. (case insensitive)'))
156156
->setAllowedTypes(['array'])
157157
->setAllowedValues($annotationsAsserts)
158158
->setDefault([
@@ -196,7 +196,7 @@ private function isClassCandidate(Tokens $tokens, $index)
196196
$tag = strtolower(substr(array_shift($matches), 1));
197197
foreach ($this->configuration['annotation-black-list'] as $tagStart => $true) {
198198
if (0 === strpos($tag, $tagStart)) {
199-
return false; // ignore class: class-level PHPDoc contains tag that has been black listed through configuration
199+
return false; // ignore class: class-level PHPDoc contains tag that has been excluded through configuration
200200
}
201201
}
202202

@@ -205,7 +205,7 @@ private function isClassCandidate(Tokens $tokens, $index)
205205

206206
foreach ($this->configuration['annotation-white-list'] as $tag => $true) {
207207
if (!isset($tags[$tag])) {
208-
return false; // ignore class: class-level PHPDoc does not contain all tags that has been white listed through configuration
208+
return false; // ignore class: class-level PHPDoc does not contain all tags that has been included through configuration
209209
}
210210
}
211211

src/Fixer/ControlStructure/NoUnneededCurlyBracesFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ private function findCurlyBraceOpen(Tokens $tokens)
131131
*/
132132
private function isOverComplete(Tokens $tokens, $index)
133133
{
134-
static $whiteList = ['{', '}', [T_OPEN_TAG], ':', ';'];
134+
static $include = ['{', '}', [T_OPEN_TAG], ':', ';'];
135135

136-
return $tokens[$tokens->getPrevMeaningfulToken($index)]->equalsAny($whiteList);
136+
return $tokens[$tokens->getPrevMeaningfulToken($index)]->equalsAny($include);
137137
}
138138

139139
private function clearIfIsOverCompleteNamespaceBlock(Tokens $tokens)

src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class PhpdocToReturnTypeFixer extends AbstractFixer implements Configurati
3434
/**
3535
* @var array<int, array<int, int|string>>
3636
*/
37-
private $blacklistFuncNames = [
37+
private $excludeFuncNames = [
3838
[T_STRING, '__construct'],
3939
[T_STRING, '__destruct'],
4040
[T_STRING, '__clone'],
@@ -179,7 +179,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
179179
}
180180

181181
$funcName = $tokens->getNextMeaningfulToken($index);
182-
if ($tokens[$funcName]->equalsAny($this->blacklistFuncNames, false)) {
182+
if ($tokens[$funcName]->equalsAny($this->excludeFuncNames, false)) {
183183
continue;
184184
}
185185

src/Fixer/FunctionNotation/VoidReturnFixer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function isRisky()
7878
protected function applyFix(\SplFileInfo $file, Tokens $tokens)
7979
{
8080
// These cause syntax errors.
81-
static $blacklistFuncNames = [
81+
static $excludeFuncNames = [
8282
[T_STRING, '__construct'],
8383
[T_STRING, '__destruct'],
8484
[T_STRING, '__clone'],
@@ -90,7 +90,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
9090
}
9191

9292
$funcName = $tokens->getNextMeaningfulToken($index);
93-
if ($tokens[$funcName]->equalsAny($blacklistFuncNames, false)) {
93+
if ($tokens[$funcName]->equalsAny($excludeFuncNames, false)) {
9494
continue;
9595
}
9696

tests/Fixer/ClassNotation/FinalInternalClassFixerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public function testConfigureSameAnnotationInBothLists()
289289
{
290290
$this->expectException(\PhpCsFixer\ConfigurationException\InvalidFixerConfigurationException::class);
291291
$this->expectExceptionMessageRegExp(
292-
sprintf('#^%s$#', preg_quote('[final_internal_class] Annotation cannot be used in both the white- and black list, got duplicates: "internal123".', '#'))
292+
sprintf('#^%s$#', preg_quote('[final_internal_class] Annotation cannot be used in both the include and exclude list, got duplicates: "internal123".', '#'))
293293
);
294294

295295
$this->fixer->configure([

tests/Fixer/FunctionNotation/PhpdocToReturnTypeFixerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function provideFixCases()
6969
'invalid class 5' => [
7070
'<?php /** @return I\Want\To\Break\Free */ function queen() {}',
7171
],
72-
'blacklisted class methods' => [
72+
'excluded class methods' => [
7373
'<?php
7474
7575
class Foo

0 commit comments

Comments
 (0)