mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-04 02:10:51 +00:00
Updated Rector to commit 99ac0029803859361b510f46cf13bb88153367ee
99ac002980
[TypeDeclaration] Skip void return on AddArrowFunctionReturnTypeRector (#3167)
This commit is contained in:
parent
50000ad3ec
commit
e381b4574f
|
@ -5,6 +5,7 @@ namespace Rector\TypeDeclaration\Rector\ArrowFunction;
|
|||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\ArrowFunction;
|
||||
use PHPStan\Type\VoidType;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\PHPStanStaticTypeMapper\Enum\TypeKind;
|
||||
|
@ -42,6 +43,9 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
$type = $this->getType($node->expr);
|
||||
if ($type instanceof VoidType) {
|
||||
return null;
|
||||
}
|
||||
$returnTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::RETURN);
|
||||
if ($returnTypeNode === null) {
|
||||
return null;
|
||||
|
|
|
@ -17,12 +17,12 @@ final class VersionResolver
|
|||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'b8aff0861788200f2e098191118d1e5e8948a242';
|
||||
public const PACKAGE_VERSION = '99ac0029803859361b510f46cf13bb88153367ee';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-12-07 16:27:36';
|
||||
public const RELEASE_DATE = '2022-12-07 18:09:31';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitdd1c9fbc0381d38245b3815a3cf777f9::getLoader();
|
||||
return ComposerAutoloaderInitfa4f15722bdd75bff874936242e27b3b::getLoader();
|
||||
|
|
2
vendor/composer/autoload_classmap.php
vendored
2
vendor/composer/autoload_classmap.php
vendored
|
@ -79,6 +79,8 @@ return array(
|
|||
'PHPStan\\Rules\\PHPUnit\\ClassCoversExistsRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ClassCoversExistsRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\ClassMethodCoversExistsRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ClassMethodCoversExistsRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\CoversHelper' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/CoversHelper.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\DataProviderDeclarationRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderDeclarationRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\DataProviderHelper' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderHelper.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\MockMethodCallRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/MockMethodCallRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\NoMissingSpaceInClassAnnotationRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/NoMissingSpaceInClassAnnotationRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\NoMissingSpaceInMethodAnnotationRule' => $vendorDir . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/NoMissingSpaceInMethodAnnotationRule.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitdd1c9fbc0381d38245b3815a3cf777f9
|
||||
class ComposerAutoloaderInitfa4f15722bdd75bff874936242e27b3b
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInitdd1c9fbc0381d38245b3815a3cf777f9
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitdd1c9fbc0381d38245b3815a3cf777f9', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitfa4f15722bdd75bff874936242e27b3b', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitdd1c9fbc0381d38245b3815a3cf777f9', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitfa4f15722bdd75bff874936242e27b3b', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitfa4f15722bdd75bff874936242e27b3b::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitfa4f15722bdd75bff874936242e27b3b::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequiredd1c9fbc0381d38245b3815a3cf777f9($fileIdentifier, $file);
|
||||
composerRequirefa4f15722bdd75bff874936242e27b3b($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInitdd1c9fbc0381d38245b3815a3cf777f9
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequiredd1c9fbc0381d38245b3815a3cf777f9($fileIdentifier, $file)
|
||||
function composerRequirefa4f15722bdd75bff874936242e27b3b($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
10
vendor/composer/autoload_static.php
vendored
10
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9
|
||||
class ComposerStaticInitfa4f15722bdd75bff874936242e27b3b
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
|
@ -319,6 +319,8 @@ class ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9
|
|||
'PHPStan\\Rules\\PHPUnit\\ClassCoversExistsRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ClassCoversExistsRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\ClassMethodCoversExistsRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/ClassMethodCoversExistsRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\CoversHelper' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/CoversHelper.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\DataProviderDeclarationRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderDeclarationRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\DataProviderHelper' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderHelper.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\MockMethodCallRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/MockMethodCallRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\NoMissingSpaceInClassAnnotationRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/NoMissingSpaceInClassAnnotationRule.php',
|
||||
'PHPStan\\Rules\\PHPUnit\\NoMissingSpaceInMethodAnnotationRule' => __DIR__ . '/..' . '/phpstan/phpstan-phpunit/src/Rules/PHPUnit/NoMissingSpaceInMethodAnnotationRule.php',
|
||||
|
@ -3018,9 +3020,9 @@ class ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitdd1c9fbc0381d38245b3815a3cf777f9::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitfa4f15722bdd75bff874936242e27b3b::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitfa4f15722bdd75bff874936242e27b3b::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitfa4f15722bdd75bff874936242e27b3b::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
16
vendor/composer/installed.json
vendored
16
vendor/composer/installed.json
vendored
|
@ -795,22 +795,22 @@
|
|||
},
|
||||
{
|
||||
"name": "phpstan\/phpstan-phpunit",
|
||||
"version": "1.2.2",
|
||||
"version_normalized": "1.2.2.0",
|
||||
"version": "1.3.0",
|
||||
"version_normalized": "1.3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/phpstan\/phpstan-phpunit.git",
|
||||
"reference": "dea1f87344c6964c607d9076dee42d891f3923f0"
|
||||
"reference": "4c06b7e3f2c40081334d86975350dda814bd064a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan-phpunit\/zipball\/dea1f87344c6964c607d9076dee42d891f3923f0",
|
||||
"reference": "dea1f87344c6964c607d9076dee42d891f3923f0",
|
||||
"url": "https:\/\/api.github.com\/repos\/phpstan\/phpstan-phpunit\/zipball\/4c06b7e3f2c40081334d86975350dda814bd064a",
|
||||
"reference": "4c06b7e3f2c40081334d86975350dda814bd064a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0",
|
||||
"phpstan\/phpstan": "^1.8.11"
|
||||
"phpstan\/phpstan": "^1.9.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit\/phpunit": "<7.0"
|
||||
|
@ -821,7 +821,7 @@
|
|||
"phpstan\/phpstan-strict-rules": "^1.0",
|
||||
"phpunit\/phpunit": "^9.5"
|
||||
},
|
||||
"time": "2022-10-28T10:23:07+00:00",
|
||||
"time": "2022-12-07T15:46:24+00:00",
|
||||
"type": "phpstan-extension",
|
||||
"extra": {
|
||||
"phpstan": {
|
||||
|
@ -844,7 +844,7 @@
|
|||
"description": "PHPUnit extensions and rules for PHPStan",
|
||||
"support": {
|
||||
"issues": "https:\/\/github.com\/phpstan\/phpstan-phpunit\/issues",
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan-phpunit\/tree\/1.2.2"
|
||||
"source": "https:\/\/github.com\/phpstan\/phpstan-phpunit\/tree\/1.3.0"
|
||||
},
|
||||
"install-path": "..\/phpstan\/phpstan-phpunit"
|
||||
},
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
2
vendor/phpstan/phpstan-phpunit/composer.json
vendored
2
vendor/phpstan/phpstan-phpunit/composer.json
vendored
|
@ -7,7 +7,7 @@
|
|||
],
|
||||
"require": {
|
||||
"php": "^7.2 || ^8.0",
|
||||
"phpstan\/phpstan": "^1.8.11"
|
||||
"phpstan\/phpstan": "^1.9.0"
|
||||
},
|
||||
"conflict": {
|
||||
"phpunit\/phpunit": "<7.0"
|
||||
|
|
|
@ -55,6 +55,8 @@ services:
|
|||
class: PHPStan\Rules\PHPUnit\CoversHelper
|
||||
-
|
||||
class: PHPStan\Rules\PHPUnit\AnnotationHelper
|
||||
-
|
||||
class: PHPStan\Rules\PHPUnit\DataProviderHelper
|
||||
|
||||
conditionalTags:
|
||||
PHPStan\PhpDoc\PHPUnit\MockObjectTypeNodeResolverExtension:
|
||||
|
|
6
vendor/phpstan/phpstan-phpunit/rules.neon
vendored
6
vendor/phpstan/phpstan-phpunit/rules.neon
vendored
|
@ -8,6 +8,10 @@ rules:
|
|||
services:
|
||||
- class: PHPStan\Rules\PHPUnit\ClassCoversExistsRule
|
||||
- class: PHPStan\Rules\PHPUnit\ClassMethodCoversExistsRule
|
||||
-
|
||||
class: PHPStan\Rules\PHPUnit\DataProviderDeclarationRule
|
||||
arguments:
|
||||
checkFunctionNameCase: %checkFunctionNameCase%
|
||||
- class: PHPStan\Rules\PHPUnit\NoMissingSpaceInClassAnnotationRule
|
||||
- class: PHPStan\Rules\PHPUnit\NoMissingSpaceInMethodAnnotationRule
|
||||
|
||||
|
@ -16,6 +20,8 @@ conditionalTags:
|
|||
phpstan.rules.rule: %featureToggles.bleedingEdge%
|
||||
PHPStan\Rules\PHPUnit\ClassMethodCoversExistsRule:
|
||||
phpstan.rules.rule: %featureToggles.bleedingEdge%
|
||||
PHPStan\Rules\PHPUnit\DataProviderDeclarationRule:
|
||||
phpstan.rules.rule: %featureToggles.bleedingEdge%
|
||||
PHPStan\Rules\PHPUnit\NoMissingSpaceInClassAnnotationRule:
|
||||
phpstan.rules.rule: %featureToggles.bleedingEdge%
|
||||
PHPStan\Rules\PHPUnit\NoMissingSpaceInMethodAnnotationRule:
|
||||
|
|
63
vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderDeclarationRule.php
vendored
Normal file
63
vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderDeclarationRule.php
vendored
Normal file
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace PHPStan\Rules\PHPUnit;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Rules\Rule;
|
||||
use PHPStan\Type\FileTypeMapper;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use function array_merge;
|
||||
/**
|
||||
* @implements Rule<Node\Stmt\ClassMethod>
|
||||
*/
|
||||
class DataProviderDeclarationRule implements Rule
|
||||
{
|
||||
/**
|
||||
* Data provider helper.
|
||||
*
|
||||
* @var DataProviderHelper
|
||||
*/
|
||||
private $dataProviderHelper;
|
||||
/**
|
||||
* The file type mapper.
|
||||
*
|
||||
* @var FileTypeMapper
|
||||
*/
|
||||
private $fileTypeMapper;
|
||||
/**
|
||||
* When set to true, it reports data provider method with incorrect name case.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $checkFunctionNameCase;
|
||||
public function __construct(\PHPStan\Rules\PHPUnit\DataProviderHelper $dataProviderHelper, FileTypeMapper $fileTypeMapper, bool $checkFunctionNameCase)
|
||||
{
|
||||
$this->dataProviderHelper = $dataProviderHelper;
|
||||
$this->fileTypeMapper = $fileTypeMapper;
|
||||
$this->checkFunctionNameCase = $checkFunctionNameCase;
|
||||
}
|
||||
public function getNodeType() : string
|
||||
{
|
||||
return Node\Stmt\ClassMethod::class;
|
||||
}
|
||||
public function processNode(Node $node, Scope $scope) : array
|
||||
{
|
||||
$classReflection = $scope->getClassReflection();
|
||||
if ($classReflection === null || !$classReflection->isSubclassOf(TestCase::class)) {
|
||||
return [];
|
||||
}
|
||||
$docComment = $node->getDocComment();
|
||||
if ($docComment === null) {
|
||||
return [];
|
||||
}
|
||||
$methodPhpDoc = $this->fileTypeMapper->getResolvedPhpDoc($scope->getFile(), $classReflection->getName(), $scope->isInTrait() ? $scope->getTraitReflection()->getName() : null, $node->name->toString(), $docComment->getText());
|
||||
$annotations = $this->dataProviderHelper->getDataProviderAnnotations($methodPhpDoc);
|
||||
$errors = [];
|
||||
foreach ($annotations as $annotation) {
|
||||
$errors = array_merge($errors, $this->dataProviderHelper->processDataProvider($scope, $annotation, $this->checkFunctionNameCase));
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
}
|
69
vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderHelper.php
vendored
Normal file
69
vendor/phpstan/phpstan-phpunit/src/Rules/PHPUnit/DataProviderHelper.php
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace PHPStan\Rules\PHPUnit;
|
||||
|
||||
use PHPStan\Analyser\Scope;
|
||||
use PHPStan\PhpDoc\ResolvedPhpDocBlock;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
use PHPStan\Reflection\MissingMethodFromReflectionException;
|
||||
use PHPStan\Rules\RuleError;
|
||||
use PHPStan\Rules\RuleErrorBuilder;
|
||||
use function array_merge;
|
||||
use function preg_match;
|
||||
use function sprintf;
|
||||
class DataProviderHelper
|
||||
{
|
||||
/**
|
||||
* @return array<PhpDocTagNode>
|
||||
*/
|
||||
public function getDataProviderAnnotations(?ResolvedPhpDocBlock $phpDoc) : array
|
||||
{
|
||||
if ($phpDoc === null) {
|
||||
return [];
|
||||
}
|
||||
$phpDocNodes = $phpDoc->getPhpDocNodes();
|
||||
$annotations = [];
|
||||
foreach ($phpDocNodes as $docNode) {
|
||||
$annotations = array_merge($annotations, $docNode->getTagsByName('@dataProvider'));
|
||||
}
|
||||
return $annotations;
|
||||
}
|
||||
/**
|
||||
* @return RuleError[] errors
|
||||
*/
|
||||
public function processDataProvider(Scope $scope, PhpDocTagNode $phpDocTag, bool $checkFunctionNameCase) : array
|
||||
{
|
||||
$dataProviderName = $this->getDataProviderName($phpDocTag);
|
||||
if ($dataProviderName === null) {
|
||||
// Missing name is already handled in NoMissingSpaceInMethodAnnotationRule
|
||||
return [];
|
||||
}
|
||||
$classReflection = $scope->getClassReflection();
|
||||
if ($classReflection === null) {
|
||||
// Should not happen
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
$dataProviderMethodReflection = $classReflection->getNativeMethod($dataProviderName);
|
||||
} catch (MissingMethodFromReflectionException $missingMethodFromReflectionException) {
|
||||
$error = RuleErrorBuilder::message(sprintf('@dataProvider %s related method not found.', $dataProviderName))->build();
|
||||
return [$error];
|
||||
}
|
||||
$errors = [];
|
||||
if ($checkFunctionNameCase && $dataProviderName !== $dataProviderMethodReflection->getName()) {
|
||||
$errors[] = RuleErrorBuilder::message(sprintf('@dataProvider %s related method is used with incorrect case: %s.', $dataProviderName, $dataProviderMethodReflection->getName()))->build();
|
||||
}
|
||||
if (!$dataProviderMethodReflection->isPublic()) {
|
||||
$errors[] = RuleErrorBuilder::message(sprintf('@dataProvider %s related method must be public.', $dataProviderName))->build();
|
||||
}
|
||||
return $errors;
|
||||
}
|
||||
private function getDataProviderName(PhpDocTagNode $phpDocTag) : ?string
|
||||
{
|
||||
if (preg_match('/^[^ \\t]+/', (string) $phpDocTag->value, $matches) !== 1) {
|
||||
return null;
|
||||
}
|
||||
return $matches[0];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user