Slide 1

Slide 1 text

Sarah Pantry VIP Development Consultant How To Do More With PHPCS

Slide 2

Slide 2 text

PHP CodeSniffer is a pair of scripts that tokenize PHP, JavaScript and CSS files to detect and fix violations of a defined coding standard -phpcs Detects violations -phpcbf Fixes violations What is PHPCS

Slide 3

Slide 3 text

How you get it? You can find PHPCS at https://github.com/squizlabs/PHP_CodeSniffer - composer global require "squizlabs/php_codesniffer=*" - pear install PHP_CodeSniffer

Slide 4

Slide 4 text

There are many sets of standards available for free download. -Doctrine -Drupal -Joomla -Magento -Symfony -WordPress -WordPress-VIP -Yii -And More Available Standards

Slide 5

Slide 5 text

How it works Coding Standards - Specified by an XML file - Can extend a parent standard - Specifies which rules apply - Assigns or overrides severity and messages for individual rules

Slide 6

Slide 6 text

Sniffs - Defined by a PHP file - Lists supported languages eg PHP, JS or CSS - Registers for specific tokens - Defines tests for compliance - Adds errors, warnings and descriptive messages How it works

Slide 7

Slide 7 text

- Security - escaping, sanitizing, nonces, injection - Performance - slow queries, uncached functions, enqueing, remote calls - Platform issues - disk writes, Memcached, Batcache or Varnish blockers - Settings alterations - ini_set, error_reporting - Unused and undefined variables - usually caused by typos - Unnecessary code - blocks of commented out or debug code - Adding more all the time What we look for

Slide 8

Slide 8 text

A Rockin’ Subtitle Director of WordPress VIP Custom Integrations

Slide 9

Slide 9 text

PHPCS and PHPStorm

Slide 10

Slide 10 text

WordPress.com VIP deploy tooling

Slide 11

Slide 11 text

VIP Go GitHub review integration

Slide 12

Slide 12 text

Sarah Pantry [email protected] @anigelUK Questions?