Skip to content

Commit

Permalink
[PHP 8] Add Nette\Utils\Strings to string functions (#6)
Browse files Browse the repository at this point in the history
* [PHP 8] Add nette utils strings to functions

* remove AnnotationToAttributeRector without any config
  • Loading branch information
TomasVotruba committed May 10, 2021
1 parent a80cf52 commit 2deebfe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions config/set/php80.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Rector\Arguments\ValueObject\ArgumentAdder;
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
use Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\Class_\StringableForToStringRector;
use Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector;
Expand All @@ -21,17 +20,29 @@
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\Php80\Rector\Ternary\GetDebugTypeRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;

return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator->services();
$services->set(UnionTypesRector::class);

$services->set(StrContainsRector::class);
$services->set(StrStartsWithRector::class);
$services->set(StrEndsWithRector::class);

$services->set(StaticCallToFuncCallRector::class)
->call('configure', [
StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => ValueObjectInliner::inline([
new StaticCallToFuncCall('Nette\Utils\Strings', 'startsWith', 'str_starts_with'),
new StaticCallToFuncCall('Nette\Utils\Strings', 'endsWith', 'str_ends_with'),
new StaticCallToFuncCall('Nette\Utils\Strings', 'contains', 'str_contains'),
]),
]);

$services->set(StringableForToStringRector::class);
$services->set(AnnotationToAttributeRector::class);
$services->set(ClassOnObjectRector::class);
$services->set(GetDebugTypeRector::class);
$services->set(TokenGetAllToObjectRector::class);
Expand Down

0 comments on commit 2deebfe

Please sign in to comment.