Skip to content

Commit 31addc3

Browse files
committed
few php-cs cleanup items
1 parent 8b6b6db commit 31addc3

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

src/HasSettableStringTags.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
trait HasSettableStringTags
2525
{
2626
/**
27-
* @param string[] $tags
28-
* @return \$this
27+
* @param array $tags
28+
* @return $this
2929
*/
3030
public function setTags(array $tags)
3131
{
@@ -35,7 +35,7 @@ public function setTags(array $tags)
3535

3636
/**
3737
* @param string $tag
38-
* @return \$this
38+
* @return $this
3939
*/
4040
public function addTag(string $tag)
4141
{

tools/php-cs-fixer/src/Fixer/FQCN/Normalizer.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,41 @@
2828
*/
2929
final class Normalizer extends FQCNTypeNormalizer
3030
{
31+
public const BUILD_IN_TYPES = FQCNTypeNormalizer::BUILD_IN_TYPES + [17 => 'static', 18 => '$this'];
32+
33+
private const DOLLAR = '$';
34+
private const SLASH = '\\';
35+
private const DUMB_DOLLAR = self::SLASH . self::DOLLAR;
36+
private const MIXED_FORMAT = 'mixed %s';
37+
private const ARR = '[]';
38+
3139
/**
3240
* @param \AdamWojs\PhpCsFixerPhpdocForceFQCN\Analyzer\NamespaceInfo $namespaceInfo
3341
* @param string $type
3442
* @return string
3543
*/
3644
public function normalizeType(NamespaceInfo $namespaceInfo, string $type): string
3745
{
38-
if ('[]' === \substr($type, -2)) {
39-
return $this->normalizeType($namespaceInfo, \substr($type, 0, -2)) . '[]';
46+
if (self::ARR === \substr($type, -2)) {
47+
return $this->normalizeType($namespaceInfo, \substr($type, 0, -2)) . self::ARR;
4048
}
4149

4250
// if this is a built-in type, already has a namespace prefix, or is merely empty, move on.
4351
if (\in_array($type, self::BUILD_IN_TYPES, true) ||
44-
0 === \strpos($type, '\\') ||
52+
0 === \strpos($type, self::SLASH) ||
4553
'' === \trim($type)) {
4654
return $type;
4755
}
4856

49-
// if this is a variable, set to 'mixed' and assume i'll fix it later
50-
if (0 === \strpos($type, '$')) {
51-
return "mixed {$type}";
57+
// if this is a variable...
58+
if (0 === \strpos($type, self::DOLLAR)) {
59+
// ...otherwise set to 'mixed' and assume i'll fix it later
60+
return \sprintf(self::MIXED_FORMAT, $type);
5261
}
5362

5463
// if this is a dumb thing, clean it up
55-
if (0 === \strpos($type, '\\$')) {
56-
return \sprintf('mixed %s', \ltrim($type, '\\'));
64+
if (0 === \strpos($type, self::DUMB_DOLLAR)) {
65+
return \sprintf(self::MIXED_FORMAT, \ltrim($type, self::SLASH));
5766
}
5867

5968
// in all other cases, try to find an ns prefix

0 commit comments

Comments
 (0)