Skip to content

Commit 06f2318

Browse files
authored
Merge pull request #99 from lmc-eu/feature/dependecies
Refactor: Remove nette/utils dependency
2 parents 728a7ae + 19962e9 commit 06f2318

5 files changed

+8
-13
lines changed

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"require": {
1313
"php": "^8.0",
1414
"friendsofphp/php-cs-fixer": "^3.0",
15-
"nette/utils": "^3.2",
1615
"slevomat/coding-standard": "^8.0",
1716
"squizlabs/php_codesniffer": "^3.9",
1817
"symplify/easy-coding-standard": "^12.1.5"

src/Sniffs/Naming/AbstractClassNameSniff.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
namespace Lmc\CodingStandard\Sniffs\Naming;
3030

31-
use Nette\Utils\Strings;
3231
use PHP_CodeSniffer\Files\File;
3332
use PHP_CodeSniffer\Sniffs\Sniff;
3433

@@ -70,7 +69,7 @@ private function shouldBeSkipped(): bool
7069
return true;
7170
}
7271

73-
return Strings::startsWith($className, 'Abstract');
72+
return str_starts_with($className, 'Abstract');
7473
}
7574

7675
private function isClassAbstract(): bool

src/Sniffs/Naming/ClassNameSuffixByParentSniff.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
use Lmc\CodingStandard\Helper\Naming;
3232
use Lmc\CodingStandard\Helper\SniffClassWrapper;
33-
use Nette\Utils\Strings;
3433
use PHP_CodeSniffer\Files\File;
3534
use PHP_CodeSniffer\Sniffs\Sniff;
3635

@@ -101,7 +100,7 @@ private function processType(File $file, string $currentParentType, string $clas
101100

102101
// the class that implements $currentParentType, should end with $suffix
103102
$suffix = $this->resolveExpectedSuffix($parentType);
104-
if (Strings::endsWith($className, $suffix)) {
103+
if (str_ends_with($className, $suffix)) {
105104
continue;
106105
}
107106

@@ -123,12 +122,12 @@ private function getClassToSuffixMap(): array
123122
*/
124123
private function resolveExpectedSuffix(string $parentType): string
125124
{
126-
if (Strings::endsWith($parentType, 'Interface')) {
127-
$parentType = Strings::substring($parentType, 0, -mb_strlen('Interface'));
125+
if (str_ends_with($parentType, 'Interface')) {
126+
$parentType = mb_substr($parentType, 0, -mb_strlen('Interface'), 'UTF-8');
128127
}
129128

130-
if (Strings::startsWith($parentType, 'Abstract')) {
131-
$parentType = Strings::substring($parentType, mb_strlen('Abstract'));
129+
if (str_starts_with($parentType, 'Abstract')) {
130+
$parentType = mb_substr($parentType, mb_strlen('Abstract'), null, 'UTF-8');
132131
}
133132

134133
return $parentType;

src/Sniffs/Naming/InterfaceNameSniff.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
namespace Lmc\CodingStandard\Sniffs\Naming;
3030

31-
use Nette\Utils\Strings;
3231
use PHP_CodeSniffer\Files\File;
3332
use PHP_CodeSniffer\Sniffs\Sniff;
3433

@@ -56,7 +55,7 @@ public function process(File $phpcsFile, $stackPtr): void
5655
$this->file = $phpcsFile;
5756
$this->position = $stackPtr;
5857

59-
if (Strings::endsWith($this->getInterfaceName(), 'Interface')) {
58+
if (str_ends_with($this->getInterfaceName(), 'Interface')) {
6059
return;
6160
}
6261

src/Sniffs/Naming/TraitNameSniff.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
namespace Lmc\CodingStandard\Sniffs\Naming;
3030

31-
use Nette\Utils\Strings;
3231
use PHP_CodeSniffer\Files\File;
3332
use PHP_CodeSniffer\Sniffs\Sniff;
3433

@@ -56,7 +55,7 @@ public function process(File $phpcsFile, $stackPtr): void
5655
$this->file = $phpcsFile;
5756
$this->position = $stackPtr;
5857

59-
if (Strings::endsWith($this->getTraitName(), 'Trait')) {
58+
if (str_ends_with($this->getTraitName(), 'Trait')) {
6059
return;
6160
}
6261

0 commit comments

Comments
 (0)