remove stub loader where not needed (#5757)

Co-authored-by: kaizen-ci <info@kaizen-ci.org>
This commit is contained in:
Tomas Votruba 2021-03-03 18:15:12 +01:00 committed by GitHub
parent 0a7ce80f4f
commit c559114715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 49 additions and 119 deletions

View File

@ -48,16 +48,17 @@
"symfony/finder": "^4.4.8|^5.1",
"symfony/http-kernel": "^4.4.8|^5.1",
"symfony/process": "^4.4.8|^5.1",
"symplify/astral": "^9.2.3",
"symplify/autowire-array-parameter": "^9.2.3",
"symplify/console-color-diff": "^9.2.3",
"symplify/package-builder": "^9.2.3",
"symplify/rule-doc-generator": "^9.2.3",
"symplify/set-config-resolver": "^9.2.3",
"symplify/simple-php-doc-parser": "^9.2.3",
"symplify/skipper": "^9.2.3",
"symplify/smart-file-system": "^9.2.3",
"symplify/symfony-php-config": "^9.2.3",
"symfony/uid": "^4.4.8|^5.1",
"symplify/astral": "^9.2.4",
"symplify/autowire-array-parameter": "^9.2.4",
"symplify/console-color-diff": "^9.2.4",
"symplify/package-builder": "^9.2.4",
"symplify/rule-doc-generator": "^9.2.4",
"symplify/set-config-resolver": "^9.2.4",
"symplify/simple-php-doc-parser": "^9.2.4",
"symplify/skipper": "^9.2.4",
"symplify/smart-file-system": "^9.2.4",
"symplify/symfony-php-config": "^9.2.4",
"webmozart/assert": "^1.9"
},
"require-dev": {
@ -71,14 +72,14 @@
"phpunit/phpunit": "^9.5",
"symfony/security-core": "^5.2",
"symfony/security-http": "^5.2",
"symplify/changelog-linker": "^9.2.3",
"symplify/coding-standard": "^9.2.3",
"symplify/changelog-linker": "^9.2.4",
"symplify/coding-standard": "^9.2.4",
"symplify/easy-ci": "^9.1.0",
"symplify/easy-coding-standard": "^9.2.3",
"symplify/easy-testing": "^9.2.3",
"symplify/easy-coding-standard": "^9.2.4",
"symplify/easy-testing": "^9.2.4",
"symplify/monorepo-builder": "^9.2",
"symplify/phpstan-extensions": "^9.2.3",
"symplify/phpstan-rules": "^9.2.3",
"symplify/phpstan-extensions": "^9.2.4",
"symplify/phpstan-rules": "^9.2.4",
"tracy/tracy": "^2.8"
},
"replace": {

View File

@ -18,7 +18,6 @@ use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\HttpKernel\RectorKernel;
use Rector\Core\NonPhpFile\NonPhpFileProcessor;
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
use Rector\Core\Stubs\StubLoader;
use Rector\Core\ValueObject\StaticNonPhpFileSuffixes;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
use Rector\Testing\Application\EnabledRectorClassProvider;
@ -329,11 +328,6 @@ abstract class AbstractRectorTestCase extends AbstractKernelTestCase
self::$smartFileSystem = new SmartFileSystem();
self::$fixtureGuard = new FixtureGuard();
self::$rectorConfigsResolver = new RectorConfigsResolver();
// load stubs
$stubLoader = new StubLoader();
$stubLoader->loadStubs();
self::$isInitialized = true;
}

View File

@ -13,10 +13,10 @@ use PhpParser\Node\Stmt\ClassConst;
use PhpParser\Node\Stmt\Expression;
use PHPStan\Type\ObjectType;
use PHPStan\Type\StringType;
use Ramsey\Uuid\Uuid;
use Rector\Core\Rector\AbstractRector;
use Rector\DeadCode\Doctrine\DoctrineEntityManipulator;
use Rector\NodeTypeResolver\Node\AttributeKey;
use Symfony\Component\Uid\Uuid;
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@ -211,10 +211,8 @@ CODE_SAMPLE
private function createUuidStringNode(): String_
{
$uuidValue = Uuid::uuid4();
$uuidValueString = $uuidValue->toString();
return new String_($uuidValueString);
$uuidV4 = Uuid::v4();
return new String_((string) $uuidV4);
}
private function isUuidType(Expr $expr): bool
@ -226,6 +224,7 @@ CODE_SAMPLE
return false;
}
return $argumentStaticType->getClassName() === 'Ramsey\Uuid\Uuid';
return $argumentStaticType->isInstanceOf('Ramsey\Uuid\Uuid')
->yes();
}
}

View File

