Skip to content

Commit 21151fa

Browse files
committed
Handle multiple constants definition
1 parent d00e261 commit 21151fa

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

README.md

Lines changed: 1 addition & 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-3744-brightgreen.svg)
8+
![Tests](https://img.shields.io/badge/tests-3748-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)

src/Fixer/TypedClassConstantFixer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class Foo {
4545
);
4646
}
4747

48+
/**
49+
* Must run after SingleClassElementPerStatementFixer.
50+
*/
4851
public function getPriority(): int
4952
{
5053
return 0;

tests/Fixer/TypedClassConstantFixerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,5 +314,10 @@ class HellCoreServiceManagerHelper
314314
}
315315
PHP,
316316
];
317+
318+
yield 'make multiple constants definition mixed type' => [
319+
'<?php class Foo { public const mixed BAR = 1, BAZ = "two"; }',
320+
'<?php class Foo { public const BAR = 1, BAZ = "two"; }',
321+
];
317322
}
318323
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--CONFIGURATION--
2+
{ "single_class_element_per_statement": true, "PhpCsFixerCustomFixers/typed_class_constant": true }
3+
--EXPECTED--
4+
<?php
5+
class Foo {
6+
const int BAR = 1;
7+
const string BAZ = "two";
8+
}
9+
10+
--INPUT--
11+
<?php
12+
class Foo {
13+
const BAR = 1, BAZ = "two";
14+
}

0 commit comments

Comments
 (0)