Download the PHP package digitoimistodude/dude-coding-standards without Composer
On this page you can find all versions of the php package digitoimistodude/dude-coding-standards. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download digitoimistodude/dude-coding-standards
More information about digitoimistodude/dude-coding-standards
Files in digitoimistodude/dude-coding-standards
Package dude-coding-standards
Short Description Dude Coding Standards (DCS) for WordPress theme and plugin development
License MIT
Informations about the package dude-coding-standards
Dude Coding Standards (DCS)
[!NOTE] Please note: The Dude Coding Standard is a work in progress. We're in the process of replacing WordPress-Core standard in dudestack with our own DSC standard, the one you are currently looking at (internal reference: DEV-624). This PHPCS standard is used by Dude staff and may not provide additional value for external developers.
PHP_CodeSniffer and Stylelint rules for WordPress theme and plugin development at Digitoimisto Dude Oy.
This repository contains:
- PHPCS standard (DCS) - via Composer
- Stylelint config - via npm
PHPCS Installation
The standard will be automatically registered with PHP_CodeSniffer via the Composer installer plugin.
Usage
In phpcs.xml
Create a phpcs.xml in your project root:
Command line
With custom configuration
You can override rules in your project's phpcs.xml:
What's included
DCS is based on WordPress Coding Standards with Dude-specific customizations:
Code style
- 2-space indentation instead of tabs
- Short array syntax
[]allowed (instead ofarray()) - Relaxed commenting requirements
- Flexible function formatting with spaces
- ...and more in the future
Security
All WordPress security sniffs are enabled:
WordPress.Security.NonceVerificationWordPress.Security.ValidatedSanitizedInputWordPress.Security.EscapeOutput- And more...
PHP compatibility
Checks code compatibility with > PHP 8.3 using PHPCompatibilityWP.
Development functions
error_log() and print_r() are allowed but flagged as warnings to remind you to review before deployment.
Excluded rules
The following WordPress rules are excluded for Dude's workflow:
- Yoda conditions (
WordPress.PHP.YodaConditions) - Strict file naming (
WordPress.Files.FileName) - Tab indentation (
Generic.WhiteSpace.DisallowSpaceIndent) - Long array syntax requirement (
Universal.Arrays.DisallowShortArraySyntax) - See DCS/ruleset.xml for the full list
Adding forbidden functions
To add more forbidden functions to your project, create a custom sniff or override in your phpcs.xml:
Development and local testing
If you want to test DCS locally before the package is published, first install dependencies in dude-coding-standards:
Then add path repository to your project's composer.json:
Run composer update in your project:
Note: Path repositories create symlinks, so any changes you make to dude-coding-standards are instantly available in your test project without reinstalling.
Check that DCS is available:
Create phpcs.xml in your project, can be as simple as this:
Run phpcs:
You can also run phpcs directly from dude-coding-standards against your project:
Check the standard itself for development:
Stylelint Config
Installation
Usage
Create .stylelintrc in your project root:
If you ever need to add project based exclusions, use rules in your project:
Overriding rules
See stylelint.config.js for all rules.
Contributing (Dude staff)
Adding excludes
When you encounter a rule that should be excluded globally, add it to DCS/ruleset.xml:
Important: Don't include full rulesets like <rule ref="Generic"> or <rule ref="Squiz">. WordPress already includes specific rules from these standards. Only disable individual rules that conflict with Dude's style.
Find the rule name from the phpcs error output (shown when using -s flag).
Release cycle
- Make changes to
DCS/ruleset.xml - Update
CHANGELOG.mdwith new version and changes -
Commit and push:
- Tag a new release:
The GitHub Actions workflow will automatically create a release when a new tag is pushed.
Projects using the package can update with:
Note: Projects using path repository (symlink) get changes instantly without updating.
References
All versions of dude-coding-standards with dependencies
squizlabs/php_codesniffer Version ^3.13
phpcsstandards/phpcsutils Version ^1.0
phpcsstandards/phpcsextra Version ^1.2.0
wp-coding-standards/wpcs Version ^3.0
phpcompatibility/php-compatibility Version ^9.3
phpcompatibility/phpcompatibility-wp Version ^2.1
dealerdirect/phpcodesniffer-composer-installer Version ^1.0