laravel / pint

Laravel Pint is an opinionated PHP code style fixer for minimalists.
https://laravel.com/docs/pint
MIT License
2.79k stars 144 forks source link

Problem with Type function declarations #202

Closed gaglioffo closed 1 year ago

gaglioffo commented 1 year ago

Pint Version

1.10.5

PHP Version

8.1.10

Description

Type null remove into declaration function

Steps To Reproduce

Scenario OS: Windows PHP: 8.1.10

./vendor/bin/pint

public function nameFunction(?string $value = null) { or public function nameFunction(string|null $value = null) {

Pint 1.10.5 remove null and become public function nameFunction(string $value = null) { <-- wrong

I tried with Pint 1.10.3 and the type aren't touched public function nameFunction(?string $value = null) { <-- correct public function nameFunction(string|null $value = null) { <-- correct

pint.json

{
    "preset": "laravel",
    "rules": {
        "simplified_null_return": true,
        "braces": false,
        "new_with_braces": {
            "anonymous_class": false,
            "named_class": false
        }
    }
}
crynobone commented 1 year ago

You can disable the rules using the following configuration:

{
    "rules": {
        "nullable_type_declaration_for_default_null_value": {
            "use_nullable_type_declaration": true
        }
    }
}

Original PR: #193

gaglioffo commented 1 year ago

Thanks a lot and sorry