Skip to content
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
44 changes: 2 additions & 42 deletions build/target-repository/docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 412 Rules Overview
# 411 Rules Overview

<br>

Expand All @@ -8,7 +8,7 @@

- [CodeQuality](#codequality) (76)

- [CodingStyle](#codingstyle) (37)
- [CodingStyle](#codingstyle) (36)

- [Compatibility](#compatibility) (1)

Expand Down Expand Up @@ -1997,46 +1997,6 @@ Changes various implode forms to consistent one

<br>

### ConsistentPregDelimiterRector

Replace PREG delimiter with configured one

:wrench: **configure it!**

- class: [`Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector`](../rules/CodingStyle/Rector/FuncCall/ConsistentPregDelimiterRector.php)

```php
<?php

declare(strict_types=1);

use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;
use Rector\Config\RectorConfig;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->ruleWithConfiguration(ConsistentPregDelimiterRector::class, [
ConsistentPregDelimiterRector::DELIMITER => '#',
]);
};
```


```diff
class SomeClass
{
public function run()
{
- preg_match('~value~', $value);
- preg_match_all('~value~im', $value);
+ preg_match('#value#', $value);
+ preg_match_all('#value#im', $value);
}
}
```

<br>

### CountArrayToEmptyArrayComparisonRector

Change count array comparison to empty array comparison to improve performance
Expand Down
2 changes: 0 additions & 2 deletions config/set/coding-style.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector;
use Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector;
use Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector;
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
use Rector\CodingStyle\Rector\FuncCall\StrictArraySearchRector;
use Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector;
Expand Down Expand Up @@ -57,7 +56,6 @@
TernaryConditionVariableAssignmentRector::class,
SymplifyQuoteEscapeRector::class,
StringClassNameToClassConstantRector::class,
ConsistentPregDelimiterRector::class,
CatchExceptionNameMatchingTypeRector::class,
UseIncrementAssignRector::class,
SplitDoubleAssignRector::class,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Rector\Tests\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector\Fixture;

use PhpParser\Node;
use PhpParser\NodeTraverser;
use PhpParser\NodeVisitor;
use PhpParser\NodeVisitorAbstract;

class SkipAnonymousClass
{
/**
* @param Node|Node[] $nodes
*/
public function traverseNodesWithCallable($nodes, callable $callable): void
{
if (! is_array($nodes)) {
$nodes = $nodes ? [$nodes] : [];
}

$nodeTraverser = new NodeTraverser();
$nodeTraverser->addVisitor($this->createNodeVisitor($callable));
$nodeTraverser->traverse($nodes);
}

private function createNodeVisitor(callable $callable): NodeVisitor
{
return new class($callable) extends NodeVisitorAbstract {
/**
* @var callable
*/
private $callable;

public function __construct(callable $callable)
{
$this->callable = $callable;
}

/**
* @return int|Node|null
*/
public function enterNode(Node $node)
{
$callable = $this->callable;
return $callable($node);
}
};
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading