SlideShare a Scribd company logo
Code Quality
Tools that make you awesome!
Intro
● I am a PHP Developer for about 9 years of
experience
● Have done shitty coding in past where I
dumped all the functions in a single file and
code still worked
● Worked on variety of frameworks and still have
no opinion on any
define(Best Practices)
● Set of rules and standards put together by the
community(SME) for the community
● Every domain has set of best practices that
each industry tends to follow. For example
accounting does Generally Accepted Account
Principle (GAAP) and project management
professionals follow PMI / Scrum etc
● Provides an flexible opinionated framework
Why Best Practices
● Well organised code
● Decreases the long term cost of maintaining a
software
● Easier to navigate different parts of codebase and
not only your codebase but vendor codes as well
[provided they follow best practices]
● Onboarding a new developer will be much quicker
[from the time developer joins the company and
makes a first PR]
PHP Best Practice Areas
● There are many areas where best practices
helps you make you write better code. We will
be talking about two main areas
● Coding Standards
● Code Analysis
Coding Standards
● PSR standards – An elite community / group of php
experts and mainterners of differnet framework and
CMS got toghther and with the help of general PHP
community memebers came across set of coding
standards that should be followed. These are
● PSR1/ PSR2
● Links:
● http://www.php-fig.org/psr/psr-1/
● http://www.php-fig.org/psr/psr-2/
CodeSniffer
● Scans your code and points if the code is not
conforming to the mention standards
● Easy to install and configure
Codesniffer-fixer
● PHPCBF and PHPCS-Fixer are the tools that
not only automatically detect the problems but
fixes them where they find applicable.
● Links:
https://github.com/FriendsOfPHP/PHP-CS-Fixer
Example
Static Code Analysis
● Does more then what codesnifer does. It scans
the code, measures it against various
programming software metrics and warns you if
your code is doing things which it shouldnt be
doing it. A must have to make your coding a
joyful experience.
– PHP Depend
– PHPMD
– PHP Stan
PHPMD
● Mess Detector is basically fork of PHP Depend
● Easy to configure and mostly used by CI engines and code quality engines to
measure code quality of PHP projects. Things it can find out
– Possibile bugs, overcomplicated expressions such as if else statements, unused
parms, methods.
– Measures code based on the following rules [all can be customized or overwritten]
● Clean Code Rule[SRP,Else conditions and static methods]
● Code Size Rule[Cyclometic complexity, method/class length,excessive parmaters etc]
● Controversial rules[Coding Standards / superglobals]
● Design Rules [using exit statements, CBO, using var_dump etc in codebase]
● Naming Rules[camelcase properties/methods, boolean getters]
● Unused Code Rules
● Installation
– Download: https://phpmd.org/download/index.html
PHP CPD
● CPD stands for Copy/Paste Detector –
PHPCPD Detects the code traces where code
is duplicated by a specific threshold.
Example
Putting it all together
● In order to ensure that code quality is mainted we ideally need to
use both codesniffer and phpmd together.
● Best way to use is during the CI phase either relying on a ci
plugins or using codacy.
● Alternatively you can use the power of git hooks a tool called
precommit does exactly that in an elegant way.
● Links:
– http://pre-commit.com/#intro
– https://github.com/hootsuite/pre-commit-php
– https://github.com/usmanzafar/devtools
– https://github.com/usmanzafar/pre-commit-php

More Related Content

What's hot (20)

How to write bad code using C#
How to write bad code using C#How to write bad code using C#
How to write bad code using C#
Wekoslav Stefanovski
 
Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)
Peter Kofler
 
Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)
Peter Kofler
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
Peter Kofler
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
Andrew Yatsenko
 
Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)
Peter Kofler
 
ITAKE Unconference - Holding down your technical debt with Sonarqube
ITAKE Unconference - Holding down your technical debt with SonarqubeITAKE Unconference - Holding down your technical debt with Sonarqube
ITAKE Unconference - Holding down your technical debt with Sonarqube
Patroklos Papapetrou (Pat)
 
Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)
Peter Kofler
 
Java interfaces design perspective
Java interfaces design perspectiveJava interfaces design perspective
Java interfaces design perspective
Manigandan Venkataraman
 
Don’t let your code to be illiterate along with your colleagues
Don’t let your code to be illiterate along with your colleaguesDon’t let your code to be illiterate along with your colleagues
Don’t let your code to be illiterate along with your colleagues
Izzet Mustafaiev
 
Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)
Peter Kofler
 
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Peter Kofler
 
Are you writing acceptance test yet?
Are you writing acceptance test yet?Are you writing acceptance test yet?
Are you writing acceptance test yet?
Ravi Okade
 
Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
Peter Kofler
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
Mihail Gaberov
 
Lighning Talk: PHP build process
Lighning Talk: PHP build processLighning Talk: PHP build process
Lighning Talk: PHP build process
Bryan Agee
 
“One man” development process model
“One man” development process model“One man” development process model
“One man” development process model
Silicon Straits
 
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Andrew Yatsenko
 
TDD, Refactoring - Workshop
TDD, Refactoring - WorkshopTDD, Refactoring - Workshop
TDD, Refactoring - Workshop
Leena N
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
Peter Kofler
 
Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)Coding Dojo: Bank OCR Outside-In (2015)
Coding Dojo: Bank OCR Outside-In (2015)
Peter Kofler
 
Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)Extract Method Refactoring Workshop (2016)
Extract Method Refactoring Workshop (2016)
Peter Kofler
 
Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)Coding Dojo: Functional Calisthenics (2016)
Coding Dojo: Functional Calisthenics (2016)
Peter Kofler
 
Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2Performance profiling and testing of symfony application 2
Performance profiling and testing of symfony application 2
Andrew Yatsenko
 
Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)Code Quality Assurance v4 (2013)
Code Quality Assurance v4 (2013)
Peter Kofler
 
ITAKE Unconference - Holding down your technical debt with Sonarqube
ITAKE Unconference - Holding down your technical debt with SonarqubeITAKE Unconference - Holding down your technical debt with Sonarqube
ITAKE Unconference - Holding down your technical debt with Sonarqube
Patroklos Papapetrou (Pat)
 
Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)Deliberate Practice, New Learning Styles (2015)
Deliberate Practice, New Learning Styles (2015)
Peter Kofler
 
Don’t let your code to be illiterate along with your colleagues
Don’t let your code to be illiterate along with your colleaguesDon’t let your code to be illiterate along with your colleagues
Don’t let your code to be illiterate along with your colleagues
Izzet Mustafaiev
 
Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)Deliberate Practice (Agile Slovenia 2015)
Deliberate Practice (Agile Slovenia 2015)
Peter Kofler
 
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)Designing Test Cases for the Gilded Rose Kata v2 (2015)
Designing Test Cases for the Gilded Rose Kata v2 (2015)
Peter Kofler
 
Are you writing acceptance test yet?
Are you writing acceptance test yet?Are you writing acceptance test yet?
Are you writing acceptance test yet?
Ravi Okade
 
Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)Coding Dojo: Baby Steps Push Challenge (2021)
Coding Dojo: Baby Steps Push Challenge (2021)
Peter Kofler
 
JavaScript Unit Testing
JavaScript Unit TestingJavaScript Unit Testing
JavaScript Unit Testing
Mihail Gaberov
 
Lighning Talk: PHP build process
Lighning Talk: PHP build processLighning Talk: PHP build process
Lighning Talk: PHP build process
Bryan Agee
 
“One man” development process model
“One man” development process model“One man” development process model
“One man” development process model
Silicon Straits
 
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Code Quality Control in a PHP project. GeekTalks, Cherkassy 2020
Andrew Yatsenko
 
TDD, Refactoring - Workshop
TDD, Refactoring - WorkshopTDD, Refactoring - Workshop
TDD, Refactoring - Workshop
Leena N
 
Pair Programming (2015)
Pair Programming (2015)Pair Programming (2015)
Pair Programming (2015)
Peter Kofler
 

Similar to PHP Code Quality (20)

"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices",  Vlad..."PHP Code Avengers: Structuring, Refactoring, and Superhero Practices",  Vlad...
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
Fwdays
 
Code quality tools for dev
Code quality tools for devCode quality tools for dev
Code quality tools for dev
Deepu S Nath
 
How to Successfully Master the PHP Development Tools.pdf
How to Successfully Master the PHP Development Tools.pdfHow to Successfully Master the PHP Development Tools.pdf
How to Successfully Master the PHP Development Tools.pdf
Enterprise Wired
 
Php|tek '12 It's More Than Just Style
Php|tek '12  It's More Than Just StylePhp|tek '12  It's More Than Just Style
Php|tek '12 It's More Than Just Style
LB Denker
 
Building rock solid software in the real world
Building rock solid software in the real worldBuilding rock solid software in the real world
Building rock solid software in the real world
Omni Adams
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards
Denis Ristic
 
Code analysis tools (for PHP)
Code analysis tools (for PHP)Code analysis tools (for PHP)
Code analysis tools (for PHP)
Karlen Kishmiryan
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
Ansar Ahmed
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
Ansar Ahmed
 
Quality assurance in practice - brussels drupal meetup
Quality assurance in practice - brussels drupal meetupQuality assurance in practice - brussels drupal meetup
Quality assurance in practice - brussels drupal meetup
Balázs Tatár
 
The automation of the process of caring for the quality of the code in PHP an...
The automation of the process of caring for the quality of the code in PHP an...The automation of the process of caring for the quality of the code in PHP an...
The automation of the process of caring for the quality of the code in PHP an...
Krzysztof (Chris) Ozog
 
Listen afup 2010
Listen afup 2010Listen afup 2010
Listen afup 2010
Gabriele Santini
 
Becoming A Php Ninja
Becoming A Php NinjaBecoming A Php Ninja
Becoming A Php Ninja
Mohammad Emran Hasan
 
Code Review
Code ReviewCode Review
Code Review
Tu Hoang
 
How to run an Enterprise PHP Shop
How to run an Enterprise PHP ShopHow to run an Enterprise PHP Shop
How to run an Enterprise PHP Shop
Jim Plush
 
Continuous Quality Assurance
Continuous Quality AssuranceContinuous Quality Assurance
Continuous Quality Assurance
Michelangelo van Dam
 
PHP Industrialization
PHP IndustrializationPHP Industrialization
PHP Industrialization
Damien Seguy
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
Wim Godden
 
Programming best practices (PHP)
Programming best practices (PHP)Programming best practices (PHP)
Programming best practices (PHP)
Clique Studios
 
Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...
Combell NV
 
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices",  Vlad..."PHP Code Avengers: Structuring, Refactoring, and Superhero Practices",  Vlad...
"PHP Code Avengers: Structuring, Refactoring, and Superhero Practices", Vlad...
Fwdays
 
Code quality tools for dev
Code quality tools for devCode quality tools for dev
Code quality tools for dev
Deepu S Nath
 
How to Successfully Master the PHP Development Tools.pdf
How to Successfully Master the PHP Development Tools.pdfHow to Successfully Master the PHP Development Tools.pdf
How to Successfully Master the PHP Development Tools.pdf
Enterprise Wired
 
Php|tek '12 It's More Than Just Style
Php|tek '12  It's More Than Just StylePhp|tek '12  It's More Than Just Style
Php|tek '12 It's More Than Just Style
LB Denker
 
Building rock solid software in the real world
Building rock solid software in the real worldBuilding rock solid software in the real world
Building rock solid software in the real world
Omni Adams
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards
Denis Ristic
 
Code analysis tools (for PHP)
Code analysis tools (for PHP)Code analysis tools (for PHP)
Code analysis tools (for PHP)
Karlen Kishmiryan
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
Ansar Ahmed
 
Php Best Practices
Php Best PracticesPhp Best Practices
Php Best Practices
Ansar Ahmed
 
Quality assurance in practice - brussels drupal meetup
Quality assurance in practice - brussels drupal meetupQuality assurance in practice - brussels drupal meetup
Quality assurance in practice - brussels drupal meetup
Balázs Tatár
 
The automation of the process of caring for the quality of the code in PHP an...
The automation of the process of caring for the quality of the code in PHP an...The automation of the process of caring for the quality of the code in PHP an...
The automation of the process of caring for the quality of the code in PHP an...
Krzysztof (Chris) Ozog
 
Code Review
Code ReviewCode Review
Code Review
Tu Hoang
 
How to run an Enterprise PHP Shop
How to run an Enterprise PHP ShopHow to run an Enterprise PHP Shop
How to run an Enterprise PHP Shop
Jim Plush
 
PHP Industrialization
PHP IndustrializationPHP Industrialization
PHP Industrialization
Damien Seguy
 
The why and how of moving to php 8
The why and how of moving to php 8The why and how of moving to php 8
The why and how of moving to php 8
Wim Godden
 
