Is there a way to add braces automatically for if-else single line blocks in netbeans 8.2 (PHP)?
Clash Royale CLAN TAG#URR8PPP
Is there a way to add braces automatically for if-else single line blocks in netbeans 8.2 (PHP)?
I am using Netbeans 8.2
for my PHP
project. It was an already build one. When code, I saw so many areas where using if-else
conditions without braces like below.
Netbeans 8.2
PHP
if-else
if(1<2)
echo 'yes';
else
echo 'no';
I don't like this syntax and want to change them to
if(1<2)
echo 'yes';
else
echo 'no';
Is there any inbuilt option or custom plugin to do the same?
@skomisa, I am looking for PHP programming.
– Arun
Aug 7 at 11:13
Possible duplicate of Netbeans code format braces in PHP single line statements, though no solution is offered unfortunately.
– skomisa
Aug 11 at 3:17
2 Answers
2
I don't think it is possible to automatically correct all if-else statements missing a brace in a single pass, but the functionality to automatically add missing braces on an individual basis for PHP source is built in to NetBeans:
First ensure that if-else
statements without braces are reported:
if-else
Then build your project containing if-else
statements without braces:
if-else
if-else
if
else
if
else
This approach is not ideal, but it is reliable, and you only need to got through the exercise once.
I fixed this issue. Added php-cs-fixer
to Netbeans
. And it fixed the issue. php-cs-fixer
will fix coding standard issues. So the above mentioned is a coding standard issue and php-cs-fixer
fixed it.
php-cs-fixer
Netbeans
php-cs-fixer
php-cs-fixer
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Are you looking for a language-specific solution, or are you looking for something more general?
– skomisa
Aug 4 at 5:54