Skip to content
New issue

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

nullable_type_declaration_for_default_null_value causes a parse error on 2.18.3 #5536

Closed
vudaltsov opened this issue Mar 10, 2021 · 3 comments
Labels

Comments

@vudaltsov
Copy link
Contributor

Bug report

  • PHP 8.0.2 (cli) (built: Feb 4 2021 18:10:29) ( NTS )
  • PHP CS Fixer 2.18.3 Remote Void by Fabien Potencier and Dariusz Ruminski
  • php vendor/bin/php-cs-fixer fix --show-progress=estimating-max -vvv

With 'nullable_type_declaration_for_default_null_value' => true the code below produces

[PhpCsFixer\Linter\LintingException] Parse error: syntax error, unexpected token "#[" on line 14.
<?php

declare(strict_types=1);

namespace HappyInc\Import\CompanyStructureImport;

use Symfony\Component\Validator\Constraints as Assert;

final class CompanyStructureImportRow
{
    public function __construct(
        #[Assert\Count(min: 1, minMessage: 'Пустая цепочка департаментов.')]
        public array $departmentTitleChain,
        #[Assert\NotBlank(message: 'Пустой email.', allowNull: true)]
        #[Assert\Email(message: 'Некорректный email {{ value }}.')]
        public ?string $email = null,
    ) {
    }
}

Disabling nullable_type_declaration_for_default_null_value fixes the issue.

@keradus
Copy link
Member

keradus commented Mar 12, 2021

I think we may not support attributes on parameter level at all.
can you raise a PR to improve the situation, @vudaltsov ?

@vudaltsov
Copy link
Contributor Author

@keradus , I'm pretty busy this month. I will try to find some time, though.

@kubawerlos
Copy link
Contributor

This is fixed by #5665.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants