Skip to content

Commit 6cf2a60

Browse files
committed
fixup! fixup! fixup! fixup! Feat: Remove skip of BlankLineAfterOpeningTagFixer
1 parent 3dbfa9e commit 6cf2a60

File tree

5 files changed

+640
-21
lines changed

5 files changed

+640
-21
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
"autoload": {
3030
"psr-4": {
3131
"Lmc\\CodingStandard\\": "src/"
32-
}
32+
},
33+
"files": [
34+
"src/polyfill.php"
35+
]
3336
},
3437
"autoload-dev": {
3538
"psr-4": {

src/Helper/Naming.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,6 @@
3434
use SlevomatCodingStandard\Helpers\NamespaceHelper;
3535
use SlevomatCodingStandard\Helpers\ReferencedNameHelper;
3636

37-
// Polyfill for mb_ltrim() which is only available in PHP 8.4+
38-
if (!function_exists('mb_ltrim')) {
39-
/**
40-
* @param non-empty-string $characters
41-
*/
42-
function mb_ltrim(string $string, string $characters = " \n\r\t\v\0", ?string $encoding = null): string
43-
{
44-
$encoding = $encoding ?? mb_internal_encoding();
45-
46-
$characterArray = preg_split('//u', $characters, -1, PREG_SPLIT_NO_EMPTY);
47-
if ($characterArray === false) {
48-
return $string;
49-
}
50-
51-
$pattern = '/^[' . preg_quote(implode('', $characterArray), '/') . ']+/u';
52-
53-
return (string) preg_replace($pattern, '', $string);
54-
}
55-
}
56-
5737
final class Naming
5838
{
5939
/**

src/polyfill.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* Polyfill for mb_ltrim() which is only available in PHP 8.4+
7+
*
8+
* This file provides backward compatibility for the mb_ltrim() function
9+
* introduced in PHP 8.4.0, allowing the codebase to work with PHP 8.0-8.3.
10+
*/
11+
12+
if (!function_exists('mb_ltrim')) {
13+
/**
14+
* Strip whitespace (or other characters) from the beginning of a string using multibyte encoding.
15+
*
16+
* @param string $string The input string
17+
* @param non-empty-string $characters The characters to strip
18+
* @param string|null $encoding The character encoding. If null, the internal character encoding is used.
19+
*
20+
* @return string The trimmed string
21+
*/
22+
function mb_ltrim(string $string, string $characters = " \n\r\t\v\0", ?string $encoding = null): string
23+
{
24+
$encoding = $encoding ?? mb_internal_encoding();
25+
26+
$characterArray = preg_split('//u', $characters, -1, PREG_SPLIT_NO_EMPTY);
27+
if ($characterArray === false) {
28+
return $string;
29+
}
30+
31+
$pattern = '/^[' . preg_quote(implode('', $characterArray), '/') . ']+/u';
32+
33+
return (string) preg_replace($pattern, '', $string);
34+
}
35+
}

0 commit comments

Comments
 (0)