Skip to content

Commit 4d36b7e

Browse files
authored
Deprecate NumericLiteralSeparatorFixer (#949)
1 parent 412229b commit 4d36b7e

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG for PHP CS Fixer: custom fixers
22

3+
## v3.19.0
4+
- Deprecate NumericLiteralSeparatorFixer - use "numeric_literal_separator "
5+
- Update minimum PHP CS Fixer version to 3.47.0
6+
37
## v3.18.0
48
- Add PhpdocTypeListFixer
59

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
66
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
77
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
8-
![Tests](https://img.shields.io/badge/tests-3525-brightgreen.svg)
8+
![Tests](https://img.shields.io/badge/tests-3526-brightgreen.svg)
99
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
1010

1111
[![CI status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml/badge.svg)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml)
@@ -385,6 +385,7 @@ Functions `strlen` and `mb_strlen` must not be compared to 0.
385385

386386
#### NumericLiteralSeparatorFixer
387387
Numeric literals must have configured separators.
388+
DEPRECATED: use `numeric_literal_separator` instead.
388389
Configuration options:
389390
- `binary` (`bool`, `null`): whether add, remove or ignore separators in binary numbers.; defaults to `false`
390391
- `decimal` (`bool`, `null`): whether add, remove or ignore separators in decimal numbers.; defaults to `false`

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": "^7.4 || ^8.0",
1414
"ext-filter": "*",
1515
"ext-tokenizer": "*",
16-
"friendsofphp/php-cs-fixer": "^3.22"
16+
"friendsofphp/php-cs-fixer": "^3.47"
1717
},
1818
"require-dev": {
1919
"phpunit/phpunit": "^9.6.4 || ^10.0.14"

src/Fixer/NumericLiteralSeparatorFixer.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

1212
namespace PhpCsFixerCustomFixers\Fixer;
1313

14+
use PhpCsFixer\Fixer\Basic\NumericLiteralSeparatorFixer as NLSFixer;
1415
use PhpCsFixer\Fixer\ConfigurableFixerInterface;
16+
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
1517
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolver;
1618
use PhpCsFixer\FixerConfiguration\FixerConfigurationResolverInterface;
1719
use PhpCsFixer\FixerConfiguration\FixerOptionBuilder;
@@ -23,7 +25,10 @@
2325
use PhpCsFixer\Tokenizer\Token;
2426
use PhpCsFixer\Tokenizer\Tokens;
2527

26-
final class NumericLiteralSeparatorFixer extends AbstractFixer implements ConfigurableFixerInterface
28+
/**
29+
* @deprecated
30+
*/
31+
final class NumericLiteralSeparatorFixer extends AbstractFixer implements ConfigurableFixerInterface, DeprecatedFixerInterface
2732
{
2833
private ?bool $binarySeparator = false;
2934
private ?bool $decimalSeparator = false;
@@ -121,6 +126,14 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
121126
}
122127
}
123128

129+
/**
130+
* @return list<string>
131+
*/
132+
public function getSuccessorsNames(): array
133+
{
134+
return [(new NLSFixer())->getName()];
135+
}
136+
124137
private function getNewContent(string $content): string
125138
{
126139
if (\strpos($content, '.') !== false) {

tests/Fixer/NumericLiteralSeparatorFixerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public function testConfiguration(): void
4040
self::assertSame('octal', $options[4]->getName());
4141
}
4242

43+
public function testSuccessorName(): void
44+
{
45+
self::assertSuccessorName('numeric_literal_separator');
46+
}
47+
4348
public function testReversingCodeSample(): void
4449
{
4550
$fixer = self::getFixer();

0 commit comments

Comments
 (0)