xoops forums

Mamba

Moderator
Posted on: 2009/8/31 6:23
Mamba
Mamba (Show more)
Moderator
Posts: 10798
Since: 2004/4/23
#1

Improving XOOPS Code: PHP CodeSniffer

Obviously, everybody has a different coding styles, but in order to make it easier for everybody to read it, we need to follow certain "Coding Standards".

The current XOOPS Coding Standards are here

But how to make sure that everybody does it correctly, and there are no mistakes?

Here comes the PHP CodeSniffer, which we'll use going forward before each release.

We would also like every developer contributing code to XOOPS (be it to Core, or as individual modules) to check his/her work before submitting to SVN!

1) Install CodeSniffer:

If you're using WAMP, here are instructions to install PEAR, and then CodeSniffer:

http://www.webeks.net/computer/other/wamp-pear-installation.html

NOTE: there are currently problems with installing PEAR on PHP 5.3:

2) Set Zend as your default:

phpcs --config-set default_standard Zend


3) Run CodeSniffer. See:

http://pear.php.net/manual/en/package ... php-codesniffer.usage.php

I didn't compare the Zend standard with ours, but since our is based on Zend, then they should be very similar. If there are differences, we'll create our own customized standard file, based on our "XOOPS Coding Standards", as described here:

http://clockwerx.blogspot.com/2008/06 ... omise-phpcodesniffer.html

As we are moving forward it's important that we start using more and more tools that will help us with improving our code and our development process.

As next, I am looking at "PHP Under Control"

http://phpundercontrol.org/about.html

has anybody any experience with it?

sailjapan

Moderator
Posted on: 2009/8/31 14:24
sailjapan
sailjapan (Show more)
Moderator
Posts: 1672
Since: 2005/11/16
#2

Re: Improving XOOPS Code: PHP CodeSniffer

this should be a news article...

Mamba

Moderator
Posted on: 2009/8/31 20:02
Mamba
Mamba (Show more)
Moderator
Posts: 10798
Since: 2004/4/23
#3

Re: Improving XOOPS Code: PHP CodeSniffer

OK, will do...

JulioNC

Quite a regular
Posted on: 2009/9/1 1:46
JulioNC
JulioNC (Show more)
Quite a regular
Posts: 239
Since: 2004/10/8
#4

Re: Improving XOOPS Code: PHP CodeSniffer

Thank You Mamba!
Don't forget CodeSniffer Netbeans Plugin

Well, for the moment only the version of CodeSniffer [1] is available in github and works in Linux Only :P

[1] http://www.whitewashing.de/blog/articles/119

Mazarin

Just can't stay away
Posted on: 2009/11/26 6:29
Mazarin
Mazarin (Show more)
Just can't stay away
Posts: 533
Since: 2008/12/10
#5

Re: Improving XOOPS Code: PHP CodeSniffer

New version of Codesniffer plugin for NetBeans is available.
http://www.whitewashing.de/blog/articles/122

Compatibility greatly increased. Now works with Windows and version 6.7.1 (and apparently 6.8 beta too) of NetBeans.

Mamba

Moderator
Posted on: 2009/11/26 7:52
Mamba
Mamba (Show more)
Moderator
Posts: 10798
Since: 2004/4/23
#6

Re: Improving XOOPS Code: PHP CodeSniffer

Great! Thanks for sharing!!!