Skip to content

Commit 2fa32f1

Browse files
committed
cs
1 parent d201c9b commit 2fa32f1

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

ncs.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
declare(strict_types=1);
99

1010
return [
11-
// constant NULL, FALSE in src/PhpGenerator/Type.php
12-
'constant_case' => false,
11+
// constants in src/PhpGenerator/Type.php
1312
'lowercase_static_reference' => false,
1413
];

src/PhpGenerator/Dumper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ private function dumpString(string $s): string
7373

7474
$utf8 = preg_match('##u', $s);
7575
$escaped = preg_replace_callback(
76-
$utf8 ? '#[\p{C}\\\\]#u' : '#[\x00-\x1F\x7F-\xFF\\\\]#',
76+
$utf8 ? '#[\p{C}\\\]#u' : '#[\x00-\x1F\x7F-\xFF\\\]#',
7777
fn($m) => $special[$m[0]] ?? (strlen($m[0]) === 1
7878
? '\x' . str_pad(strtoupper(dechex(ord($m[0]))), 2, '0', STR_PAD_LEFT)
7979
: '\u{' . strtoupper(ltrim(dechex(self::utf8Ord($m[0])), '0')) . '}'),
8080
$s,
8181
);
8282
return $s === str_replace('\\\\', '\\', $escaped)
83-
? "'" . preg_replace('#\'|\\\\(?=[\'\\\\]|$)#D', '\\\\$0', $s) . "'"
83+
? "'" . preg_replace('#\'|\\\(?=[\'\\\]|$)#D', '\\\$0', $s) . "'"
8484
: '"' . addcslashes($escaped, '"$') . '"';
8585
}
8686

src/PhpGenerator/Helpers.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static function tagName(string $name, string $of = PhpNamespace::NameNorm
7575

7676
public static function simplifyTaggedNames(string $code, ?PhpNamespace $namespace): string
7777
{
78-
return preg_replace_callback('~/\*\(([ncf])\*/([\w\x7f-\xff\\\\]++)~', function ($m) use ($namespace) {
78+
return preg_replace_callback('~/\*\(([ncf])\*/([\w\x7f-\xff\\\]++)~', function ($m) use ($namespace) {
7979
[, $of, $name] = $m;
8080
return $namespace
8181
? $namespace->simplifyType($name, $of)
@@ -106,7 +106,7 @@ public static function isIdentifier(mixed $value): bool
106106

107107
public static function isNamespaceIdentifier(mixed $value, bool $allowLeadingSlash = false): bool
108108
{
109-
$re = '#^' . ($allowLeadingSlash ? '\\\\?' : '') . self::ReIdentifier . '(\\\\' . self::ReIdentifier . ')*$#D';
109+
$re = '#^' . ($allowLeadingSlash ? '\\\?' : '') . self::ReIdentifier . '(\\\\' . self::ReIdentifier . ')*$#D';
110110
return is_string($value) && preg_match($re, $value);
111111
}
112112

src/PhpGenerator/PhpNamespace.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function resolveName(string $name, string $of = self::NameNormal): string
200200
*/
201201
public function simplifyType(string $type, string $of = self::NameNormal): string
202202
{
203-
return preg_replace_callback('~[\w\x7f-\xff\\\\]+~', fn($m) => $this->simplifyName($m[0], $of), $type);
203+
return preg_replace_callback('~[\w\x7f-\xff\\\]+~', fn($m) => $this->simplifyName($m[0], $of), $type);
204204
}
205205

206206

tests/PhpGenerator/Dumper.dump().phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Assert::same("'Hello'", $dumper->dump('Hello'));
3434
Assert::same('"\t\n\r\e"', $dumper->dump("\t\n\r\e"));
3535
Assert::same('"\u{FEFF}"', $dumper->dump("\xEF\xBB\xBF")); // BOM
3636
Assert::same('\'$"\\\\\'', $dumper->dump('$"\\'));
37-
Assert::same('\'$"\\ \x00\'', $dumper->dump('$"\\ \x00')); // no escape
38-
Assert::same('"\\$\\"\\\\ \x00"', $dumper->dump("$\"\\ \x00"));
37+
Assert::same('\'$"\ \x00\'', $dumper->dump('$"\ \x00')); // no escape
38+
Assert::same('"\$\"\\\ \x00"', $dumper->dump("$\"\\ \x00"));
3939
Assert::same(
4040
"'I\u{F1}t\u{EB}rn\u{E2}ti\u{F4}n\u{E0}liz\u{E6}ti\u{F8}n'",
4141
$dumper->dump("I\u{F1}t\u{EB}rn\u{E2}ti\u{F4}n\u{E0}liz\u{E6}ti\u{F8}n"), // Iñtërnâtiônàlizætiøn

tests/PhpGenerator/Helpers.isNamespaceIdentifier.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ Assert::true(Helpers::isNamespaceIdentifier("\x7F"));
1313
Assert::true(Helpers::isNamespaceIdentifier("\x7F\\\x7F"));
1414
Assert::false(Helpers::isNamespaceIdentifier('0Item'));
1515
Assert::true(Helpers::isNamespaceIdentifier('Item\Item'));
16-
Assert::false(Helpers::isNamespaceIdentifier('Item\\\\Item'));
17-
Assert::false(Helpers::isNamespaceIdentifier('\\Item'));
16+
Assert::false(Helpers::isNamespaceIdentifier('Item\\\Item'));
17+
Assert::false(Helpers::isNamespaceIdentifier('\Item'));
1818
Assert::false(Helpers::isNamespaceIdentifier('Item\\'));
1919

20-
Assert::true(Helpers::isNamespaceIdentifier('\\Item', allowLeadingSlash: true));
20+
Assert::true(Helpers::isNamespaceIdentifier('\Item', allowLeadingSlash: true));
2121
Assert::false(Helpers::isNamespaceIdentifier('Item\\', allowLeadingSlash: true));

tests/PhpGenerator/PhpFile.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ $interfaceF
7474
$traitG = $file->addTrait('Baz\G');
7575
Assert::same($file->addNamespace('Baz'), $traitG->getNamespace());
7676

77-
$file->addFunction('Baz\\f2')
77+
$file->addFunction('Baz\f2')
7878
->setReturnType('Foo\B');
7979

8080

@@ -112,7 +112,7 @@ Assert::same([
112112
'FooBar\I',
113113
], array_keys($file->getClasses()));
114114

115-
Assert::same(['Baz\\f2', 'f1'], array_keys($file->getFunctions()));
115+
Assert::same(['Baz\f2', 'f1'], array_keys($file->getFunctions()));
116116

117117

118118

tests/PhpGenerator/fixtures/classes.82.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ public function func(C|(X&D)|null $foo): (A&B)|null
2222

2323
trait Trait13
2424
{
25-
public const FOO = 123;
25+
public const FOO = 123;
2626
}

0 commit comments

Comments
 (0)