Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Remove nette/utils dependency #99

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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