@ -2,16 +2,16 @@
namespace Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Fixture;
use Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Source\ArrayStore;
use Illuminate\Contracts\Cache\Store;
class SomeClass
{
/**
* @var ArrayStore
* @var Store
*/
private $arrayStore;
public function __construct(ArrayStore $arrayStore)
public function __construct(Store $arrayStore)
{
$this->arrayStore = $arrayStore;
}
@ -33,16 +33,16 @@ class SomeClass
namespace Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Fixture;
use Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Source\ArrayStore;
use Illuminate\Contracts\Cache\Store;
class SomeClass
{
/**
* @var ArrayStore
* @var Store
*/
private $arrayStore;
public function __construct(ArrayStore $arrayStore)
public function __construct(Store $arrayStore)
{
$this->arrayStore = $arrayStore;
}

View File

@ -1,50 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Laravel\Tests\Rector\StaticCall\MinutesToSecondsInCacheRector\Source;
use Illuminate\Contracts\Cache\Store;
final class ArrayStore implements Store
{
public function get($key)
{
}
public function many(array $keys)
{
}
public function put($key, $value, $seconds)
{
}
public function putMany(array $values, $seconds)
{
}
public function increment($key, $value = 1)
{
}
public function decrement($key, $value = 1)
{
}
public function forever($key, $value)
{
}
public function forget($key)
{
}
public function flush()
{
}
public function getPrefix()
{
}
}

View File

@ -18,7 +18,6 @@ use Rector\Core\FileSystem\PhpFilesFinder;
use Rector\Core\Guard\RectorGuard;
use Rector\Core\NonPhpFile\NonPhpFileProcessor;
use Rector\Core\PhpParser\NodeTraverser\RectorNodeTraverser;
use Rector\Core\Stubs\StubLoader;
use Rector\Core\ValueObject\StaticNonPhpFileSuffixes;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -69,11 +68,6 @@ final class ProcessCommand extends AbstractCommand
*/
private $rectorNodeTraverser;
/**
* @var StubLoader
*/
private $stubLoader;
/**
* @var NonPhpFileProcessor
*/
@ -105,7 +99,6 @@ final class ProcessCommand extends AbstractCommand
RectorApplication $rectorApplication,
RectorGuard $rectorGuard,
RectorNodeTraverser $rectorNodeTraverser,
StubLoader $stubLoader,
SymfonyStyle $symfonyStyle,
ComposerProcessor $composerProcessor,
PhpFilesFinder $phpFilesFinder
@ -118,7 +111,6 @@ final class ProcessCommand extends AbstractCommand
$this->rectorApplication = $rectorApplication;
$this->outputFormatterCollector = $outputFormatterCollector;
$this->rectorNodeTraverser = $rectorNodeTraverser;
$this->stubLoader = $stubLoader;
$this->nonPhpFileProcessor = $nonPhpFileProcessor;
$this->changedFilesDetector = $changedFilesDetector;
$this->symfonyStyle = $symfonyStyle;
@ -193,7 +185,6 @@ final class ProcessCommand extends AbstractCommand
$this->configuration->setAreAnyPhpRectorsLoaded((bool) $this->rectorNodeTraverser->getPhpRectorCount());
$this->rectorGuard->ensureSomeRectorsAreRegistered();
$this->stubLoader->loadStubs();
$paths = $this->configuration->getPaths();

View File

@ -9,7 +9,6 @@ use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\Core\Configuration\Configuration;
use Rector\Core\HttpKernel\RectorKernel;
use Rector\Core\Stubs\PHPStanStubLoader;
use Rector\Core\Stubs\StubLoader;
use Rector\Core\ValueObject\Bootstrap\BootstrapConfigs;
use Symfony\Component\DependencyInjection\Container;
use Symplify\PackageBuilder\Console\Input\StaticInputDetector;
@ -35,9 +34,6 @@ final class RectorContainerFactory
$rectorKernel->setConfigs($configFilePaths);
}
$stubLoader = new StubLoader();
$stubLoader->loadStubs();
$phpStanStubLoader = new PHPStanStubLoader();
$phpStanStubLoader->loadStubs();

View File

@ -23,16 +23,33 @@ final class StubLoader
return;
}
$stubDirectory = __DIR__ . '/../../stubs';
// these have to be loaded, as doctrine annotation parser only works with included files
$stubDirectories = [
__DIR__ . '/../../stubs/DI/Annotation',
__DIR__ . '/../../stubs/Doctrine/ORM/Mapping',
__DIR__ . '/../../stubs/Gedmo/Mapping/Annotation',
__DIR__ . '/../../stubs/JMS',
__DIR__ . '/../../stubs/Sensio/Bundle/FrameworkExtraBundle/Configuration',
__DIR__ . '/../../stubs/Symfony/Bundle/FrameworkExtraBundle/Configuration',
__DIR__ . '/../../stubs/Symfony/Bridge/Doctrine/Validator/Constraints',
__DIR__ . '/../../stubs/Symfony/Component/Validator',
__DIR__ . '/../../stubs/Symfony/Component/Form',
__DIR__ . '/../../stubs/Symfony/Component/Routing/Annotation',
__DIR__ . '/../../stubs/Tester',
];
// @see https://github.com/rectorphp/rector/issues/1899
$stubDirectories = array_filter($stubDirectories, function (string $stubDirectory): bool {
return file_exists($stubDirectory);
});
// stubs might not exists on composer install, to prevent PHPStorm duplicated confusion
// @see https://github.com/rectorphp/rector/issues/1899
if (! file_exists($stubDirectory)) {
if ($stubDirectories === []) {
return;
}
$robotLoader = new RobotLoader();
$robotLoader->addDirectory($stubDirectory);
$robotLoader->addDirectory(...$stubDirectories);
$robotLoader->setTempDirectory(sys_get_temp_dir() . '/rector/stubs');
$robotLoader->register();
$robotLoader->rebuild();

View File

@ -1,17 +0,0 @@
<?php
declare(strict_types=1);
namespace Vich\UploaderBundle\Mapping\Annotation;
if (class_exists('Vich\UploaderBundle\Mapping\Annotation\Uploadable')) {
return;
}
/**
* @Annotation
* @Target({"CLASS"})
*/
class Uploadable
{
}

View File

@ -14,7 +14,6 @@ error_reporting(E_ALL ^ E_DEPRECATED);
// performance boost
gc_disable();
// load stubs
$stubLoader = new StubLoader();
$stubLoader->loadStubs();