SlideShare a Scribd company logo
1 of 34
Back to basics PHP_Codesniffer Sebastian Marek
Control your code ,[object Object]
Avoid duplications ,[object Object]
Minimize complexity
Increase performance
Right tools for the job ,[object Object]
Avoid duplications (phpcpd) ,[object Object]
Minimize complexity (pdepend)
Increase performance (phpmd)
PHP_Codesniffer Static code analysis ,[object Object]
syntax checks
coding standards
Tokenizer http://uk2.php.net/manual/en/book.tokenizer.php
Tokenize the code T_OPEN_TAG <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_CLASS  T_WHITESPACE  T_STRING  T_WHITESPACE T_EXTENDS T_WHITESPACE  T_STRING  T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code {  T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_PROTECTED T_WHITESPACE T_FUNCTION T_WHITESPACE T_STRING ( T_VARIABLE ) T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code {  T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_IF T_WHITESPACE ( T_VARIABLE T_OBJECT_OPERATOR T_STRING T_WHITESPACE T_IS_NOT_IDENTICAL T_WHITESPACE T_STRING ) T_WHITESPACE { T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_REQUIRE_ONCE T_WHITESPACE T_CONSTANT_ENCAPSED_STRING ; T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_THROW T_WHITESPACE T_NEW T_WHITESPACE T_STRING ( T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_VARIABLE T_OBJECT_OPERATOR T_STRING T_WHITESPACE <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code ) ; <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_WHITESPACE } <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_RETURN T_WHITESPACE T_VARIABLE ; <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_WHITESPACE } <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Tokenize the code T_WHITESPACE } <?php class  Zend_Config_Ini  extends  Zend_Config { protected function  _parseIniFile($filename) { if  ( $this -> _loadFileErrorStr  !==  null ) { require_once  'Zend/Config/Exception.php' ; throw new  Zend_Config_Exception( $this -> _loadFileErrorStr ); } return  $iniArray; } }
Installation #> pear install PHP_CodeSniffer #> phpcs --version PHP_CodeSniffer version 1.3.0RC1 (beta) by Squiz Pty Ltd. (http://www.squiz.net) #> phpcs -i The installed coding standards are MySource, PEAR, PHPCS, Squiz and Zend
Quick user guide #> phpcs --standard=Zend ~/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php   FILE: /Users/smarek/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php -------------------------------------------------------------------------------- FOUND 2 ERROR(S) AFFECTING 6 LINE(S) -------------------------------------------------------------------------------- 17 | WARNING | Line exceeds 80 characters; contains 87 characters 26 | WARNING | Line exceeds 80 characters; contains 87 characters 51 | ERROR  | Closing brace must be on a line by itself 59 | ERROR  | Closing brace must be on a line by itself 80 | WARNING | Line exceeds 80 characters; contains 90 characters 120 | WARNING | Line exceeds 80 characters; contains 87 characters -------------------------------------------------------------------------------- Time: 0 seconds, Memory: 4.25Mb Selecting a coding standard
Quick user guide #> phpcs --standard=Zend --report=checkstyle  ~/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php   <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <checkstyle version=&quot;1.3.0RC1&quot;> <file name=&quot;/Users/smarek/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php&quot;> <error line=&quot;17&quot; column=&quot;1&quot; severity=&quot;warning&quot;  message=&quot;Line exceeds 80 characters; contains 87 characters&quot; source=&quot;Generic.Files.LineLength.TooLong&quot;/> <error line=&quot;26&quot; column=&quot;1&quot; severity=&quot;warning&quot;  message=&quot;Line exceeds 80 characters; contains 87 characters&quot;  source=&quot;Generic.Files.LineLength.TooLong&quot;/> <error line=&quot;51&quot; column=&quot;6&quot; severity=&quot;error&quot;  message=&quot;Closing brace must be on a line by itself&quot;  source=&quot;PEAR.WhiteSpace.ScopeClosingBrace.Line&quot;/> <error line=&quot;59&quot; column=&quot;6&quot; severity=&quot;error&quot;  message=&quot;Closing brace must be on a line by itself&quot;  source=&quot;PEAR.WhiteSpace.ScopeClosingBrace.Line&quot;/> <error line=&quot;80&quot; column=&quot;1&quot; severity=&quot;warning&quot;  message=&quot;Line exceeds 80 characters; contains 90 characters&quot;  source=&quot;Generic.Files.LineLength.TooLong&quot;/> <error line=&quot;120&quot; column=&quot;1&quot; severity=&quot;warning&quot;  message=&quot;Line exceeds 80 characters; contains 87 characters&quot;  source=&quot;Generic.Files.LineLength.TooLong&quot;/> </file> </checkstyle> Changing reporting format to checkstyle report
Quick user guide #> phpcs --standard=Zend --report=svnblame library/Zend/Auth.php   PHP CODE SNIFFER SVN BLAME SUMMARY -------------------------------------------------------------------------------- AUTHOR  (Author %) (Overall %) COUNT -------------------------------------------------------------------------------- darby  (1.91)  (50)  3 bkarwin  (0)  (33.33)  2 ralph  (16.67)  (16.67)  1 -------------------------------------------------------------------------------- A TOTAL OF 6 SNIFF VIOLATION(S) WERE COMMITTED BY 3 AUTHOR(S) -------------------------------------------------------------------------------- Time: 3 seconds, Memory: 4.25Mb Changing reporting format to svnblame report
Understanding the sniffs CodeSniffer - Standards - Zend - Sniffs - NamingConventions - ValidVariableNameSniff.php - Files - ClosingTagSniff.php - Debug - CodeAnalyzerSniff.php
Including existing sniffs CodeSniffer/Standards/Zend/Sniffs/ ruleset.xml <? xml   version = &quot;1.0&quot; ?> < ruleset   name = &quot;Zend&quot; > < description > A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date. </ description > <!-- Include some sniffs from all around the place --> < rule   ref = &quot;Generic.Functions.FunctionCallArgumentSpacing&quot; /> < rule   ref = &quot;Generic.Functions.OpeningFunctionBraceBsdAllman&quot; /> < rule   ref = &quot;Generic.PHP.DisallowShortOpenTag&quot; /> < rule   ref = &quot;Generic.WhiteSpace.DisallowTabIndent&quot; /> < rule   ref = &quot;PEAR.Classes.ClassDeclaration&quot; /> < rule   ref = &quot;PEAR.ControlStructures.ControlSignature&quot; /> < rule   ref = &quot;PEAR.Functions.FunctionCallSignature&quot; /> < rule   ref = &quot;PEAR.Functions.ValidDefaultValue&quot; /> < rule   ref = &quot;PEAR.WhiteSpace.ScopeClosingBrace&quot; /> < rule   ref = &quot;Squiz.Functions.GlobalFunction&quot; /> </ ruleset >
Overriding sniffs options CodeSniffer/Standards/Zend/Sniffs/ ruleset.xml <? xml   version = &quot;1.0&quot; ?> < ruleset   name = &quot;Zend&quot; > < description > A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date. </ description > <!-- Lines can be 80 chars long, show errors at 120 chars --> < rule   ref = &quot;Generic.Files.LineLength&quot; > < properties > < property   name = &quot;lineLimit&quot;   value = &quot;80&quot; /> < property   name = &quot;absoluteLineLimit&quot;   value = &quot;120&quot; /> </ properties > </ rule > <!-- Use Unix newlines --> < rule   ref = &quot;Generic.Files.LineEndings&quot; > < properties > < property   name = &quot;eolChar&quot;   value = &quot;&quot; /> </ properties > </ rule > </ ruleset >

