We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule phpdoc_to_comment turns phpdoc @var on return statement to two-slash comment.
PHP 7.3.21, PHP CS Fixer 2.16.4 Yellow Bird
The command: /usr/local/bin/php-cs-fixer fix --verbose --diff --config "$PHP_CS_CONFIG" $CHANGED_FILES;
/usr/local/bin/php-cs-fixer fix --verbose --diff --config "$PHP_CS_CONFIG" $CHANGED_FILES;
Config:
<?php $finder = PhpCsFixer\Finder::create() ->in(__DIR__ . DIRECTORY_SEPARATOR . 'src') ->notPath('Kernel.php') ; return PhpCsFixer\Config::create() ->setRiskyAllowed(true) ->setRules([ '@PSR2' => true, '@Symfony' => true, '@PhpCsFixer' => true, 'declare_strict_types' => true, 'concat_space' => ['spacing' => 'one'], 'ordered_class_elements' => false, 'phpdoc_add_missing_param_annotation' => false, 'binary_operator_spaces' => [ 'default' => 'single_space', 'operators' => [ '=>' => null, '=' => null, ], ], ]) ->setFinder($finder) ;
public function findDeleted($id, $lockMode = null, $lockVersion = null): ?Project { /** @var null|Project */ <-- this comment is required to specify concrete object from parent::find, otherwise PHPStan throws an error "should return Project|null but returns object|null" return parent::find($id, $lockMode, $lockVersion); }
PHP-CS-Fixer turns it to
public function findDeleted($id, $lockMode = null, $lockVersion = null): ?Project { // @var null|Project return parent::find($id, $lockMode, $lockVersion); }
If I try to avoid it like this:
public function findDeleted($id, $lockMode = null, $lockVersion = null): ?Project { /** @var null|Project */ $project = parent::find($id, $lockMode, $lockVersion); return $project; }
The rule return_assignment turns it to
public function findDeleted($id, $lockMode = null, $lockVersion = null): ?Project { /** @var null|Project */ return parent::find($id, $lockMode, $lockVersion); }
And on the next run the rule phpdoc_to_comment is coming again:
And this kind of comment can't be inspected by PHPStan.
The text was updated successfully, but these errors were encountered:
Duplicate of #5109/#4649.
Sorry, something went wrong.
No branches or pull requests
Bug report
Rule phpdoc_to_comment turns phpdoc @var on return statement to two-slash comment.
PHP 7.3.21, PHP CS Fixer 2.16.4 Yellow Bird
The command:
/usr/local/bin/php-cs-fixer fix --verbose --diff --config "$PHP_CS_CONFIG" $CHANGED_FILES;
Config:
Code snippet that reproduces the problem
PHP-CS-Fixer turns it to
If I try to avoid it like this:
The rule return_assignment turns it to
And on the next run the rule phpdoc_to_comment is coming again:
And this kind of comment can't be inspected by PHPStan.
The text was updated successfully, but these errors were encountered: