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

TypesSpacesFixer - Introduction #5734

Merged
merged 1 commit into from
Aug 29, 2021
Merged

TypesSpacesFixer - Introduction #5734

merged 1 commit into from
Aug 29, 2021

Conversation

kubawerlos
Copy link
Contributor

@kubawerlos kubawerlos commented May 24, 2021

closes #5495

@coveralls
Copy link

coveralls commented May 24, 2021

Coverage Status

Coverage increased (+0.02%) to 92.339% when pulling eec2de4 on kubawerlos:add_UnionTypesSpacesFixer into cbe00f0 on FriendsOfPHP:master.

@nicolas-grekas
Copy link

nicolas-grekas commented May 25, 2021

About the name, should we anticipate for intersection types?
TypesSpacesFixer maybe?
(just asking myself, I'm good with UnionTypesSpacesFixer)

@julienfalque
Copy link
Member

@nicolas-grekas Good point! I think we can be fairly sure intersection types will land in PHP at some point. TypesSpacesFixer looks more suitable to me 👍

@kubawerlos
Copy link
Contributor Author

Wouldn't TypesSpacesFixer suggest handling all spaces in types like function foo (TypeA | TypeA | ? string $x) {} when that space after ? is already handled?

@julienfalque
Copy link
Member

? is not allowed when using union types with | but I see your point. I don't have a better suggestion for now.

@kubawerlos
Copy link
Contributor Author

Let's go with TypesSpacesFixer for now then.

@kubawerlos kubawerlos marked this pull request as draft May 25, 2021 14:33
@kubawerlos kubawerlos changed the title Add UnionTypesSpacesFixer Add TypesSpacesFixer May 25, 2021
@kubawerlos kubawerlos marked this pull request as ready for review July 6, 2021 13:45
@nicolas-grekas
Copy link

I just ran this PR on branch 6.0 of symfony/symfony, all went well!
Can't wait ;)

@nicolas-grekas
Copy link

Hum, on second try, it looks like this doesn't fix past the first argument.
After I added spaces, I have this kind of diff when I try to remove the spaces again with the rule:

-    public function trans(string|\Stringable|TranslatableInterface|null $message, array|string $arguments = [], string $domain = null, string $locale = null, int $count = null): string
+    public function trans(string|\Stringable|TranslatableInterface|null $message, array | string $arguments = [], string $domain = null, string $locale = null, int $count = null): string

@kubawerlos
Copy link
Contributor Author

@nicolas-grekas I've found the reason: #5799 - can you review that, please?

@SpacePossum SpacePossum changed the title Add TypesSpacesFixer TypesSpacesFixer - Introduction Jul 30, 2021
@SpacePossum
Copy link
Contributor

SpacePossum commented Jul 30, 2021

looks very nice :)
little todo list

@nicolas-grekas
Copy link

#5799 is now merged ;)

@kubawerlos
Copy link
Contributor Author

@SpacePossum all done

@keradus
Copy link
Member

keradus commented Aug 29, 2021

Thank you @kubawerlos.

@keradus keradus merged commit 5799bac into PHP-CS-Fixer:master Aug 29, 2021
@kubawerlos kubawerlos deleted the add_UnionTypesSpacesFixer branch August 29, 2021 18:36
@sebastianbergmann
Copy link
Contributor

Thank you, @kubawerlos and @keradus.

@sidigi
Copy link

sidigi commented Sep 15, 2021

[ 'types_spaces' => ['space' => 'single']]

not worked for me

@SpacePossum
Copy link
Contributor

@sidigi can you report a new issue as to properly track it? please fill out the issue template when doing so, thanks!

BacLuc added a commit to ecamp/ecamp3 that referenced this pull request Sep 28, 2021
The new rule types_spaces was introduced with PHP-CS-Fixer/PHP-CS-Fixer#5734,
defaults to none (no spaces between union types).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Whitespace around union types separator
9 participants