Skip to content

Commit

Permalink
Updated Rector to commit 6aeef64
Browse files Browse the repository at this point in the history
rectorphp/rector-src@6aeef64 [CodeQuality] Add ReplaceMultipleBooleanNotRector (#1319)
  • Loading branch information
TomasVotruba committed Nov 26, 2021
1 parent 738852d commit b2791fe
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 19 deletions.
2 changes: 2 additions & 0 deletions config/set/code-quality.php
Expand Up @@ -8,6 +8,7 @@
use Rector\CodeQuality\Rector\Assign\CombinedAssignRector;
use Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector;
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
use Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector;
use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
use Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
Expand Down Expand Up @@ -83,6 +84,7 @@
$services = $containerConfigurator->services();
$services->set(\Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class);
$services->set(\Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class);
$services->set(\Rector\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector::class);
$services->set(\Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class);
$services->set(\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class);
$services->set(\Rector\CodeQuality\Rector\FuncCall\InArrayAndArrayKeysToArrayKeyExistsRector::class);
Expand Down
@@ -0,0 +1,54 @@
<?php

declare (strict_types=1);
namespace Rector\CodeQuality\Rector\BooleanNot;

use PhpParser\Node;
use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Expr\Cast\Bool_;
use Rector\Core\Rector\AbstractRector;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
/**
* @see \Rector\Tests\CodeQuality\Rector\BooleanNot\ReplaceMultipleBooleanNotRector\ReplaceMultipleBooleanNotRectorTest
*/
final class ReplaceMultipleBooleanNotRector extends \Rector\Core\Rector\AbstractRector
{
public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition
{
return new \Symplify\RuleDocGenerator\ValueObject\RuleDefinition('Replace the Double not operator (!!) by type-casting to boolean', [new \Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample(<<<'CODE_SAMPLE'
$bool = !!$var;
CODE_SAMPLE
, <<<'CODE_SAMPLE'
$bool = (bool) $var;
CODE_SAMPLE
)]);
}
/**
* @return array<class-string<Node>>
*/
public function getNodeTypes() : array
{
return [\PhpParser\Node\Expr\BooleanNot::class];
}
/**
* @param BooleanNot $node
*/
public function refactor(\PhpParser\Node $node) : ?\PhpParser\Node
{
$depth = 0;
$expr = $node->expr;
while ($expr instanceof \PhpParser\Node\Expr\BooleanNot) {
++$depth;
$expr = $expr->expr;
}
if ($depth === 0) {
return null;
}
if ($depth % 2 === 0) {
$node->expr = $expr;
return $node;
}
return new \PhpParser\Node\Expr\Cast\Bool_($expr);
}
}
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Expand Up @@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '1255b91c20378fcbab6e086fc056d6eb955a1f98';
public const PACKAGE_VERSION = '6aeef64c72b3c36a9c34473b0cb746264484b531';
/**
* @var string
*/
public const RELEASE_DATE = '2021-11-26 18:03:37';
public const RELEASE_DATE = '2021-11-26 19:57:10';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211126\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer/autoload_real.php';

return ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb::getLoader();
return ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3::getLoader();
1 change: 1 addition & 0 deletions vendor/composer/autoload_classmap.php
Expand Up @@ -1450,6 +1450,7 @@
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => $baseDir . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
'Rector\\CodeQuality\\Rector\\Assign\\SplitListAssignToSeparateLineRector' => $baseDir . '/rules/CodeQuality/Rector/Assign/SplitListAssignToSeparateLineRector.php',
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
'Rector\\CodeQuality\\Rector\\BooleanNot\\ReplaceMultipleBooleanNotRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanNot/ReplaceMultipleBooleanNotRector.php',
'Rector\\CodeQuality\\Rector\\BooleanNot\\SimplifyDeMorganBinaryRector' => $baseDir . '/rules/CodeQuality/Rector/BooleanNot/SimplifyDeMorganBinaryRector.php',
'Rector\\CodeQuality\\Rector\\Catch_\\ThrowWithPreviousExceptionRector' => $baseDir . '/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php',
'Rector\\CodeQuality\\Rector\\ClassMethod\\DateTimeToDateTimeInterfaceRector' => $baseDir . '/rules/CodeQuality/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector.php',
Expand Down
14 changes: 7 additions & 7 deletions vendor/composer/autoload_real.php
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb
class ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3
{
private static $loader;

Expand All @@ -22,15 +22,15 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
Expand All @@ -42,19 +42,19 @@ public static function getLoader()
$loader->register(true);

if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb::$files;
$includeFiles = Composer\Autoload\ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire31b4c805a0b1b6836939c7a901c7a0fb($fileIdentifier, $file);
composerRequiref8293da5b79cfa5fdf8db617d80e5ac3($fileIdentifier, $file);
}

return $loader;
}
}

function composerRequire31b4c805a0b1b6836939c7a901c7a0fb($fileIdentifier, $file)
function composerRequiref8293da5b79cfa5fdf8db617d80e5ac3($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
Expand Down
9 changes: 5 additions & 4 deletions vendor/composer/autoload_static.php
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb
class ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
Expand Down Expand Up @@ -1847,6 +1847,7 @@ class ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb
'Rector\\CodeQuality\\Rector\\Assign\\CombinedAssignRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Assign/CombinedAssignRector.php',
'Rector\\CodeQuality\\Rector\\Assign\\SplitListAssignToSeparateLineRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Assign/SplitListAssignToSeparateLineRector.php',
'Rector\\CodeQuality\\Rector\\BooleanAnd\\SimplifyEmptyArrayCheckRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanAnd/SimplifyEmptyArrayCheckRector.php',
'Rector\\CodeQuality\\Rector\\BooleanNot\\ReplaceMultipleBooleanNotRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanNot/ReplaceMultipleBooleanNotRector.php',
'Rector\\CodeQuality\\Rector\\BooleanNot\\SimplifyDeMorganBinaryRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/BooleanNot/SimplifyDeMorganBinaryRector.php',
'Rector\\CodeQuality\\Rector\\Catch_\\ThrowWithPreviousExceptionRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/Catch_/ThrowWithPreviousExceptionRector.php',
'Rector\\CodeQuality\\Rector\\ClassMethod\\DateTimeToDateTimeInterfaceRector' => __DIR__ . '/../..' . '/rules/CodeQuality/Rector/ClassMethod/DateTimeToDateTimeInterfaceRector.php',
Expand Down Expand Up @@ -3767,9 +3768,9 @@ class ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit31b4c805a0b1b6836939c7a901c7a0fb::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitf8293da5b79cfa5fdf8db617d80e5ac3::$classMap;

}, null, ClassLoader::class);
}
Expand Down
10 changes: 5 additions & 5 deletions vendor/scoper-autoload.php
Expand Up @@ -12,8 +12,8 @@
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20211126\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb', false) && !interface_exists('ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb', false) && !trait_exists('ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb', false)) {
spl_autoload_call('RectorPrefix20211126\ComposerAutoloaderInit31b4c805a0b1b6836939c7a901c7a0fb');
if (!class_exists('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', false) && !interface_exists('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', false) && !trait_exists('ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3', false)) {
spl_autoload_call('RectorPrefix20211126\ComposerAutoloaderInitf8293da5b79cfa5fdf8db617d80e5ac3');
}
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
spl_autoload_call('RectorPrefix20211126\Helmich\TypoScriptParser\Parser\AST\Statement');
Expand Down Expand Up @@ -81,9 +81,9 @@ function print_node() {
return \RectorPrefix20211126\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire31b4c805a0b1b6836939c7a901c7a0fb')) {
function composerRequire31b4c805a0b1b6836939c7a901c7a0fb() {
return \RectorPrefix20211126\composerRequire31b4c805a0b1b6836939c7a901c7a0fb(...func_get_args());
if (!function_exists('composerRequiref8293da5b79cfa5fdf8db617d80e5ac3')) {
function composerRequiref8293da5b79cfa5fdf8db617d80e5ac3() {
return \RectorPrefix20211126\composerRequiref8293da5b79cfa5fdf8db617d80e5ac3(...func_get_args());
}
}
if (!function_exists('scanPath')) {
Expand Down

0 comments on commit b2791fe

Please sign in to comment.