various fixes

This commit is contained in:
TomasVotruba 2020-04-20 14:16:08 +02:00
parent b338dcb0c9
commit c4dee7782f
5 changed files with 22 additions and 10 deletions

View File

@ -19,4 +19,7 @@ jobs:
coverage: none
- run: composer install --no-progress --no-dev
- run: bin/rector list
- run: |
# needs to remove, add dev dependencies are missing and phpstan.neon includes them
rm phpstan.neon
bin/rector list

View File

@ -38,9 +38,11 @@ try {
$configuration = $container->get(Configuration::class);
$configuration->setFirstResolverConfig($rectorConfigsResolver->getFirstResolvedConfig());
/** @var ChangedFilesDetector $changedFilesDetector */
$changedFilesDetector = $container->get(ChangedFilesDetector::class);
$changedFilesDetector->setFirstUsedConfig(realpath($rectorConfigsResolver->getFirstResolvedConfig()));
if ($rectorConfigsResolver->getFirstResolvedConfig()) {
/** @var ChangedFilesDetector $changedFilesDetector */
$changedFilesDetector = $container->get(ChangedFilesDetector::class);
$changedFilesDetector->setFirstUsedConfig(realpath($rectorConfigsResolver->getFirstResolvedConfig()));
}
} catch (Throwable $throwable) {
$symfonyStyle = (new SymfonyStyleFactory(new PrivatesCaller()))->create();
$symfonyStyle->error($throwable->getMessage());

View File

@ -211,6 +211,8 @@ class ConstantPreservingAnnotationReader implements \Doctrine\Common\Annotations
if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') == 0) {
throw \Doctrine\Common\Annotations\AnnotationException::optimizerPlusSaveComments();
}
// Make sure that the IgnoreAnnotation annotation is loaded
class_exists(\Doctrine\Common\Annotations\Annotation\IgnoreAnnotation::class);
$this->parser = $parser ?: new \Doctrine\Common\Annotations\DocParser();
$this->preParser = new \Rector\DoctrineAnnotationGenerated\ConstantPreservingDocParser();
$this->preParser->setImports(self::$globalImports);

View File

@ -347,6 +347,11 @@ final class ConstantPreservingDocParser
self::$metadataParser->setIgnoreNotImportedAnnotations(true);
self::$metadataParser->setIgnoredAnnotationNames($this->ignoredAnnotationNames);
self::$metadataParser->setImports(['enum' => 'Doctrine\Common\Annotations\Annotation\Enum', 'target' => 'Doctrine\Common\Annotations\Annotation\Target', 'attribute' => 'Doctrine\Common\Annotations\Annotation\Attribute', 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes']);
// Make sure that annotations from metadata are loaded
class_exists(\Doctrine\Common\Annotations\Annotation\Enum::class);
class_exists(\Doctrine\Common\Annotations\Annotation\Target::class);
class_exists(\Doctrine\Common\Annotations\Annotation\Attribute::class);
class_exists(\Doctrine\Common\Annotations\Annotation\Attributes::class);
}
$class = new \ReflectionClass($name);
$docComment = $class->getDocComment();

View File

@ -48,7 +48,7 @@ final class PHPStanServicesFactory
$additionalConfigFiles
);
$temporaryPhpstanNeon = null;
$temporaryPHPStanNeon = null;
$currentProjectConfigFile = $currentWorkingDirectory . '/phpstan.neon';
if (file_exists($currentProjectConfigFile)) {
@ -58,11 +58,11 @@ final class PHPStanServicesFactory
if (Strings::match($phpstanNeonContent, self::BLEEDING_EDGE_PATTERN)) {
// Note: We need a unique file per process if rector runs in parallel
$pid = getmypid();
$temporaryPhpstanNeon = $currentWorkingDirectory . '/rector-temp-phpstan' . $pid . '.neon';
$temporaryPHPStanNeon = $currentWorkingDirectory . '/rector-temp-phpstan' . $pid . '.neon';
$clearedPhpstanNeonContent = Strings::replace($phpstanNeonContent, self::BLEEDING_EDGE_PATTERN);
FileSystem::write($temporaryPhpstanNeon, $clearedPhpstanNeonContent);
FileSystem::write($temporaryPHPStanNeon, $clearedPhpstanNeonContent);
$additionalConfigFiles[] = $temporaryPhpstanNeon;
$additionalConfigFiles[] = $temporaryPHPStanNeon;
} else {
$additionalConfigFiles[] = $currentProjectConfigFile;
}
@ -76,8 +76,8 @@ final class PHPStanServicesFactory
$this->container = $containerFactory->create(sys_get_temp_dir(), $additionalConfigFiles, []);
// clear bleeding edge fallback
if ($temporaryPhpstanNeon !== null) {
FileSystem::delete($temporaryPhpstanNeon);
if ($temporaryPHPStanNeon !== null) {
FileSystem::delete($temporaryPHPStanNeon);
}
}