This commit is contained in:
Tomas Votruba 2021-03-18 14:29:32 +01:00 committed by GitHub
parent 6f4b0b4ae9
commit 33daf1de2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 12 deletions

View File

@ -50,8 +50,11 @@ final class DowngradeRectorConfig
// use relative paths, so files are excluded on nested directory too
'vendor/symfony/http-kernel/HttpKernelBrowser.php',
'vendor/symfony/string/Slugger/AsciiSlugger.php',
// not used at all
'vendor/symfony/http-foundation/Session/*',
'vendor/symfony/string/Slugger/AsciiSlugger.php',
'vendor/nette/caching/src/Bridges/*',
// always excluded
'*vendor/symfony/polyfill*/bootstrap80.php',

View File

@ -30,5 +30,5 @@ for directory in $directories; do
echo "[NOTE] Downgrading '$directory' directory\n"
# --working-dir is needed, so "SKIP" parameter is applied in absolute path of nested directory
php -d memory_limit=-1 bin/rector process $directory --config build/config/config-downgrade.php --working-dir $BUILD_DIRECTORY --ansi
php -d memory_limit=-1 bin/rector process $directory --config build/config/config-downgrade.php --working-dir $BUILD_DIRECTORY --ansi --debug
done

View File

@ -102,12 +102,12 @@ abstract class AbstractPhpDocInfoTest extends AbstractKernelTestCase
{
$nodes = $this->fileInfoParser->parseFileInfoToNodesAndDecorate($fileInfo);
$foundNode = $this->betterNodeFinder->findFirstInstanceOf($nodes, $nodeType);
if (! $foundNode instanceof Node) {
$namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, $nodeType);
if (! $namespace instanceof Node) {
throw new ShouldNotHappenException();
}
return $foundNode;
return $namespace;
}
private function printNodePhpDocInfoToString(Node $node): string

View File

@ -92,12 +92,12 @@ final class UseAddingPostRector extends AbstractPostRector
$this->useNodesToAddCollector->clear($smartFileInfo);
// A. has namespace? add under it
$foundNode = $this->betterNodeFinder->findFirstInstanceOf($nodes, Namespace_::class);
if ($foundNode instanceof Namespace_) {
$namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, Namespace_::class);
if ($namespace instanceof Namespace_) {
// first clean
$this->useImportsRemover->removeImportsFromNamespace($foundNode, $removedShortUses);
$this->useImportsRemover->removeImportsFromNamespace($namespace, $removedShortUses);
// then add, to prevent adding + removing false positive of same short use
$this->useImportsAdder->addImportsToNamespace($foundNode, $useImportTypes, $functionUseImportTypes);
$this->useImportsAdder->addImportsToNamespace($namespace, $useImportTypes, $functionUseImportTypes);
return $nodes;
}

View File

@ -587,3 +587,6 @@ parameters:
# phpstan bug
- '#Unable to resolve the template type T in call to method Rector\\Core\\PhpParser\\Node\\BetterNodeFinder\:\:findParentTypes\(\)#'
-
message: '#Function "interface_exists\(\)" cannot be used/left in the code#'
path: packages/Testing/PhpConfigPrinter/config/php-config-printer-config.php

View File

@ -32,12 +32,12 @@ final class FullyQualifiedNameResolver
*/
public function resolveFullyQualifiedName(array $nodes, string $shortClassName): string
{
$foundNode = $this->betterNodeFinder->findFirstInstanceOf($nodes, Namespace_::class);
if (! $foundNode instanceof Namespace_) {
$namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, Namespace_::class);
if (! $namespace instanceof Namespace_) {
return $shortClassName;
}
$namespaceName = $this->nodeNameResolver->getName($foundNode);
$namespaceName = $this->nodeNameResolver->getName($namespace);
if ($namespaceName === null) {
return $shortClassName;
}