Skip to content

Commit

Permalink
Updated Rector to commit db16e33a9a72d6c75600187d9f7851060d9a88fe
Browse files Browse the repository at this point in the history
rectorphp/rector-src@db16e33 [EarlyReturn] Remove ReturnBinaryAndToEarlyReturnRector as creates code hard to read and flips condition (#4478)
  • Loading branch information
TomasVotruba committed Jul 11, 2023
1 parent e73319d commit fb5e28c
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 179 deletions.
3 changes: 1 addition & 2 deletions config/set/early-return.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector;
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\EarlyReturn\Rector\StmtsAwareInterface\ReturnEarlyIfVariableRector;
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([ChangeNestedForeachIfsToEarlyContinueRector::class, ChangeAndIfToEarlyReturnRector::class, ChangeIfElseValueAssignToEarlyReturnRector::class, ChangeNestedIfsToEarlyReturnRector::class, RemoveAlwaysElseRector::class, ReturnBinaryAndToEarlyReturnRector::class, ChangeOrIfContinueToMultiContinueRector::class, PreparedValueToEarlyReturnRector::class, ReturnBinaryOrToEarlyReturnRector::class, ReturnEarlyIfVariableRector::class]);
$rectorConfig->rules([ChangeNestedForeachIfsToEarlyContinueRector::class, ChangeAndIfToEarlyReturnRector::class, ChangeIfElseValueAssignToEarlyReturnRector::class, ChangeNestedIfsToEarlyReturnRector::class, RemoveAlwaysElseRector::class, ChangeOrIfContinueToMultiContinueRector::class, PreparedValueToEarlyReturnRector::class, ReturnBinaryOrToEarlyReturnRector::class, ReturnEarlyIfVariableRector::class]);
};
27 changes: 2 additions & 25 deletions docs/rector_rules_overview.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 362 Rules Overview
# 361 Rules Overview

<br>

Expand All @@ -12,7 +12,7 @@

