Prep Plugin for release on WordPress.org (#23)
* Update translation text domain * Escape everything that should be escaped. * Add nonce checks where needed. * Sanitize all inputs. * Apply Code style changes across the codebase. * Correct many deprecation notices. * Optimize load order of many filters. * Add Proper Build script * Use emojii flags * Fix i18n deprecation notice for translating too early * Put all scripts in footer and load async
This commit is contained in:
@ -18,21 +18,19 @@ use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
/**
|
||||
* @see \Rector\Tests\TypeDeclaration\Rector\YodaConditionsRector\YodaConditionsRectorTest
|
||||
*/
|
||||
final class YodaConditionsRector extends AbstractRector
|
||||
{
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes(): array
|
||||
{
|
||||
return [Equal::class, NotEqual::class, Identical::class, NotIdentical::class];
|
||||
}
|
||||
final class YodaConditionsRector extends AbstractRector {
|
||||
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
/**
|
||||
* @return array<class-string<Node>>
|
||||
*/
|
||||
public function getNodeTypes(): array {
|
||||
return [Equal::class, NotEqual::class, Identical::class, NotIdentical::class];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \PhpParser\Node\Stmt\Class_ $node
|
||||
*/
|
||||
public function refactor(Node $node): ?Node {
|
||||
// Ensure the left operand is not a constant
|
||||
if ((
|
||||
$node->left instanceof Node\Expr\Variable ||
|
||||
@ -47,6 +45,6 @@ final class YodaConditionsRector extends AbstractRector
|
||||
$this->mirrorComments($node->right, $node->left);
|
||||
[$node->left, $node->right] = [$node->right, $node->left];
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
@ -6,23 +6,20 @@ namespace Rector\Tests\TypeDeclaration\Rector\YodaConditionsRector;
|
||||
|
||||
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
|
||||
|
||||
final class YodaConditionsRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(string $filePath): void
|
||||
{
|
||||
$this->doTestFile($filePath);
|
||||
}
|
||||
final class YodaConditionsRectorTest extends AbstractRectorTestCase {
|
||||
|
||||
public static function provideData(): \Iterator
|
||||
{
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
/**
|
||||
* @dataProvider provideData()
|
||||
*/
|
||||
public function test(string $filePath): void {
|
||||
$this->doTestFile($filePath);
|
||||
}
|
||||
|
||||
public function provideConfigFilePath(): string
|
||||
{
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
public static function provideData(): \Iterator {
|
||||
return self::yieldFilesFromDirectory(__DIR__ . '/Fixture');
|
||||
}
|
||||
|
||||
public function provideConfigFilePath(): string {
|
||||
return __DIR__ . '/config/configured_rule.php';
|
||||
}
|
||||
}
|
||||
|
@ -5,5 +5,5 @@ declare(strict_types=1);
|
||||
use Rector\Config\RectorConfig;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
$rectorConfig->rule(\Utils\Rector\Rector\YodaConditionsRector::class);
|
||||
$rectorConfig->rule(\Utils\Rector\Rector\YodaConditionsRector::class);
|
||||
};
|
||||
|
Reference in New Issue
Block a user