Skip to content

Commit 6be2b3b

Browse files
committed
use static closure
1 parent 13d28b8 commit 6be2b3b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

rector.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use Rector\CodingStyle\Rector\Closure\StaticClosureRector;
34
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
45
use Rector\Config\RectorConfig;
56

@@ -11,4 +12,7 @@
1112
->withImportNames(removeUnusedImports: true)
1213
->withSkip([
1314
NullToStrictStringFuncCallArgRector::class,
15+
])
16+
->withRules([
17+
StaticClosureRector::class,
1418
]);

spec/Filter/NamingSpec.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
use Naming\Filter\Naming;
66

7-
describe('Naming', function (): void {
7+
describe('Naming', static function (): void {
88

9-
describe('filter()', function (): void {
9+
describe('filter()', static function (): void {
1010

11-
it('set striptags, trim, and strip double space with ucwords with set lower first, upper after apostrophe and hyphen', function (): void {
11+
it('set striptags, trim, and strip double space with ucwords with set lower first, upper after apostrophe and hyphen', static function (): void {
1212

1313
$maps = [
1414
'' => '',

src/Filter/Naming.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function filter(mixed $value): string
3838
// Ensure the letter after apostrophe/hyphen is uppercase (Unicode-safe)
3939
$value = preg_replace_callback(
4040
"/(?<=^|\s)(\p{L}+'?)(\p{Ll})/u",
41-
function ($matches) {
41+
static function ($matches): string {
4242
// only uppercase if it's single-letter prefix like D' or O'
4343
if (mb_strlen($matches[1], 'UTF-8') === 2 && str_ends_with($matches[1], "'")) {
4444
return $matches[1] . mb_strtoupper($matches[2], 'UTF-8');

0 commit comments

Comments
 (0)