Skip to content

Commit

Permalink
[PHPStan] Avoid removing bleeding edge from phar include, let user ha…
Browse files Browse the repository at this point in the history
…ndle own phpstan configuration (#4840)

Co-authored-by: GitHub Action <actions@github.com>
  • Loading branch information
TomasVotruba and actions-user authored Aug 23, 2023
1 parent 5de9824 commit 75f2cbc
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 148 deletions.
3 changes: 0 additions & 3 deletions build/config/phpstan-for-downgrade.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
includes:
- phar://vendor/phpstan/phpstan/phpstan.phar/conf/bleedingEdge.neon

# this config has extensions, that helps PHPStan inside Rector to resolve more precise types
parameters:
inferPrivatePropertyTypeFromConstructor: true
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions packages/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@ public function services(): void
);
}

public function resetRuleConfigurations(): void
{
$this->ruleConfigurations = [];
}

private function importFile(string $filePath): void
{
Assert::fileExists($filePath);
Expand Down Expand Up @@ -412,9 +417,4 @@ private function ensureNotDuplicatedClasses(array $rectorClasses): void
$duplicatedRectorClasses
));
}

public function resetRuleConfigurations(): void
{
$this->ruleConfigurations = [];
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Rector\Core\Configuration\Option;
use Rector\Core\Configuration\Parameter\SimpleParameterProvider;
use Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider;
use Symfony\Component\Filesystem\Filesystem;
use Webmozart\Assert\Assert;

/**
Expand All @@ -29,34 +28,15 @@ final class PHPStanServicesFactory
private readonly Container $container;

public function __construct(
BleedingEdgeIncludePurifier $bleedingEdgeIncludePurifier,
) {
$containerFactory = new ContainerFactory(getcwd());
$additionalConfigFiles = $this->resolveAdditionalConfigFiles();

$purifiedConfigFiles = [];

foreach ($additionalConfigFiles as $key => $additionalConfigFile) {
$purifiedConfigFile = $bleedingEdgeIncludePurifier->purifyConfigFile($additionalConfigFile);

// nothing was changed
if ($purifiedConfigFile === null) {
continue;
}

$additionalConfigFiles[$key] = $purifiedConfigFile;
$purifiedConfigFiles[] = $purifiedConfigFile;
}

$containerFactory = new ContainerFactory(getcwd());
$this->container = $containerFactory->create(
SimpleParameterProvider::provideStringParameter(Option::CONTAINER_CACHE_DIRECTORY),
$additionalConfigFiles,
[]
);

// clear temporary files, after container is created
$filesystem = new Filesystem();
$filesystem->remove($purifiedConfigFiles);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public function resolve(Node $node): Type
$callerType = $this->nodeTypeResolver->getType($node->class);
}

foreach ($callerType->getObjectClassReflections() as $classReflection) {
$classMethodReturnType = $this->resolveClassMethodReturnType($classReflection, $node, $methodName, $scope);
foreach ($callerType->getObjectClassReflections() as $objectClassReflection) {
$classMethodReturnType = $this->resolveClassMethodReturnType($objectClassReflection, $node, $methodName, $scope);
if (! $classMethodReturnType instanceof MixedType) {
return $classMethodReturnType;
}
Expand Down
5 changes: 1 addition & 4 deletions tests/Issues/EmptyLongArraySyntax/config/configured_rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@
use Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([
SensitiveConstantNameRector::class,
AddParamBasedOnParentClassMethodRector::class,
]);
$rectorConfig->rules([SensitiveConstantNameRector::class, AddParamBasedOnParentClassMethodRector::class]);
};

0 comments on commit 75f2cbc

Please sign in to comment.