mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-16 08:02:23 +00:00
Updated Rector to commit f6090319c24eb98de56d09353c24b5c30da9e7fc
f6090319c2
[PHPStan] Reduce PHPStan errors for narrow public - take 3 (#2674)
This commit is contained in:
parent
da70700f98
commit
ce84017a24
|
@ -108,6 +108,9 @@ final class PhpDocInfo
|
||||||
$this->isSingleLine = \true;
|
$this->isSingleLine = \true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode) : void
|
public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode) : void
|
||||||
{
|
{
|
||||||
$this->phpDocNode->children[] = $phpDocChildNode;
|
$this->phpDocNode->children[] = $phpDocChildNode;
|
||||||
|
|
|
@ -48,6 +48,9 @@ final class VarAnnotationManipulator
|
||||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
$phpDocInfo->addTagValueNode($varTagValueNode);
|
||||||
$phpDocInfo->makeSingleLined();
|
$phpDocInfo->makeSingleLined();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
public function decorateNodeWithType(Node $node, Type $staticType) : void
|
public function decorateNodeWithType(Node $node, Type $staticType) : void
|
||||||
{
|
{
|
||||||
if ($staticType instanceof MixedType) {
|
if ($staticType instanceof MixedType) {
|
||||||
|
|
|
@ -19,6 +19,7 @@ final class BinaryOpConditionsCollector
|
||||||
* Similarly, for right-associative operations (e.g. `a ?? b ?? c`), the result produced by
|
* 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.
|
* the implicit parenthesization (`[a, b ?? c]`) might not match the expectations.
|
||||||
*
|
*
|
||||||
|
* @api
|
||||||
* @param class-string<BinaryOp> $binaryOpClass
|
* @param class-string<BinaryOp> $binaryOpClass
|
||||||
* @return array<int, Expr>
|
* @return array<int, Expr>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,6 +22,9 @@ final class CustomPHPStanDetector
|
||||||
{
|
{
|
||||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
public function isCustomType(Type $definedType, Node $node) : bool
|
public function isCustomType(Type $definedType, Node $node) : bool
|
||||||
{
|
{
|
||||||
if (!$definedType instanceof NonExistingObjectType) {
|
if (!$definedType instanceof NonExistingObjectType) {
|
||||||
|
|
|
@ -97,9 +97,9 @@ final class ClassMethodReturnTypeOverrideGuard
|
||||||
}
|
}
|
||||||
return $this->hasClassMethodExprReturn($classMethod);
|
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;
|
return \true;
|
||||||
}
|
}
|
||||||
if ($oldType instanceof MixedType) {
|
if ($oldType instanceof MixedType) {
|
||||||
|
|
|
@ -4,12 +4,12 @@ declare (strict_types=1);
|
||||||
namespace Rector\DeadCode\TypeNodeAnalyzer;
|
namespace Rector\DeadCode\TypeNodeAnalyzer;
|
||||||
|
|
||||||
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
|
||||||
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
|
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
||||||
final class GenericTypeNodeAnalyzer
|
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) {
|
foreach ($types as $type) {
|
||||||
if ($type instanceof GenericTypeNode) {
|
if ($type instanceof GenericTypeNode) {
|
||||||
return \true;
|
return \true;
|
||||||
|
|
|
@ -120,6 +120,7 @@ final class AnonymousFunctionFactory
|
||||||
$this->inlineCodeParser = $inlineCodeParser;
|
$this->inlineCodeParser = $inlineCodeParser;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* @api
|
||||||
* @param Param[] $params
|
* @param Param[] $params
|
||||||
* @param Stmt[] $stmts
|
* @param Stmt[] $stmts
|
||||||
* @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|\PhpParser\Node\ComplexType|null $returnTypeNode
|
* @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|\PhpParser\Node\ComplexType|null $returnTypeNode
|
||||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const PACKAGE_VERSION = 'ce32685688660a000848322caadcf336bfc282f8';
|
public const PACKAGE_VERSION = 'f6090319c24eb98de56d09353c24b5c30da9e7fc';
|
||||||
/**
|
/**
|
||||||
* @api
|
* @api
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public const RELEASE_DATE = '2022-07-17 03:11:17';
|
public const RELEASE_DATE = '2022-07-17 14:22:06';
|
||||||
/**
|
/**
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,7 +34,10 @@ final class ExclusionManager
|
||||||
{
|
{
|
||||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
$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_) {
|
if ($node instanceof PropertyProperty || $node instanceof Const_) {
|
||||||
$node = $node->getAttribute(AttributeKey::PARENT_NODE);
|
$node = $node->getAttribute(AttributeKey::PARENT_NODE);
|
||||||
|
@ -42,7 +45,7 @@ final class ExclusionManager
|
||||||
return \false;
|
return \false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->hasNoRectorPhpDocTagMatch($node, $phpRector)) {
|
if ($this->hasNoRectorPhpDocTagMatch($node, $rectorClass)) {
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
if ($node instanceof Stmt) {
|
if ($node instanceof Stmt) {
|
||||||
|
@ -53,14 +56,16 @@ final class ExclusionManager
|
||||||
if ($parentNode === null) {
|
if ($parentNode === null) {
|
||||||
return \false;
|
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);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||||
/** @var PhpDocTagNode[] $noRectorTags */
|
/** @var PhpDocTagNode[] $noRectorTags */
|
||||||
$noRectorTags = \array_merge($phpDocInfo->getTagsByName('noRector'), $phpDocInfo->getTagsByName('norector'));
|
$noRectorTags = \array_merge($phpDocInfo->getTagsByName('noRector'), $phpDocInfo->getTagsByName('norector'));
|
||||||
$rectorClass = \get_class($phpRector);
|
|
||||||
if ($this->matchesNoRectorTag($noRectorTags, $rectorClass)) {
|
if ($this->matchesNoRectorTag($noRectorTags, $rectorClass)) {
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,6 +157,7 @@ final class BetterNodeFinder
|
||||||
return $this->findVariableOfName($nodes, $name) instanceof Node;
|
return $this->findVariableOfName($nodes, $name) instanceof Node;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* @api
|
||||||
* @param \PhpParser\Node|mixed[] $nodes
|
* @param \PhpParser\Node|mixed[] $nodes
|
||||||
* @return Variable|null
|
* @return Variable|null
|
||||||
*/
|
*/
|
||||||
|
@ -302,6 +303,7 @@ final class BetterNodeFinder
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
* @api
|
||||||
* @template T of Node
|
* @template T of Node
|
||||||
* @param array<class-string<T>> $types
|
* @param array<class-string<T>> $types
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -444,6 +444,9 @@ final class NodeFactory
|
||||||
}
|
}
|
||||||
return $this->createBooleanAndFromNodes($newNodes);
|
return $this->createBooleanAndFromNodes($newNodes);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @api
|
||||||
|
*/
|
||||||
public function createClassConstant(string $name, Expr $expr, int $modifier) : ClassConst
|
public function createClassConstant(string $name, Expr $expr, int $modifier) : ClassConst
|
||||||
{
|
{
|
||||||
$expr = BuilderHelpers::normalizeValue($expr);
|
$expr = BuilderHelpers::normalizeValue($expr);
|
||||||
|
|
|
@ -329,7 +329,7 @@ CODE_SAMPLE;
|
||||||
if ($this->nodesToRemoveCollector->isNodeRemoved($node)) {
|
if ($this->nodesToRemoveCollector->isNodeRemoved($node)) {
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
if ($this->exclusionManager->isNodeSkippedByRector($node, $this)) {
|
if ($this->exclusionManager->isNodeSkippedByRector($node, static::class)) {
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
$smartFileInfo = $this->file->getSmartFileInfo();
|
$smartFileInfo = $this->file->getSmartFileInfo();
|
||||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||||
|
|
||||||
require_once __DIR__ . '/composer/autoload_real.php';
|
require_once __DIR__ . '/composer/autoload_real.php';
|
||||||
|
|
||||||
return ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01::getLoader();
|
return ComposerAutoloaderInit89237dd5b5cd25462a2d0b4006201be0::getLoader();
|
||||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
// autoload_real.php @generated by Composer
|
// autoload_real.php @generated by Composer
|
||||||
|
|
||||||
class ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01
|
class ComposerAutoloaderInit89237dd5b5cd25462a2d0b4006201be0
|
||||||
{
|
{
|
||||||
private static $loader;
|
private static $loader;
|
||||||
|
|
||||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01
|
||||||
return self::$loader;
|
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__));
|
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';
|
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->setClassMapAuthoritative(true);
|
||||||
$loader->register(true);
|
$loader->register(true);
|
||||||
|
|
||||||
$includeFiles = \Composer\Autoload\ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$files;
|
$includeFiles = \Composer\Autoload\ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$files;
|
||||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||||
composerRequire227a1866e9ea4ee32c5211f8e530ed01($fileIdentifier, $file);
|
composerRequire89237dd5b5cd25462a2d0b4006201be0($fileIdentifier, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $loader;
|
return $loader;
|
||||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInit227a1866e9ea4ee32c5211f8e530ed01
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function composerRequire227a1866e9ea4ee32c5211f8e530ed01($fileIdentifier, $file)
|
function composerRequire89237dd5b5cd25462a2d0b4006201be0($fileIdentifier, $file)
|
||||||
{
|
{
|
||||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||||
|
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
namespace Composer\Autoload;
|
namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01
|
class ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0
|
||||||
{
|
{
|
||||||
public static $files = array (
|
public static $files = array (
|
||||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||||
|
@ -3416,9 +3416,9 @@ class ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01
|
||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$prefixLengthsPsr4;
|
$loader->prefixLengthsPsr4 = ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$prefixLengthsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInit227a1866e9ea4ee32c5211f8e530ed01::$classMap;
|
$loader->classMap = ComposerStaticInit89237dd5b5cd25462a2d0b4006201be0::$classMap;
|
||||||
|
|
||||||
}, null, ClassLoader::class);
|
}, null, ClassLoader::class);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user