Skip to content

Conversation

@samsonasik
Copy link
Member

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@TomasVotruba TomasVotruba merged commit 97a8d8e into main Oct 7, 2021
@TomasVotruba TomasVotruba deleted the close-968 branch October 7, 2021 07:46
@navneet0693
Copy link

navneet0693 commented Nov 9, 2021

Using:

https://github.com/palantirnet/drupal-rector
version: "0.11.4"
PHP: 7.4

I am not sure why it is still removing the @param docs.

Screenshot 2021-11-09 at 2 24 54 PM

My rector.php file is:

<?php

/**
 * @file
 */

declare(strict_types=1);

use Rector\Core\ValueObject\PhpVersion;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
use DrupalFinder\DrupalFinder;
use Rector\Core\Configuration\Option;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Set\ValueObject\SetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;

return static function (ContainerConfigurator $containerConfigurator): void {
  // @todo find out how to only load the relevant rector rules.
  //   Should we try and load \Drupal::VERSION and check?
  $containerConfigurator->import(__DIR__ . '/vendor/palantirnet/drupal-rector/config/drupal-8/drupal-8-all-deprecations.php');
  $containerConfigurator->import(__DIR__ . '/vendor/palantirnet/drupal-rector/config/drupal-9/drupal-9-all-deprecations.php');
  $containerConfigurator->import(SetList::PHP_74);

  $parameters = $containerConfigurator->parameters();

  $drupalFinder = new DrupalFinder();
  $drupalFinder->locateRoot(__DIR__);
  $drupalRoot = $drupalFinder->getDrupalRoot();
  $parameters->set(Option::AUTOLOAD_PATHS, [
    $drupalRoot . '/core',
    $drupalRoot . '/modules',
    $drupalRoot . '/profiles',
    $drupalRoot . '/themes',
  ]);

  $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_74);
  $parameters->set(Option::SKIP, ['*/upgrade_status/tests/modules/*']);
  $parameters->set(Option::FILE_EXTENSIONS, ['php', 'module', 'theme', 'install', 'profile', 'inc', 'engine']);
  $parameters->set(Option::AUTO_IMPORT_NAMES, TRUE);
  $parameters->set(Option::IMPORT_SHORT_CLASSES, FALSE);
  $parameters->set(Option::IMPORT_DOC_BLOCKS, FALSE);

  $parameters->set('drupal_rector_notices_as_comments', TRUE);

  $services = $containerConfigurator->services();

  $services->set(ReturnTypeFromReturnNewRector::class);
  $services->set(ReturnTypeFromStrictTypedPropertyRector::class);
  $services->set(ReturnTypeFromStrictTypedCallRector::class);
  $services->set(TypedPropertyFromStrictConstructorRector::class);

  $services->set(TypedPropertyRector::class);
  $services->set(ReturnTypeDeclarationRector::class);
  $services->set(ParamTypeDeclarationRector::class);
  $containerConfigurator->import(DoctrineSetList::DOCTRINE_CODE_QUALITY);

  // is your PHP version different from the one your refactor to? [default: your PHP version], uses PHP_VERSION_ID format
  $parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_74);

  // auto import fully qualified class names? [default: false]
  $parameters->set(Option::AUTO_IMPORT_NAMES, true);

  // skip classes used in PHP DocBlocks, like in /** @var \Some\Class */ [default: true]
  $parameters->set(Option::IMPORT_DOC_BLOCKS, false);

  // Run Rector only on changed files
  $parameters->set(Option::ENABLE_CACHE, true);
};

@weitzman
Copy link

weitzman commented Nov 9, 2021

Sadly, I've seen this too. Here is a demo https://getrector.org/demo/1ec39364-dbe0-6a5a-9487-95acf2ddf76b. In addition, the demo shows that @return should ideally behave like @param.

@samsonasik
Copy link
Member Author

The demo is not using latest dev-main, could you try "rector/rector: "dev-main" ?

@weitzman
Copy link

weitzman commented Nov 9, 2021 via email

@samsonasik
Copy link
Member Author

@weitzman thank you for verify, could you create failing test case for it? Thank you.

@cspitzlay
Copy link

cspitzlay commented Dec 1, 2022

I added failing tests for three different rectors that do not leave the @param / @return alone although there is a description (on the next line). Seems to me this is related to what @navneet0693 reported in #969 (comment)

The demo links provided by @weitzman don't seem to work anymore so I cannot tell if it is the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Param description not recognized after new line

7 participants