Skip to content

Commit fe0ada9

Browse files
committed
Update
1 parent 2998165 commit fe0ada9

File tree

3 files changed

+47
-46
lines changed

3 files changed

+47
-46
lines changed

README.md

+2-2
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-3635-brightgreen.svg)
8+
![Tests](https://img.shields.io/badge/tests-3637-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)
@@ -407,7 +407,7 @@ There must be no useless write visibility.
407407
- public(set) $y;
408408
- protected protected(set) $z;
409409
+ public $x;
410-
+ public(set)$y;
410+
+ public $y;
411411
+ protected $z;
412412
}
413413
```

src/Fixer/NoUselessWriteVisibilityFixer.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public function getDefinition(): FixerDefinitionInterface
3232
'There must be no useless write visibility.',
3333
[new CodeSample(
3434
<<<'PHP'
35-
<?php class Foo {
36-
public public(set) $x;
37-
public(set) $y;
38-
protected protected(set) $z;
39-
}
35+
<?php class Foo {
36+
public public(set) $x;
37+
public(set) $y;
38+
protected protected(set) $z;
39+
}
4040

41-
PHP,
41+
PHP,
4242
)],
4343
);
4444
}
@@ -62,7 +62,7 @@ public function fix(\SplFileInfo $file, Tokens $tokens): void
6262
{
6363
foreach ($tokens->findGivenKind(\array_keys(self::PREDECESSOR_KIND_MAP)) as $kind => $elements) {
6464
foreach (\array_keys($elements) as $index) {
65-
$this->fixVisibility($tokens, $index, $kind, \defined('T_PUBLIC_SET') && $kind === T_PUBLIC_SET);
65+
self::fixVisibility($tokens, $index, $kind, $kind === \T_PUBLIC_SET);
6666
}
6767
}
6868
}
@@ -73,8 +73,9 @@ private static function fixVisibility(Tokens $tokens, int $index, int $kind, boo
7373

7474
if (!$tokens[$prevIndex]->isGivenKind(self::PREDECESSOR_KIND_MAP[$kind])) {
7575
if ($makePublicIfNone) {
76-
$tokens[$index] = new Token([T_PUBLIC, 'public']);
76+
$tokens[$index] = new Token([\T_PUBLIC, 'public']);
7777
}
78+
7879
return;
7980
}
8081

tests/Fixer/NoUselessWriteVisibilityFixerTest.php

+36-36
Original file line numberDiff line numberDiff line change
@@ -40,53 +40,53 @@ public static function provideFixCases(): iterable
4040
{
4141
yield [
4242
<<<'PHP'
43-
<?php class Foo {
44-
public $x;
45-
protected $z;
46-
private $z;
47-
}
48-
PHP,
43+
<?php class Foo {
44+
public $x;
45+
protected $z;
46+
private $z;
47+
}
48+
PHP,
4949
<<<'PHP'
50-
<?php class Foo {
51-
public public(set) $x;
52-
protected protected(set) $z;
53-
private private(set) $z;
54-
}
55-
PHP,
50+
<?php class Foo {
51+
public public(set) $x;
52+
protected protected(set) $z;
53+
private private(set) $z;
54+
}
55+
PHP,
5656
];
5757

5858
yield [
5959
<<<'PHP'
60-
<?php class Foo {
61-
public $x;
62-
}
63-
PHP,
60+
<?php class Foo {
61+
public $x;
62+
}
63+
PHP,
6464
<<<'PHP'
65-
<?php class Foo {
66-
public(set) $x;
67-
}
68-
PHP,
65+
<?php class Foo {
66+
public(set) $x;
67+
}
68+
PHP,
6969
];
7070

7171
yield [
7272
<<<'PHP'
73-
<?php class Foo {
74-
public function __construct(
75-
public $x,
76-
protected $z,
77-
private $z,
78-
) {}
79-
}
80-
PHP,
73+
<?php class Foo {
74+
public function __construct(
75+
public $x,
76+
protected $z,
77+
private $z,
78+
) {}
79+
}
80+
PHP,
8181
<<<'PHP'
82-
<?php class Foo {
83-
public function __construct(
84-
public public(set) $x,
85-
protected protected(set) $z,
86-
private private(set) $z,
87-
) {}
88-
}
89-
PHP,
82+
<?php class Foo {
83+
public function __construct(
84+
public public(set) $x,
85+
protected protected(set) $z,
86+
private private(set) $z,
87+
) {}
88+
}
89+
PHP,
9090
];
9191
}
9292
}

0 commit comments

Comments
 (0)