Skip to content

Commit

Permalink
Updated Rector to commit 8f6b3660d0aeee1c44fd9726c97429900863d460
Browse files Browse the repository at this point in the history
rectorphp/rector-src@8f6b366 [Strict] Skip docblock on DisallowedShortTernaryRuleFixerRector (#4639)
  • Loading branch information
TomasVotruba committed Aug 3, 2023
1 parent 32ea38b commit ed1dba1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ final class DisallowedShortTernaryRuleFixerRector extends AbstractFalsyScalarRul
* @var \Rector\Strict\NodeFactory\ExactCompareFactory
*/
private $exactCompareFactory;
/**
* @var bool
*/
private $hasChanged = \false;
public function __construct(ExactCompareFactory $exactCompareFactory)
{
$this->exactCompareFactory = $exactCompareFactory;
Expand Down Expand Up @@ -64,16 +68,20 @@ public function getNodeTypes() : array
*/
public function refactorWithScope(Node $node, Scope $scope) : ?Ternary
{
$this->hasChanged = \false;
// skip non-short ternary
if ($node->if instanceof Expr) {
return null;
}
// special case for reset() function
if ($node->cond instanceof FuncCall && $this->isName($node->cond, 'reset')) {
$this->refactorResetFuncCall($node, $node->cond, $scope);
if (!$this->hasChanged) {
return null;
}
return $node;
}
$exprType = $scope->getType($node->cond);
$exprType = $scope->getNativeType($node->cond);
$compareExpr = $this->exactCompareFactory->createNotIdenticalFalsyCompare($exprType, $node->cond, $this->treatAsNonEmpty);
if (!$compareExpr instanceof Expr) {
return null;
Expand All @@ -89,11 +97,12 @@ private function refactorResetFuncCall(Ternary $ternary, FuncCall $resetFuncCall
return;
}
$firstArgValue = $resetFuncCall->getArgs()[0]->value;
$firstArgType = $scope->getType($firstArgValue);
$firstArgType = $scope->getNativeType($firstArgValue);
$falsyCompareExpr = $this->exactCompareFactory->createNotIdenticalFalsyCompare($firstArgType, $firstArgValue, $this->treatAsNonEmpty);
if (!$falsyCompareExpr instanceof Expr) {
return;
}
$ternary->cond = $falsyCompareExpr;
$this->hasChanged = \true;
}
}
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 = '3c2fab22122dbab967154f433c93c61ec5532de5';
public const PACKAGE_VERSION = '8f6b3660d0aeee1c44fd9726c97429900863d460';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-03 23:52:42';
public const RELEASE_DATE = '2023-08-03 23:59:42';
/**
* @var int
*/
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 ComposerAutoloaderInitfc6ab4c5bef69bf42aa1c48df22fadef::getLoader();
return ComposerAutoloaderInit7821f85399c2831bc3d31048dd9e8c2c::getLoader();
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 ComposerAutoloaderInitfc6ab4c5bef69bf42aa1c48df22fadef
class ComposerAutoloaderInit7821f85399c2831bc3d31048dd9e8c2c
{
private static $loader;

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

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

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

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

$filesToLoad = \Composer\Autoload\ComposerStaticInitfc6ab4c5bef69bf42aa1c48df22fadef::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit7821f85399c2831bc3d31048dd9e8c2c::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
Expand Down
8 changes: 4 additions & 4 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 ComposerStaticInitfc6ab4c5bef69bf42aa1c48df22fadef
class ComposerStaticInit7821f85399c2831bc3d31048dd9e8c2c
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
Expand Down Expand Up @@ -3025,9 +3025,9 @@ class ComposerStaticInitfc6ab4c5bef69bf42aa1c48df22fadef
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitfc6ab4c5bef69bf42aa1c48df22fadef::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitfc6ab4c5bef69bf42aa1c48df22fadef::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInitfc6ab4c5bef69bf42aa1c48df22fadef::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit7821f85399c2831bc3d31048dd9e8c2c::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit7821f85399c2831bc3d31048dd9e8c2c::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit7821f85399c2831bc3d31048dd9e8c2c::$classMap;

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

0 comments on commit ed1dba1

Please sign in to comment.