Skip to content

Commit 4d3eb82

Browse files
committed
ReadonlyPromotedPropertiesFixer - support asymmetric visibility
1 parent 217f467 commit 4d3eb82

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

CHANGELOG.md

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

3+
## v3.25.0
4+
- ReadonlyPromotedPropertiesFixer - support asymmetric visibility
5+
36
## v3.24.0
47
- Add PhpUnitRequiresConstraintFixer
58

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-3610-brightgreen.svg)
8+
![Tests](https://img.shields.io/badge/tests-3614-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)

tests/Fixer/AbstractFixerTestCase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ abstract class AbstractFixerTestCase extends TestCase
4040
'testFix80',
4141
'testFix81',
4242
'testFix82',
43+
'testFix84',
4344
'testIsRisky',
4445
'testReversingCodeSample',
4546
'testStringIsTheSame',

tests/Fixer/ReadonlyPromotedPropertiesFixerTest.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,88 @@ class Baz { public function __construct(public int $x) {} }
173173
',
174174
];
175175
}
176+
177+
/**
178+
* @dataProvider provideFix84Cases
179+
*
180+
* @requires PHP >= 8.4
181+
*/
182+
public function testFix84(string $expected, ?string $input = null): void
183+
{
184+
$this->doTest($expected, $input);
185+
}
186+
187+
/**
188+
* @return iterable<string, array{0: string, 1?: string}>
189+
*/
190+
public static function provideFix84Cases(): iterable
191+
{
192+
yield 'asymmetric visibility with both visibilities' => [
193+
<<<'PHP'
194+
<?php
195+
final class Foo {
196+
public function __construct(
197+
public public(set) readonly int $a,
198+
public protected(set) readonly int $b,
199+
public private(set) readonly int $c,
200+
protected protected(set) readonly int $d,
201+
protected private(set) readonly int $e,
202+
private private(set) readonly int $f,
203+
) {}
204+
}
205+
PHP,
206+
<<<'PHP'
207+
<?php
208+
final class Foo {
209+
public function __construct(
210+
public public(set) int $a,
211+
public protected(set) int $b,
212+
public private(set) int $c,
213+
protected protected(set) int $d,
214+
protected private(set) int $e,
215+
private private(set) int $f,
216+
) {}
217+
}
218+
PHP,
219+
];
220+
221+
yield 'asymmetric visibility with only write visibility' => [
222+
<<<'PHP'
223+
<?php
224+
final class Foo {
225+
public function __construct(
226+
public(set) readonly int $a,
227+
protected(set) readonly int $b,
228+
private(set) readonly int $c,
229+
) {}
230+
}
231+
PHP,
232+
<<<'PHP'
233+
<?php
234+
final class Foo {
235+
public function __construct(
236+
public(set) int $a,
237+
protected(set) int $b,
238+
private(set) int $c,
239+
) {}
240+
}
241+
PHP,
242+
];
243+
244+
yield 'readonly asymmetric visibility' => [
245+
<<<'PHP'
246+
<?php
247+
final class Foo {
248+
public function __construct(
249+
readonly public public(set) int $a,
250+
public readonly protected(set) int $b,
251+
public private(set) readonly int $c,
252+
readonly private(set) int $e,
253+
private(set) readonly int $f,
254+
) {}
255+
}
256+
PHP,
257+
];
258+
259+
}
176260
}

0 commit comments

Comments
 (0)