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

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

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 ?