Using the TYPO3 Coding Standard¶
In general¶
We are using the same development cycle as the TYPO3 Core (Git as version controll system and Gerrit as review tool). Our Git repository is located at
http://git.typo3.org/Teams/forge.typo3.org/hudson-helpers/tools/PHP_CodeSniffer.git
Our Gerrit-Project is located at
https://review.typo3.org/#/q/project:Teams/forge.typo3.org/hudson-helpers/tools/PHP_CodeSniffer,n,z
Introduction to Git and Gerrit / Development-Workflow¶
Introduction for users, which are new to Git:- wiki.typo3.org: Introduction to Git
- Working with Gerrit as a Developer
- Working with Git and Gerrit Code Review
- wiki.typo3.org: Contribution Walkthrough with CommandLine
Setup for developer / contributer¶
Get your copy¶
If you are a user who want to develop / contribute / play around with the full copy of our development cycle, you need to clone the master branch of PHP_CoderSniffer:
git clone git://github.com/squizlabs/PHP_CodeSniffer.git
This is necessary to execute our UnitTests. If you don`t want to execute our UnitTests, you can install a stable version of PHP_CodeSniffer.
After this you need to clone our complete repository:
git clone git://git.typo3.org/Teams/forge.typo3.org/hudson-helpers/tools/PHP_CodeSniffer.git
Add the standards¶
Now it is necessary to add the coding standards into your PHP_CodeSniffer clone. Typically this is made by symlinks. If you use windows, it is okay to copy the standards instead of symlinking.
For example:- Clone-Path for PHP_CodeSniffer: /Users/Your/Path/Development/PHP_CodeSniffer/CodeSniffer
- Clone-Path for TYPO3 Standards: /Users/Your/Path/Development/PHP_CodeSniffer/TYPO3_CGL_Standard
The folder structure looks now like this:
|- Development
|- PHP_CodeSniffer
| |- CodeSniffer
| |- CodeSniffer
| |- scripts
| |- tests
| |- CodeSniffer.php
| |- CodeSniffer.sample.conf
| |- LICENCE
| |- package.xml
|-TYPO3_CGL_Standard
|- TYPO3
| |- Sniffs
| | |- Classes
| | | |- LowercaseClassKeywordsSniff.php
| | | |- ...
| | |- Commenting
| | |- ...
| |- Tests
| | |- Classes
| | |- ...
| |- Builds
| | |- PHPCS_TYPO3_SniffPool-0.0.3.tgz
| |- ruleset.xml
| |- package.xml
|- TYPO3v4
|- Builds
| |- PHPCS_TYPO3v4_Standard-0.0.3.tgz
|- ruleset.xml
|- package.xml
According to the folder structure above, you have to symlink the standards:
ln -s /Users/Your/Path/Development/PHP_CodeSniffer/TYPO3_CGL_Standard/TYPO3 /Users/Your/Path/Development/PHP_CodeSniffer/CodeSniffer/Standards/TYPO3 ln -s /Users/Your/Path/Development/PHP_CodeSniffer/TYPO3_CGL_Standard/TYPO3v4 /Users/Your/Path/Development/PHP_CodeSniffer/CodeSniffer/Standards/TYPO3v4
With "php /Users/Your/Path/Development/PHP_CodeSniffer/scripts/phpcs -i" you could verify if the standards are installed.
php /Users/Your/Path/Development/PHP_CodeSniffer/scripts/phpcs -i The installed coding standards are MySource, PEAR, PHPCS, Squiz, TYPO3, TYPO3v4 and Zend
To run the unit tests you must fire the following command (PHPUnit must be installed!):
phpunit /Users/Your/Path/Development/CodeSniffer/tests/AllTests.php
Providing patches¶
Since we are on Git and Gerrit you could push your patches right ahead into Gerrit. So its easier for us to review / annotate / comment / merge your patches.
For more informations about Git and Gerrit and how to work with this tools, please read the informations behind the links above.
According to our development model please push only patches with a own ticket in our issue tracker. So when pushing you have to type this command into your terminal (if you have configured your Git installation as described in: Contribution Walkthrough with CommandLine):
git push origin HEAD:refs/for/master/TOPIC
Note 1: The name of you local branch doesn't matter - you push allways into master
Note 2: The TOPIC is for example your issue number, which you are patching for