- [DeadCode](#deadcode) (42)

- [EarlyReturn](#earlyreturn) (10)
- [EarlyReturn](#earlyreturn) (9)

- [Naming](#naming) (6)

Expand Down Expand Up @@ -3377,29 +3377,6 @@ Split if statement, when if condition always break execution flow

<br>

### ReturnBinaryAndToEarlyReturnRector

Changes Single return of && to early returns

- class: [`Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector`](../rules/EarlyReturn/Rector/Return_/ReturnBinaryAndToEarlyReturnRector.php)

```diff
class SomeClass
{
public function accept()
{
- return $this->something() && $this->somethingelse();
+ if (! $this->something()) {
+ return false;
+ }
+
+ return (bool) $this->somethingelse();
}
}
```

<br>

### ReturnBinaryOrToEarlyReturnRector

Changes Single return of || to early returns
Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '59b4c8d69f788a36184b69adf06b03e2ab2e8989';
public const PACKAGE_VERSION = 'db16e33a9a72d6c75600187d9f7851060d9a88fe';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-07-11 17:32:32';
public const RELEASE_DATE = '2023-07-11 15:47:43';
/**
* @var int
*/
Expand Down
14 changes: 1 addition & 13 deletions src/NodeManipulator/IfManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Rector\Core\PhpParser\Comparing\NodeComparator;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\Value\ValueResolver;
use Rector\EarlyReturn\NodeTransformer\ConditionInverter;
final class IfManipulator
{
/**
Expand All @@ -34,22 +33,16 @@ final class IfManipulator
* @var \Rector\Core\PhpParser\Node\Value\ValueResolver
*/
private $valueResolver;
/**
* @readonly
* @var \Rector\EarlyReturn\NodeTransformer\ConditionInverter
*/
private $conditionInverter;
/**
* @readonly
* @var \Rector\Core\PhpParser\Comparing\NodeComparator
*/
private $nodeComparator;
public function __construct(BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\StmtsManipulator $stmtsManipulator, ValueResolver $valueResolver, ConditionInverter $conditionInverter, NodeComparator $nodeComparator)
public function __construct(BetterNodeFinder $betterNodeFinder, \Rector\Core\NodeManipulator\StmtsManipulator $stmtsManipulator, ValueResolver $valueResolver, NodeComparator $nodeComparator)
{
$this->betterNodeFinder = $betterNodeFinder;
$this->stmtsManipulator = $stmtsManipulator;
$this->valueResolver = $valueResolver;
$this->conditionInverter = $conditionInverter;
$this->nodeComparator = $nodeComparator;
}
/**
Expand Down Expand Up @@ -175,11 +168,6 @@ public function isIfWithoutElseAndElseIfs(If_ $if) : bool
}
return $if->elseifs === [];
}
public function createIfNegation(Expr $expr, Return_ $return) : If_
{
$expr = $this->conditionInverter->createInvertedCondition($expr);
return new If_($expr, ['stmts' => [$return]]);
}
/**
* @deprecated Create If_ directly, this is simple new with no added value
*/
Expand Down
2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@

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

return ComposerAutoloaderInitbdbcb98a5c11cb94a8c3c305b51a35c3::getLoader();
return ComposerAutoloaderInit8a543d47f349b747b51539c55a747fdb::getLoader();
1 change: 0 additions & 1 deletion vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,6 @@
'Rector\\EarlyReturn\\Rector\\If_\\ChangeOrIfContinueToMultiContinueRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php',
'Rector\\EarlyReturn\\Rector\\If_\\RemoveAlwaysElseRector' => $baseDir . '/rules/EarlyReturn/Rector/If_/RemoveAlwaysElseRector.php',
'Rector\\EarlyReturn\\Rector\\Return_\\PreparedValueToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/Return_/PreparedValueToEarlyReturnRector.php',
'Rector\\EarlyReturn\\Rector\\Return_\\ReturnBinaryAndToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/Return_/ReturnBinaryAndToEarlyReturnRector.php',
'Rector\\EarlyReturn\\Rector\\Return_\\ReturnBinaryOrToEarlyReturnRector' => $baseDir . '/rules/EarlyReturn/Rector/Return_/ReturnBinaryOrToEarlyReturnRector.php',
'Rector\\EarlyReturn\\Rector\\StmtsAwareInterface\\ReturnEarlyIfVariableRector' => $baseDir . '/rules/EarlyReturn/Rector/StmtsAwareInterface/ReturnEarlyIfVariableRector.php',
'Rector\\EarlyReturn\\ValueObject\\BareSingleAssignIf' => $baseDir . '/rules/EarlyReturn/ValueObject/BareSingleAssignIf.php',
Expand Down
10 changes: 5 additions & 5 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitbdbcb98a5c11cb94a8c3c305b51a35c3
class ComposerAutoloaderInit8a543d47f349b747b51539c55a747fdb
{
private static $loader;

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

spl_autoload_register(array('ComposerAutoloaderInitbdbcb98a5c11cb94a8c3c305b51a35c3', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit8a543d47f349b747b51539c55a747fdb', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInitbdbcb98a5c11cb94a8c3c305b51a35c3', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit8a543d47f349b747b51539c55a747fdb', 'loadClassLoader'));

require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit8a543d47f349b747b51539c55a747fdb::getInitializer($loader));

$loader->setClassMapAuthoritative(true);
$loader->register(true);

$filesToLoad = \Composer\Autoload\ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit8a543d47f349b747b51539c55a747fdb::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
9 changes: 4 additions & 5 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Composer\Autoload;

class ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3
class ComposerStaticInit8a543d47f349b747b51539c55a747fdb
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -2154,7 +2154,6 @@ class ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3
'Rector\\EarlyReturn\\Rector\\If_\\ChangeOrIfContinueToMultiContinueRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/ChangeOrIfContinueToMultiContinueRector.php',
'Rector\\EarlyReturn\\Rector\\If_\\RemoveAlwaysElseRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/If_/RemoveAlwaysElseRector.php',
'Rector\\EarlyReturn\\Rector\\Return_\\PreparedValueToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/Return_/PreparedValueToEarlyReturnRector.php',
'Rector\\EarlyReturn\\Rector\\Return_\\ReturnBinaryAndToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/Return_/ReturnBinaryAndToEarlyReturnRector.php',
'Rector\\EarlyReturn\\Rector\\Return_\\ReturnBinaryOrToEarlyReturnRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/Return_/ReturnBinaryOrToEarlyReturnRector.php',
'Rector\\EarlyReturn\\Rector\\StmtsAwareInterface\\ReturnEarlyIfVariableRector' => __DIR__ . '/../..' . '/rules/EarlyReturn/Rector/StmtsAwareInterface/ReturnEarlyIfVariableRector.php',
'Rector\\EarlyReturn\\ValueObject\\BareSingleAssignIf' => __DIR__ . '/../..' . '/rules/EarlyReturn/ValueObject/BareSingleAssignIf.php',
Expand Down Expand Up @@ -3067,9 +3066,9 @@ class ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitbdbcb98a5c11cb94a8c3c305b51a35c3::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit8a543d47f349b747b51539c55a747fdb::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit8a543d47f349b747b51539c55a747fdb::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit8a543d47f349b747b51539c55a747fdb::$classMap;

}, null, ClassLoader::class);
}
Expand Down

0 comments on commit fb5e28c

Please sign in to comment.