PHP-CS-Fixer
PHP-CS-Fixer copied to clipboard
Normalize `null|Foo` vs `?Foo` in phpDoc
In #7002 nullability normalisation was introduced for native types. We also should have solution for phpDoc.
For reference see here.
why the downvote, could be a configurable fixer for one of the two styles?
Could be. My downvote is for a fixer that would change Foo|null
to ?Foo
. I'm fine with a fixer doing the opposite change though I don't think it's worth it: I never saw such syntax in PHPDocs except here.
I've never seen ?Foo
, only null|foo
, would like to be proven wrong though
yes, would be nice if fixer could go both ways, so one could always unify his codebase.
there are not that much php 7.1+ codebase yet ;)
This is implemented now, and can be closed.
By the nullable_type_declaration_for_default_null_value
fixer.
nullable_type_declaration_for_default_null_value
is different: it updates the real type declaration, while this feature request is about PHPDoc syntax, i.e.:
/** @param Foo|null $foo */
vs.
/** @param ?Foo $foo */
Oh, I see.
Since PHP now supports union types, I think such PHPDocs will disappear entirely and we won't need such rule anymore. Shall we close?
do we have a rule to move that PHPDoc to PHP type declaration?
Since PHP now supports union types, I think such PHPDocs will disappear entirely and we won't need such rule anymore.
I don't think so! We still can't express things like ?non-empty-list<non-empty-string>
in PHP types, but this is a valid specialism of array|null
according to the type system specified by Psalm.
I'm working on an implementation of this feature and hopefully will provide a PR soon.
Resolved via #7002
This is for PHPDocs, not for type declarations. Should be reopened.
Since this issue has not had any activity within the last 90 days, I have marked it as stale.
The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way.
You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point.
I will close it if no further activity occurs within the next 30 days.
Since this issue has not had any activity within the last 90 days, I have marked it as stale.
The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way.
You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point.
I will close it if no further activity occurs within the next 30 days.
Since this issue has not had any activity within the last 90 days, I have marked it as stale.
The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way.
You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point.
I will close it if no further activity occurs within the next 30 days.
Since this issue has not had any activity within the last 90 days, I have marked it as stale.
The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way.
You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point.
I will close it if no further activity occurs within the next 30 days.