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
Forcing short hand arrays in PHP #2123
Comments
Hi @vincentmcgreevy! That's correct, there is no option to override this. Prettier is an opinionated code formatter, and we try to keep the number of options to an absolute minimum. Can you explain why the shorthand array syntax is not working out for you? |
I am actually having the same issue. We have the old syntax in 1000s of places and them all being updated makes PRs very hard to distinguish between real changes and these |
@Dalton-James I'd recommend to format every file in a single commit when introducing prettier in an existing codebase, such that commits afterwards never just change formatting at places unrelated to the actual change. There even is a way to rewrite history as if the project would have always been formatted with Prettier, but I never tried that myself. |
Formatting all the code at once is not an option, we have a lot of old PHP scripts and prettier was breaking scripts so we lost any confidence in doing this. From what I remember one of the issues was prettier broke the syntax if you declared a class property with a variable. |
@vincentmcgreevy I get that. I’ll mention the AST_COMPARE flag though, which ensures that the AST doesn’t change after formatting (except expected changes), which should give you additional safety. See Line 20 in 39c4d52
|
It appears the PHP array short hand is being forced for version 5.4 and above?
const useShortForm =
(node.kind === "array" && isMinVersion(options.phpVersion, "5.4")) ||
(node.kind === "list" && node.shortForm
Can this be updated to have the option to override this?
The text was updated successfully, but these errors were encountered: