Giter Club home page Giter Club logo

wp-coding-standards's Introduction

Pronamic WordPress Coding Standards

Pronamic WordPress Coding Standards for PHP_CodeSniffer.

Versions

We try to provide support for the last 3 major releases of PHP and WordPress in our projects.

PHP

  • 8.3
  • 8.2
  • 8.1

https://www.php.net/supported-versions.php

WordPress

  • 6.5
  • 6.4
  • 6.3

https://codex.wordpress.org/WordPress_Versions

Other

PHP_CodeSniffer

https://github.com/PHPCSStandards/PHP_CodeSniffer

Arguments

https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Usage

colors

By default use colors in output.

<arg name="colors" />

extensions

By default only check files with php extension:

<arg name="extensions" value="php" />

parallel

By default use 8 parallel processes.

<arg name="parallel" value="8" />

squizlabs/PHP_CodeSniffer#1732

sp

By default show sniff codes in all reports. By default show progress of the run.

<arg value="sp" />

Rules

PHPCompatibilityWP

https://github.com/PHPCompatibility/PHPCompatibilityWP

By default this package test PHP 8.1 and higher via the following setting:

<config name="testVersion" value="8.1-"/>

PHPCompatibility

https://github.com/PHPCompatibility/PHPCompatibility

Required through PHPCompatibilityWP.

WordPress

https://github.com/WordPress/WordPress-Coding-Standards

By default the minimum WordPress version to check is set to 6.3 via the following setting:

<config name="minimum_supported_wp_version" value="6.3" />

https://github.com/WordPress/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters

WordPressVIPMinimum

https://github.com/Automattic/VIP-Coding-Standards

WordPress-VIP-Go

https://github.com/Automattic/VIP-Coding-Standards

VariableAnalysis

https://github.com/sirbrillig/phpcs-variable-analysis

Exclusions

WordPress.Files.FileName.InvalidClassFileName

According to the WordPress PHP Coding Standards:

Class file names should be based on the class name with class- prepended and the underscores in the class name replaced with hyphens, for example WP_Error becomes:

class-wp-error.php

Source: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions

This sniff will check on this naming convention:

Class file names should be based on the class name with "class-" prepended. Expected class-test.php, but found Test.php.

We often use the PSR-4 autoloading mechanism and therefore deviate from it.

WordPress.Files.FileName.NotHyphenatedLowercase

According to the WordPress PHP Coding Standards:

Files should be named descriptively using lowercase letters. Hyphens should separate words.

my-plugin-name.php

Source: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions

Filenames should be all lowercase with hyphens as word separators. Expected test.php, but found Test.php.

We often use the PSR-4 autoloading mechanism and therefore deviate from it.

Universal.Arrays.DisallowShortArraySyntax

According to the WordPress PHP Coding Standards:

Using long array syntax ( array( 1, 2, 3 ) ) for declaring arrays is generally more readable than short array syntax ( [ 1, 2, 3 ] ), particularly for those with vision difficulties. Additionally, it’s much more descriptive for beginners.

Arrays must be declared using long array syntax.

Source: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#declaring-arrays

Pronamic - Work with us

wp-coding-standards's People

Contributors

remcotolsma avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

wp-coding-standards's Issues

Error `trim()`: Passing `null` to parameter #1 (`$string`) of type `string` is deprecated on PHP `8.1`

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: trim(): Passing null to parameter #1 ($string) of type string is deprecated in
   |       | /Users/remco/Projects/wp-coding-standards/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php on line 280 (Internal.Exception)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.