Skip to content

Commit

Permalink
Merge pull request #99 from lmc-eu/feature/dependecies
Browse files Browse the repository at this point in the history
Refactor: Remove nette/utils dependency
  • Loading branch information
OndraM committed May 13, 2024
2 parents 728a7ae + 19962e9 commit 06f2318
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"require": {
"php": "^8.0",
"friendsofphp/php-cs-fixer": "^3.0",
"nette/utils": "^3.2",
"slevomat/coding-standard": "^8.0",
"squizlabs/php_codesniffer": "^3.9",
"symplify/easy-coding-standard": "^12.1.5"
Expand Down
3 changes: 1 addition & 2 deletions src/Sniffs/Naming/AbstractClassNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

namespace Lmc\CodingStandard\Sniffs\Naming;

use Nette\Utils\Strings;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;

Expand Down Expand Up @@ -70,7 +69,7 @@ private function shouldBeSkipped(): bool
return true;
}

return Strings::startsWith($className, 'Abstract');
return str_starts_with($className, 'Abstract');
}

private function isClassAbstract(): bool
Expand Down
11 changes: 5 additions & 6 deletions src/Sniffs/Naming/ClassNameSuffixByParentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

use Lmc\CodingStandard\Helper\Naming;
use Lmc\CodingStandard\Helper\SniffClassWrapper;
use Nette\Utils\Strings;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;

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

// the class that implements $currentParentType, should end with $suffix
$suffix = $this->resolveExpectedSuffix($parentType);
if (Strings::endsWith($className, $suffix)) {
if (str_ends_with($className, $suffix)) {
continue;
}

Expand All @@ -123,12 +122,12 @@ private function getClassToSuffixMap(): array
*/
private function resolveExpectedSuffix(string $parentType): string
{
if (Strings::endsWith($parentType, 'Interface')) {
$parentType = Strings::substring($parentType, 0, -mb_strlen('Interface'));
if (str_ends_with($parentType, 'Interface')) {
$parentType = mb_substr($parentType, 0, -mb_strlen('Interface'), 'UTF-8');
}

if (Strings::startsWith($parentType, 'Abstract')) {
$parentType = Strings::substring($parentType, mb_strlen('Abstract'));
if (str_starts_with($parentType, 'Abstract')) {
$parentType = mb_substr($parentType, mb_strlen('Abstract'), null, 'UTF-8');
}

return $parentType;
Expand Down
3 changes: 1 addition & 2 deletions src/Sniffs/Naming/InterfaceNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

namespace Lmc\CodingStandard\Sniffs\Naming;

use Nette\Utils\Strings;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;

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

if (Strings::endsWith($this->getInterfaceName(), 'Interface')) {
if (str_ends_with($this->getInterfaceName(), 'Interface')) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Sniffs/Naming/TraitNameSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

namespace Lmc\CodingStandard\Sniffs\Naming;

use Nette\Utils\Strings;
use PHP_CodeSniffer\Files\File;
use PHP_CodeSniffer\Sniffs\Sniff;

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

if (Strings::endsWith($this->getTraitName(), 'Trait')) {
if (str_ends_with($this->getTraitName(), 'Trait')) {
return;
}

Expand Down

0 comments on commit 06f2318

Please sign in to comment.