More Related Content

What's hot

PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021Ayesh Karunaratne
 
Optiva-13449_TestResults
Optiva-13449_TestResultsOptiva-13449_TestResults
Optiva-13449_TestResultsHarvey Canaan
 
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016Britta Alex
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisIan Macali
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormMichelangelo van Dam
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Nikita Popov
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Php pattern matching
Php pattern matchingPhp pattern matching
Php pattern matchingJIGAR MAKHIJA
 
Storytelling By Numbers
Storytelling By NumbersStorytelling By Numbers
Storytelling By NumbersMichael King
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11Combell NV
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning PerlDave Cross
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
 

What's hot (20)

PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021PHP Enums - PHPCon Japan 2021
PHP Enums - PHPCon Japan 2021
 
Optiva-13449_TestResults
Optiva-13449_TestResultsOptiva-13449_TestResults
Optiva-13449_TestResults
 
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016
 
PHPSpec BDD Framework
PHPSpec BDD FrameworkPHPSpec BDD Framework
PHPSpec BDD Framework
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with thisPHP Powerpoint -- Teach PHP with this
PHP Powerpoint -- Teach PHP with this
 
Intermediate PHP
Intermediate PHPIntermediate PHP
Intermediate PHP
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
 
Php security3895
Php security3895Php security3895
Php security3895
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)Static Optimization of PHP bytecode (PHPSC 2017)
Static Optimization of PHP bytecode (PHPSC 2017)
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Php pattern matching
Php pattern matchingPhp pattern matching
Php pattern matching
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Storytelling By Numbers
Storytelling By NumbersStorytelling By Numbers
Storytelling By Numbers
 
CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11CLI, the other SAPI phpnw11
CLI, the other SAPI phpnw11
 
Beginning Perl
Beginning PerlBeginning Perl
Beginning Perl
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
New in php 7
New in php 7New in php 7
New in php 7
 

Similar to Back to basics - PHP_Codesniffer

vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking Sebastian Marek
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for MagentoIvan Chepurnyi
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxMichelangelo van Dam
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11Michelangelo van Dam
 
Secure Coding With Wordpress (BarCamp Orlando 2009)
Secure Coding With Wordpress (BarCamp Orlando 2009)Secure Coding With Wordpress (BarCamp Orlando 2009)
Secure Coding With Wordpress (BarCamp Orlando 2009)Mark Jaquith
 
Php Security3895
Php Security3895Php Security3895
Php Security3895Aung Khant
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit TestingMike Lively
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Coursemussawir20
 
Dealing with Legacy PHP Applications
Dealing with Legacy PHP ApplicationsDealing with Legacy PHP Applications
Dealing with Legacy PHP ApplicationsClinton Dreisbach
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 TrainingChris Chubb
 

Similar to Back to basics - PHP_Codesniffer (20)

PHPSpec BDD for PHP
PHPSpec BDD for PHPPHPSpec BDD for PHP
PHPSpec BDD for PHP
 
Zend framework 04 - forms
Zend framework 04 - formsZend framework 04 - forms
Zend framework 04 - forms
 
Framework
FrameworkFramework
Framework
 
vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking vfsStream - effective filesystem mocking
vfsStream - effective filesystem mocking
 
Os Nixon
Os NixonOs Nixon
Os Nixon
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
 
Unit testing zend framework apps
Unit testing zend framework appsUnit testing zend framework apps
Unit testing zend framework apps
 
Using of TDD practices for Magento
Using of TDD practices for MagentoUsing of TDD practices for Magento
Using of TDD practices for Magento
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
PHP
PHP PHP
PHP
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
Secure Coding With Wordpress (BarCamp Orlando 2009)
Secure Coding With Wordpress (BarCamp Orlando 2009)Secure Coding With Wordpress (BarCamp Orlando 2009)
Secure Coding With Wordpress (BarCamp Orlando 2009)
 
SPL, not a bridge too far
SPL, not a bridge too farSPL, not a bridge too far
SPL, not a bridge too far
 
Php Security3895
Php Security3895Php Security3895
Php Security3895
 
Basic PHP
Basic PHPBasic PHP
Basic PHP
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Php Crash Course
Php Crash CoursePhp Crash Course
Php Crash Course
 
Dealing with Legacy PHP Applications
Dealing with Legacy PHP ApplicationsDealing with Legacy PHP Applications
Dealing with Legacy PHP Applications
 
Php Chapter 1 Training
Php Chapter 1 TrainingPhp Chapter 1 Training
Php Chapter 1 Training
 

More from Sebastian Marek

The Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationThe Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationSebastian Marek
 
CodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingCodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingSebastian Marek
 
Praktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlPraktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlSebastian Marek
 
Managing and Monitoring Application Performance
Managing and Monitoring Application PerformanceManaging and Monitoring Application Performance
Managing and Monitoring Application PerformanceSebastian Marek
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerSebastian Marek
 
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Sebastian Marek
 
Test your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceTest your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceSebastian Marek
 
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practicePHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practiceSebastian Marek
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerSebastian Marek
 
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice Sebastian Marek
 
Magic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practiceMagic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practiceSebastian Marek
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnitSebastian Marek
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them allSebastian Marek
 

More from Sebastian Marek (15)

The Journey Towards Continuous Integration
The Journey Towards Continuous IntegrationThe Journey Towards Continuous Integration
The Journey Towards Continuous Integration
 
CodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programmingCodeClub - Teaching the young generation programming
CodeClub - Teaching the young generation programming
 
Praktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPlPraktyczne code reviews - PHPConPl
Praktyczne code reviews - PHPConPl
 
Managing and Monitoring Application Performance
Managing and Monitoring Application PerformanceManaging and Monitoring Application Performance
Managing and Monitoring Application Performance
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
 
Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!Continuous Inspection: Fight back the 7 deadly sins of a developer!
Continuous Inspection: Fight back the 7 deadly sins of a developer!
 
Test your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practiceTest your code like a pro - PHPUnit in practice
Test your code like a pro - PHPUnit in practice
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
Effective code reviews
Effective code reviewsEffective code reviews
Effective code reviews
 
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practicePHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
PHP Forum Paris 2012: Magic behind the numbers. Software metrics in practice
 
Ten Commandments Of A Software Engineer
Ten Commandments Of A Software EngineerTen Commandments Of A Software Engineer
Ten Commandments Of A Software Engineer
 
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
PHP Benelux 2012: Magic behind the numbers. Software metrics in practice
 
Magic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practiceMagic behind the numbers - software metrics in practice
Magic behind the numbers - software metrics in practice
 
Back to basics - PHPUnit
Back to basics - PHPUnitBack to basics - PHPUnit
Back to basics - PHPUnit
 
Sonar - the ring to rule them all
Sonar - the ring to rule them allSonar - the ring to rule them all
Sonar - the ring to rule them all
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 

Recently uploaded (20)

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Back to basics - PHP_Codesniffer

  • 1. Back to basics PHP_Codesniffer Sebastian Marek
  • 2.
  • 3.
  • 6.
  • 7.
  • 10.
  • 14. Tokenize the code T_OPEN_TAG <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 15. Tokenize the code T_CLASS T_WHITESPACE T_STRING T_WHITESPACE T_EXTENDS T_WHITESPACE T_STRING T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 16. Tokenize the code { T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 17. Tokenize the code T_PROTECTED T_WHITESPACE T_FUNCTION T_WHITESPACE T_STRING ( T_VARIABLE ) T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 18. Tokenize the code { T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 19. Tokenize the code T_IF T_WHITESPACE ( T_VARIABLE T_OBJECT_OPERATOR T_STRING T_WHITESPACE T_IS_NOT_IDENTICAL T_WHITESPACE T_STRING ) T_WHITESPACE { T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 20. Tokenize the code T_REQUIRE_ONCE T_WHITESPACE T_CONSTANT_ENCAPSED_STRING ; T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 21. Tokenize the code T_THROW T_WHITESPACE T_NEW T_WHITESPACE T_STRING ( T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 22. Tokenize the code T_VARIABLE T_OBJECT_OPERATOR T_STRING T_WHITESPACE <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 23. Tokenize the code ) ; <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 24. Tokenize the code T_WHITESPACE } <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 25. Tokenize the code T_RETURN T_WHITESPACE T_VARIABLE ; <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 26. Tokenize the code T_WHITESPACE } <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 27. Tokenize the code T_WHITESPACE } <?php class Zend_Config_Ini extends Zend_Config { protected function _parseIniFile($filename) { if ( $this -> _loadFileErrorStr !== null ) { require_once 'Zend/Config/Exception.php' ; throw new Zend_Config_Exception( $this -> _loadFileErrorStr ); } return $iniArray; } }
  • 28. Installation #> pear install PHP_CodeSniffer #> phpcs --version PHP_CodeSniffer version 1.3.0RC1 (beta) by Squiz Pty Ltd. (http://www.squiz.net) #> phpcs -i The installed coding standards are MySource, PEAR, PHPCS, Squiz and Zend
  • 29. Quick user guide #> phpcs --standard=Zend ~/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php FILE: /Users/smarek/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php -------------------------------------------------------------------------------- FOUND 2 ERROR(S) AFFECTING 6 LINE(S) -------------------------------------------------------------------------------- 17 | WARNING | Line exceeds 80 characters; contains 87 characters 26 | WARNING | Line exceeds 80 characters; contains 87 characters 51 | ERROR | Closing brace must be on a line by itself 59 | ERROR | Closing brace must be on a line by itself 80 | WARNING | Line exceeds 80 characters; contains 90 characters 120 | WARNING | Line exceeds 80 characters; contains 87 characters -------------------------------------------------------------------------------- Time: 0 seconds, Memory: 4.25Mb Selecting a coding standard
  • 30. Quick user guide #> phpcs --standard=Zend --report=checkstyle ~/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?> <checkstyle version=&quot;1.3.0RC1&quot;> <file name=&quot;/Users/smarek/apps/ZendFramework-1.11.2-minimal/library/Zend/Auth.php&quot;> <error line=&quot;17&quot; column=&quot;1&quot; severity=&quot;warning&quot; message=&quot;Line exceeds 80 characters; contains 87 characters&quot; source=&quot;Generic.Files.LineLength.TooLong&quot;/> <error line=&quot;26&quot; column=&quot;1&quot; severity=&quot;warning&quot; message=&quot;Line exceeds 80 characters; contains 87 characters&quot; source=&quot;Generic.Files.LineLength.TooLong&quot;/> <error line=&quot;51&quot; column=&quot;6&quot; severity=&quot;error&quot; message=&quot;Closing brace must be on a line by itself&quot; source=&quot;PEAR.WhiteSpace.ScopeClosingBrace.Line&quot;/> <error line=&quot;59&quot; column=&quot;6&quot; severity=&quot;error&quot; message=&quot;Closing brace must be on a line by itself&quot; source=&quot;PEAR.WhiteSpace.ScopeClosingBrace.Line&quot;/> <error line=&quot;80&quot; column=&quot;1&quot; severity=&quot;warning&quot; message=&quot;Line exceeds 80 characters; contains 90 characters&quot; source=&quot;Generic.Files.LineLength.TooLong&quot;/> <error line=&quot;120&quot; column=&quot;1&quot; severity=&quot;warning&quot; message=&quot;Line exceeds 80 characters; contains 87 characters&quot; source=&quot;Generic.Files.LineLength.TooLong&quot;/> </file> </checkstyle> Changing reporting format to checkstyle report
  • 31. Quick user guide #> phpcs --standard=Zend --report=svnblame library/Zend/Auth.php PHP CODE SNIFFER SVN BLAME SUMMARY -------------------------------------------------------------------------------- AUTHOR (Author %) (Overall %) COUNT -------------------------------------------------------------------------------- darby (1.91) (50) 3 bkarwin (0) (33.33) 2 ralph (16.67) (16.67) 1 -------------------------------------------------------------------------------- A TOTAL OF 6 SNIFF VIOLATION(S) WERE COMMITTED BY 3 AUTHOR(S) -------------------------------------------------------------------------------- Time: 3 seconds, Memory: 4.25Mb Changing reporting format to svnblame report
  • 32. Understanding the sniffs CodeSniffer - Standards - Zend - Sniffs - NamingConventions - ValidVariableNameSniff.php - Files - ClosingTagSniff.php - Debug - CodeAnalyzerSniff.php
  • 33. Including existing sniffs CodeSniffer/Standards/Zend/Sniffs/ ruleset.xml <? xml version = &quot;1.0&quot; ?> < ruleset name = &quot;Zend&quot; > < description > A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date. </ description > <!-- Include some sniffs from all around the place --> < rule ref = &quot;Generic.Functions.FunctionCallArgumentSpacing&quot; /> < rule ref = &quot;Generic.Functions.OpeningFunctionBraceBsdAllman&quot; /> < rule ref = &quot;Generic.PHP.DisallowShortOpenTag&quot; /> < rule ref = &quot;Generic.WhiteSpace.DisallowTabIndent&quot; /> < rule ref = &quot;PEAR.Classes.ClassDeclaration&quot; /> < rule ref = &quot;PEAR.ControlStructures.ControlSignature&quot; /> < rule ref = &quot;PEAR.Functions.FunctionCallSignature&quot; /> < rule ref = &quot;PEAR.Functions.ValidDefaultValue&quot; /> < rule ref = &quot;PEAR.WhiteSpace.ScopeClosingBrace&quot; /> < rule ref = &quot;Squiz.Functions.GlobalFunction&quot; /> </ ruleset >
  • 34. Overriding sniffs options CodeSniffer/Standards/Zend/Sniffs/ ruleset.xml <? xml version = &quot;1.0&quot; ?> < ruleset name = &quot;Zend&quot; > < description > A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date. </ description > <!-- Lines can be 80 chars long, show errors at 120 chars --> < rule ref = &quot;Generic.Files.LineLength&quot; > < properties > < property name = &quot;lineLimit&quot; value = &quot;80&quot; /> < property name = &quot;absoluteLineLimit&quot; value = &quot;120&quot; /> </ properties > </ rule > <!-- Use Unix newlines --> < rule ref = &quot;Generic.Files.LineEndings&quot; > < properties > < property name = &quot;eolChar&quot; value = &quot;&quot; /> </ properties > </ rule > </ ruleset >
  • 35. Customizing sniffs CodeSniffer/Standards/Zend/Sniffs/ ruleset.xml <? xml version = &quot;1.0&quot; ?> < ruleset name = &quot;Zend&quot; > < description > A coding standard based on an early Zend Framework coding standard. Note that this standard is out of date. </ description > < rule ref = &quot;Generic.Commenting.Todo.CommentFound&quot; > < message > Ten komentarz wymaga dalszych zmian: %s </ message > < severity > 3 </ severity > </ rule > </ ruleset >
  • 36. Closure Linter support Closure Linter installation #> sudo easy_install http://closure-linter.googlecode.com/files/closure_linter-latest.tar.gz PHP_Codesniffer integration #> phpcs --config-set gjslint_path /usr/local/bin/gjslint #> phpcs --standard=Squiz ~/git/LegacyCodebase/data/mis/doc_root/latest/assets/bookmark.js FILE: /Volumes/git/LegacyCodebase/data/mis/doc_root/latest/assets/bookmark.js -------------------------------------------------------------------------------- FOUND 6 ERROR(S) AFFECTING 5 LINE(S) -------------------------------------------------------------------------------- 1 | ERROR | Missing file doc comment 1 | ERROR | Equals sign not aligned with surrounding assignments; expected 3 | | spaces but found 1 space 4 | ERROR | Opening brace should be on a new line 5 | ERROR | Operator == prohibited; use === instead 7 | ERROR | Operator == prohibited; use === instead 12 | ERROR | Expected 1 blank line before closing function brace; 0 found -------------------------------------------------------------------------------- Time: 0 seconds, Memory: 8.25Mb
  • 41.
  • 42. PHP_CodeSniffer homepage - http://pear.php.net/package/PHP_CodeSniffer
  • 43. Closure Linter - http://code.google.com/closure/utilities/docs/linter_howto.html
  • 44. PHP CodeBrowser - https://github.com/mayflowergmbh/PHP_CodeBrowser
  • 45. PHPUnderControl - http://phpundercontrol.org/
  • 46. Hudson - http://hudson-ci.org/
  • 47. Sonar - http://docs.codehaus.org/display/SONAR/PHP+Plugin
  • 48. Q&A ?