[jgen] PHPcs: spaces, tabs, indenting... and PHPStorm

5,662 views
Skip to first unread message

Javier Gómez

unread,
Jun 9, 2012, 8:20:22 PM6/9/12
to Joomla! General Development
Hi,

I've just installed PHPStorm and activated the PHPcs with the sniffers
here https://github.com/joomla/joomla-platform/tree/staging/build/phpcs.
It's awesome!!!

But I'm getting this phpcs response "Spaces must be used to indent
lines; tabs are not allowed".
As far as I know in joomla we use Tabs and not spaces as written here:
http://developer.joomla.org/standards/ch02s03.html

In the previous link says:
"Source code editors or Integrated Development Environments (IDE’s)
such as Eclipse must have the tab-stops for indenting measuring four
(4) spaces in length."

Does any one know how to do that in PHPStorm?

Thanks a lot

Michael Babker

unread,
Jun 9, 2012, 8:23:18 PM6/9/12
to joomla-de...@googlegroups.com
In PhpStorm's preferences, there should be an option to define the code
style. As far as I know, you have to manually define the options (I.e. No
way to link it to the PHPCS rules and auto-format it), but once you're set
up, there's very few issues with PhpStorm's auto formatter.
>--
>You received this message because you are subscribed to the Google Groups
>"Joomla! General Development" group.
>To post to this group, send an email to
>joomla-de...@googlegroups.com.
>To unsubscribe from this group, send email to
>joomla-dev-gene...@googlegroups.com.
>For more options, visit this group at
>http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>


Marius van Rijnsoever

unread,
Jun 9, 2012, 9:43:32 PM6/9/12
to joomla-de...@googlegroups.com
The "tabs" error is generated from within phpcs and you can add the
following commandline parameter to auto-convert tabs to 4 spaces:
--tab-width=4

On a side note, that phpcs joomla profile on github is not correct and
does not follow the newly defined coding standards (seems to use the
old coding standards)

Thanks, Marius

Javier Gómez

unread,
Jun 10, 2012, 11:25:02 AM6/10/12
to Joomla! General Development
Nope, seems that this sniffer is up to date and okay. It checks for
tabs and not for whitespaces as you can see here:
https://github.com/joomla/joomla-platform/blob/staging/build/phpcs/Joomla/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php

I will continue searching. Thanks.

On Jun 9, 7:43 pm, Marius van Rijnsoever <mariu...@gmail.com> wrote:
> The "tabs" error is generated from within phpcs and you can add the
> following commandline parameter to auto-convert tabs to 4 spaces:
> --tab-width=4
>
> On a side note, that phpcs joomla profile on github is not correct and
> does not follow the newly defined coding standards (seems to use the
> old coding standards)
>
> Thanks, Marius
>
>
>
>
>
>
>
> On Sun, Jun 10, 2012 at 8:23 AM, Michael Babker <mbab...@flbab.com> wrote:
> > In PhpStorm's preferences, there should be an option to define the code
> > style.  As far as I know, you have to manually define the options (I.e. No
> > way to link it to the PHPCS rules and auto-format it), but once you're set
> > up, there's very few issues with PhpStorm's auto formatter.
>
> > On 6/9/12 8:20 PM, "Javier Gómez" <javier.gomez.co...@gmail.com> wrote:
>
> >>Hi,
>
> >>I've just installed PHPStorm and activated the PHPcs with the sniffers
> >>herehttps://github.com/joomla/joomla-platform/tree/staging/build/phpcs.

Javier Gómez

unread,
Jun 10, 2012, 11:35:56 AM6/10/12
to Joomla! General Development
Ok solved. There must be a cache in the IDE that stores the Coding
Standard.
The solution is to choose any other coding standard. Save. Go back and
choose the Joomla! coding Standard. And Save. That should work.

By the way, if there is any sniffer not up to date please report it
here so we can check it.

On Jun 10, 9:25 am, Javier Gómez <javier.gomez.co...@gmail.com> wrote:
> Nope, seems that this sniffer is up to date and okay. It checks for
> tabs and not for whitespaces as you can see here:https://github.com/joomla/joomla-platform/blob/staging/build/phpcs/Jo...

Prasath Nadarajah

unread,
Jun 18, 2012, 12:19:42 AM6/18/12
to joomla-de...@googlegroups.com
Hi Javier i am aslo facing problems wiht phpstorm + phpcs.
The code editor displays  "tabs must be used to indent lines; spaces are not allowed"
even if i use tabs to indent lines.
Any idea how to fix this editor problem??

prasath nadarajah

unread,
Jun 18, 2012, 12:20:48 AM6/18/12
to joomla-de...@googlegroups.com
If you open the same file using notepad++ and then indent it with tabs.
The code editor in the IDE correct itself and does not display the error

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-general/-/9tqczv3FeKEJ.

To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.



--
Cheers
Prasath Nadarajah

Michael Babker

unread,
Jun 18, 2012, 12:23:58 AM6/18/12
to joomla-de...@googlegroups.com
There is a setting in PhpStorm that lets you choose between using an actual tab character or the tab button applying X number of spaces.  You may be running into that issue.  Try going back into the config and changing that option.

Zubair Hussain

unread,
Jun 18, 2012, 12:59:55 AM6/18/12
to joomla-de...@googlegroups.com
Try menu

File->setting->
Inline image 1

Regards

Zubair Hussain
tab-setting.PNG

prasath nadarajah

unread,
Jun 18, 2012, 4:25:18 AM6/18/12
to joomla-de...@googlegroups.com
It works thanks!!!
Cheers
Prasath Nadarajah

tab-setting.PNG

garyamort

unread,
Jun 19, 2012, 12:51:42 PM6/19/12
to joomla-de...@googlegroups.com
Also I'm learning:
File --> Settings --> IDE Settings --> Editor
Set "strip trailing spaces on save" to "modified"....would have saved a commit if I had that enabled.

File --> Settings --> IDE Settings --> Editor --> Appearance
"Show whitespace" - when enabled it shows a graphical representation of the tab charector so you know your using tabs and not spaces....[19 days after the fact for me]

To post to this group, send an email to joomla-dev-general@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.



--
Cheers
Prasath Nadarajah

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-dev-general@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-dev-general@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-general+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages