Updated Rector to commit f6090319c24eb98de56d09353c24b5c30da9e7fc

f6090319c2 [PHPStan] Reduce PHPStan errors for narrow public - take 3 (#2674)
This commit is contained in:
Tomas Votruba 2022-07-17 12:27:00 +00:00
parent da70700f98
commit ce84017a24
15 changed files with 46 additions and 25 deletions

View File

@ -108,6 +108,9 @@ final class PhpDocInfo
$this->isSingleLine = \true;
}
}
/**
* @api
*/
public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode) : void
{
$this->phpDocNode->children[] = $phpDocChildNode;

View File

@ -48,6 +48,9 @@ final class VarAnnotationManipulator
$phpDocInfo->addTagValueNode($varTagValueNode);
$phpDocInfo->makeSingleLined();
}
/**
* @api
*/
public function decorateNodeWithType(Node $node, Type $staticType) : void
{
if ($staticType instanceof MixedType) {

View File

@ -19,6 +19,7 @@ final class BinaryOpConditionsCollector
* Similarly, for right-associative operations (e.g. `a ?? b ?? c`), the result produced by
* the implicit parenthesization (`[a, b ?? c]`) might not match the expectations.
*
* @api
* @param class-string<BinaryOp> $binaryOpClass
* @return array<int, Expr>
*/

View File

@ -22,6 +22,9 @@ final class CustomPHPStanDetector
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
}
/**
* @api
*/
public function isCustomType(Type $definedType, Node $node) : bool
{
if (!$definedType instanceof NonExistingObjectType) {

View File

@ -97,9 +97,9 @@ final class ClassMethodReturnTypeOverrideGuard
}
return $this->hasClassMethodExprReturn($classMethod);
}
public function shouldSkipClassMethodOldTypeWithNewType(Type $oldType, Type $newType, Node $node) : bool
public function shouldSkipClassMethodOldTypeWithNewType(Type $oldType, Type $newType, ClassMethod $classMethod) : bool
{
if ($this->customPHPStanDetector->isCustomType($oldType, $node)) {
if ($this->customPHPStanDetector->isCustomType($oldType, $classMethod)) {
return \true;
}
if ($oldType instanceof MixedType) {

View File

@ -4,12 +4,12 @@ declare (strict_types=1);
namespace Rector\DeadCode\TypeNodeAnalyzer;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
final class GenericTypeNodeAnalyzer
{
public function hasGenericType(UnionTypeNode $unionTypeNode) : bool
public function hasGenericType(BracketsAwareUnionTypeNode $bracketsAwareUnionTypeNode) : bool
{
$types = $unionTypeNode->types;
$types = $bracketsAwareUnionTypeNode->types;
foreach ($types as $type) {
if ($type instanceof GenericTypeNode) {
return \true;

View File

@ -120,6 +120,7 @@ final class AnonymousFunctionFactory
$this->inlineCodeParser = $inlineCodeParser;
}
/**
* @api
* @param Param[] $params
* @param Stmt[] $stmts
* @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|\PhpParser\Node\ComplexType|null $returnTypeNode

View File

@ -17,12 +17,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'ce32685688660a000848322caadcf336bfc282f8';
public const PACKAGE_VERSION = 'f6090319c24eb98de56d09353c24b5c30da9e7fc';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2022-07-17 03:11:17';
public const RELEASE_DATE = '2022-07-17 14:22:06';
/**
* @var int
*/

View File

@ -34,7 +34,10 @@ final class ExclusionManager
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
}
public function isNodeSkippedByRector(Node $node, PhpRectorInterface $phpRector) : bool
/**
* @param class-string<PhpRectorInterface> $rectorClass
*/
public function isNodeSkippedByRector(Node $node, string $rectorClass) : bool
{
if ($node instanceof PropertyProperty || $node instanceof Const_) {
$node = $node->getAttribute(AttributeKey::PARENT_NODE);
@ -42,7 +45,7 @@ final class ExclusionManager
return \false;
}
}
if ($this->hasNoRectorPhpDocTagMatch($node, $phpRector)) {
if ($this->hasNoRectorPhpDocTagMatch($node, $rectorClass)) {
return \true;
}
if ($node instanceof Stmt) {
@ -53,14 +56,16 @@ final class ExclusionManager
if ($parentNode === null) {
return \false;
}
return $this->isNodeSkippedByRector($parentNode, $phpRector);
return $this->isNodeSkippedByRector($parentNode, $rectorClass);
}
private function hasNoRectorPhpDocTagMatch(Node $node, PhpRectorInterface $phpRector) : bool
/**
* @param class-string<PhpRectorInterface> $rectorClass
*/
private function hasNoRectorPhpDocTagMatch(Node $node, string $rectorClass) : bool
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
/** @var PhpDocTagNode[] $noRectorTags */
$noRectorTags = \array_merge($phpDocInfo->getTagsByName('noRector'), $phpDocInfo->getTagsByName('norector'));
$rectorClass = \get_class($phpRector);
if ($this->matchesNoRectorTag($noRectorTags, $rectorClass)) {
return \true;
}

View File

@ -157,6 +157,7 @@ final class BetterNodeFinder
return $this->findVariableOfName($nodes, $name) instanceof Node;
}
/**
* @api
* @param \PhpParser\Node|mixed[] $nodes
* @return Variable|null
*/
@ -302,6 +303,7 @@ final class BetterNodeFinder
return null;
}
/**
* @api
* @template T of Node
* @param array<class-string<T>> $types
*/

View File

@ -444,6 +444,9 @@ final class NodeFactory
}
return $this->createBooleanAndFromNodes($newNodes);
}
/**
* @api
*/
public function createClassConstant(string $name, Expr $expr, int $modifier) : ClassConst
{
$expr = BuilderHelpers::normalizeValue($expr);

View File

@ -329,7 +329,7 @@ CODE_SAMPLE;
if ($this->nodesToRemoveCollector->isNodeRemoved($node)) {
return \true;
}
if ($this->exclusionManager->isNodeSkippedByRector($node, $this)) {
if ($this->exclusionManager->isNodeSkippedByRector($node, static::class)) {
return \true;
}
$smartFileInfo = $this->file->getSmartFileInfo();

2
vendor/autoload.php vendored
View File

@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01::getLoader();
return ComposerAutoloaderInit89237dd5b5cd25462a2d0b4006201be0::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01
class ComposerAutoloaderInit89237dd5b5cd25462a2d0b4006201be0
{
private static $loader;
@ -22,19 +22,19 @@ class ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit89237dd5b5cd25462a2d0b4006201be0', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit89237dd5b5cd25462a2d0b4006201be0', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$files;
$includeFiles = \Composer\Autoload\ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire227a1866e9ea4ee32c5211f8e530ed01($fileIdentifier, $file);
composerRequire89237dd5b5cd25462a2d0b4006201be0($fileIdentifier, $file);
}
return $loader;
@ -46,7 +46,7 @@ class ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01
* @param string $file
* @return void
*/
function composerRequire227a1866e9ea4ee32c5211f8e530ed01($fileIdentifier, $file)
function composerRequire89237dd5b5cd25462a2d0b4006201be0($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01
class ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0
{
public static $files = array (
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
@ -3416,9 +3416,9 @@ class ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$classMap;
}, null, ClassLoader::class);
}