Programming best practices (PHP)
Programming best practices (PHP)Programming best practices (PHP)
Programming best practices (PHP)
Clique Studios
 
Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...Professional PHP: an open-source alternative for enterprise development [Kort...
Professional PHP: an open-source alternative for enterprise development [Kort...
Combell NV
 

Recently uploaded (20)

Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4
Razin Mustafiz
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025
Scott Keck-Warren
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025
Splunk
 
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
SOFTTECHHUB
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
MuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World Tips
MuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World TipsMuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World Tips
MuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World Tips
Patryk Bandurski
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
The fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team TopologiesThe fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team Topologies
Patricia Aas
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Optimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services HelpOptimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services Help
Alice Gray
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
John Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 TalkJohn Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 Talk
Razin Mustafiz
 
What’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptxWhat’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptx
Lisa ward
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4System Card: Claude Opus 4 & Claude Sonnet 4
System Card: Claude Opus 4 & Claude Sonnet 4
Razin Mustafiz
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025Reducing Bugs With Static Code Analysis php tek 2025
Reducing Bugs With Static Code Analysis php tek 2025
Scott Keck-Warren
 
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PCWondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Wondershare Filmora 14.3.2 Crack + License Key Free for Windows PC
Mudasir
 
Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025Splunk Leadership Forum Wien - 20.05.2025
Splunk Leadership Forum Wien - 20.05.2025
Splunk
 
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
With Claude 4, Anthropic redefines AI capabilities, effectively unleashing a ...
SOFTTECHHUB
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
MuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World Tips
MuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World TipsMuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World Tips
MuleSoft RTF & Flex Gateway on AKS – Setup, Insights & Real-World Tips
Patryk Bandurski
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
The fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team TopologiesThe fundamental misunderstanding in Team Topologies
The fundamental misunderstanding in Team Topologies
Patricia Aas
 
Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025Kubernetes Cloud Native Indonesia Meetup - May 2025
Kubernetes Cloud Native Indonesia Meetup - May 2025
Prasta Maha
 
Optimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services HelpOptimize IBM i with Consulting Services Help
Optimize IBM i with Consulting Services Help
Alice Gray
 
Fully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and ControlFully Open-Source Private Clouds: Freedom, Security, and Control
Fully Open-Source Private Clouds: Freedom, Security, and Control
ShapeBlue
 
John Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 TalkJohn Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 Talk
Razin Mustafiz
 
What’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptxWhat’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptx
Lisa ward
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 

PHP Code Quality

  • 1. Code Quality Tools that make you awesome!
  • 2. Intro ● I am a PHP Developer for about 9 years of experience ● Have done shitty coding in past where I dumped all the functions in a single file and code still worked ● Worked on variety of frameworks and still have no opinion on any
  • 3. define(Best Practices) ● Set of rules and standards put together by the community(SME) for the community ● Every domain has set of best practices that each industry tends to follow. For example accounting does Generally Accepted Account Principle (GAAP) and project management professionals follow PMI / Scrum etc ● Provides an flexible opinionated framework
  • 4. Why Best Practices ● Well organised code ● Decreases the long term cost of maintaining a software ● Easier to navigate different parts of codebase and not only your codebase but vendor codes as well [provided they follow best practices] ● Onboarding a new developer will be much quicker [from the time developer joins the company and makes a first PR]
  • 5. PHP Best Practice Areas ● There are many areas where best practices helps you make you write better code. We will be talking about two main areas ● Coding Standards ● Code Analysis
  • 6. Coding Standards ● PSR standards – An elite community / group of php experts and mainterners of differnet framework and CMS got toghther and with the help of general PHP community memebers came across set of coding standards that should be followed. These are ● PSR1/ PSR2 ● Links: ● http://www.php-fig.org/psr/psr-1/ ● http://www.php-fig.org/psr/psr-2/
  • 7. CodeSniffer ● Scans your code and points if the code is not conforming to the mention standards ● Easy to install and configure
  • 8. Codesniffer-fixer ● PHPCBF and PHPCS-Fixer are the tools that not only automatically detect the problems but fixes them where they find applicable. ● Links: https://github.com/FriendsOfPHP/PHP-CS-Fixer
  • 10. Static Code Analysis ● Does more then what codesnifer does. It scans the code, measures it against various programming software metrics and warns you if your code is doing things which it shouldnt be doing it. A must have to make your coding a joyful experience. – PHP Depend – PHPMD – PHP Stan
  • 11. PHPMD ● Mess Detector is basically fork of PHP Depend ● Easy to configure and mostly used by CI engines and code quality engines to measure code quality of PHP projects. Things it can find out – Possibile bugs, overcomplicated expressions such as if else statements, unused parms, methods. – Measures code based on the following rules [all can be customized or overwritten] ● Clean Code Rule[SRP,Else conditions and static methods] ● Code Size Rule[Cyclometic complexity, method/class length,excessive parmaters etc] ● Controversial rules[Coding Standards / superglobals] ● Design Rules [using exit statements, CBO, using var_dump etc in codebase] ● Naming Rules[camelcase properties/methods, boolean getters] ● Unused Code Rules ● Installation – Download: https://phpmd.org/download/index.html
  • 12. PHP CPD ● CPD stands for Copy/Paste Detector – PHPCPD Detects the code traces where code is duplicated by a specific threshold.
  • 14. Putting it all together ● In order to ensure that code quality is mainted we ideally need to use both codesniffer and phpmd together. ● Best way to use is during the CI phase either relying on a ci plugins or using codacy. ● Alternatively you can use the power of git hooks a tool called precommit does exactly that in an elegant way. ● Links: – http://pre-commit.com/#intro – https://github.com/hootsuite/pre-commit-php – https://github.com/usmanzafar/devtools – https://github.com/usmanzafar/pre-commit-php