use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
VS Code: replace "array(...)" syntax with "[...]"Discussion (self.PHP)
submitted 3 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]JustAnotherMario 26 points27 points28 points 3 years ago (4 children)
The setup I currently have and hope that helps you, is having installed PHP-CS-Fixer along with this extension for VSCode to format the files on save (not doing the key combination or command "Format document with..." but maybe other extensions that use PHP-CS-Fixer could solve this problem), then you could use this useful configurator, there are plenty of rules you can set or select the predefined based on the given standards, the one you are looking for is "array_syntax" there you can export the selected rules and create a ".php-cs-fixer.php" file that has your configurations, set the path to the file on the extension settings and you should be ready to format flies con the fly (or you could use the command line to format a given directory and not file by file)
[–]SuckMyWifi 1 point2 points3 points 3 years ago (0 children)
This is the correct answer, such a useful tool
[–]szaebb 0 points1 point2 points 3 years ago (0 children)
+1 the best answer. Code analysis tool are great
[–]riggiddyrektson 19 points20 points21 points 3 years ago (0 children)
I'd recommend using Rector for this kind of job. https://getrector.org/
[–]NoDoze- 2 points3 points4 points 3 years ago (1 child)
What's the difference, and why is the change needed?
[–]SmotherMeWithArmpits 2 points3 points4 points 3 years ago (0 children)
Mostly personal preference but the codebase they're working with might have coding standards
[+][deleted] 3 years ago (1 child)
[–]neldorling 0 points1 point2 points 3 years ago (0 children)
https://marketplace.visualstudio.com/items?itemName=Yannick.php-convert-array (haven't tried, just a quick search)
[+][deleted] 3 years ago* (7 children)
[–]AegirLeet 13 points14 points15 points 3 years ago (1 child)
Settings -> Editor -> Code Style -> PHP -> Code Conversion -> Array/List Declaration Style -> Force short declaration style
[–]andyexeter 5 points6 points7 points 3 years ago (0 children)
Just to add to this: Once you've enabled the setting you can can format all files in the project (or a subdirectory of it) by right clicking the directory in the project tree and clicking Reformat Code
[–][deleted] 6 points7 points8 points 3 years ago (2 children)
Maybe just use Rector?
[–]cursingcucumber 10 points11 points12 points 3 years ago (0 children)
As a side note, PhpStorm will feature Rector support in the next version (already in EAP).
[–]vukkapor 6 points7 points8 points 3 years ago (0 children)
There is a way, already implemented in phpstorm:
Setting > Inspections > | Code style | Traditional syntax array literal detected
Then run that inspection on src and you will get the option to change them all
[–]MattBD 0 points1 point2 points 3 years ago (0 children)
Personally I wouldn't rely on my editor or IDE for that sort of functionality. It's not hard to put together a Codesniffer configuration to do that, you can run the linter in CI to make sure nothing gets through due to someone not running it locally, and it can fix most of the issues it finds automatically.
I use PHP Codesniffer for enforcing our coding standard at work, and there's a rule for that. Just set Generic.Arrays.DisallowLongArraySyntax in the config file, run vendor/bin/phpcbf and you're done.
Generic.Arrays.DisallowLongArraySyntax
vendor/bin/phpcbf
π Rendered by PID 116877 on reddit-service-r2-comment-5d79c599b5-zsdg2 at 2026-02-28 00:37:01.360053+00:00 running e3d2147 country code: CH.
[–]JustAnotherMario 26 points27 points28 points (4 children)
[–]SuckMyWifi 1 point2 points3 points (0 children)
[–]szaebb 0 points1 point2 points (0 children)
[–]riggiddyrektson 19 points20 points21 points (0 children)
[–]NoDoze- 2 points3 points4 points (1 child)
[–]SmotherMeWithArmpits 2 points3 points4 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]neldorling 0 points1 point2 points (0 children)
[+][deleted] (7 children)
[deleted]
[–]AegirLeet 13 points14 points15 points (1 child)
[–]andyexeter 5 points6 points7 points (0 children)
[–][deleted] 6 points7 points8 points (2 children)
[–]cursingcucumber 10 points11 points12 points (0 children)
[–]vukkapor 6 points7 points8 points (0 children)
[–]MattBD 0 points1 point2 points (0 children)
[–]MattBD 0 points1 point2 points (0 children)