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

Error when using union types array|null on public property #5659

Closed
uyab opened this issue Apr 25, 2021 · 3 comments · Fixed by #5660
Closed

Error when using union types array|null on public property #5659

uyab opened this issue Apr 25, 2021 · 3 comments · Fixed by #5660
Assignees
Labels

Comments

@uyab
Copy link

uyab commented Apr 25, 2021

Bug report

  • PHP version: 8.0.3
  • PHP CS Fixer version: 3.0.0-rc.1
        [PhpCsFixer\Linter\LintingException]
        Parse error: syntax error, unexpected token "public" on line 19.


      Applied fixers: visibility_required

Code snippet that reproduces the problem

<?php

declare(strict_types=1);

namespace Laravolt\Camunda\Dto;

use Spatie\DataTransferObject\Attributes\Strict;
use Spatie\DataTransferObject\DataTransferObject;

#[Strict]
class ProcessInstance extends DataTransferObject
{
    public string $id;

    public string|null $tenantId;

    public string|null $businessKey;

    public array|null $links;

    public string $definitionId;

    public ?string $caseInstanceId;

    public bool $ended;

    public bool $suspended;
}
@uyab uyab added the kind/bug label Apr 25, 2021
@uyab
Copy link
Author

uyab commented Apr 25, 2021

There is no issue if I wrote like this:

public ?array $links;

//or
public null|array $links;

@kubawerlos
Copy link
Contributor

Hi @uyab, thanks for the report.

I'ts actually not a problem in visibility_required, but in one of internal transformers, see the fix in: #5660 (it's adding test for visibility_required for regression)- would be great if you could drop a review there.

@zolex
Copy link

zolex commented Apr 27, 2021

it also happens for other visibility. e.g.

private array|null $openingHours = null;

becomes

private array | public null $openingHours = null;

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

Successfully merging a pull request may close this issue.

3 participants