oscar-team / per-coding-standard
Oscar coding standard built on PER Coding Style 3.0.
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Type:phpcodesniffer-standard
pkg:composer/oscar-team/per-coding-standard
Requires (Dev)
- squizlabs/php_codesniffer: ^3.10
README
Coding standard for the Oscar technical team that layers project-specific sniffs on top of the PER Coding Style 3.0 specification. The standard is distributed as a PHP_CodeSniffer custom standard located at Oscar/ruleset.xml.
Custom PER Sniffs
- Namespaces.UseGrouping – rejects grouped
usestatements that append more than one namespace separator inside the group. (PER §3) - Attributes.AttributePlacement – validates attribute spacing, line placement, and parameter formatting, including adjacency to docblocks. (PER §12)
- Closures.ShortClosure – enforces arrow function spacing, indentation and semicolon placement rules. (PER §7.1)
- Functions.EmptyBody – requires empty methods/functions to collapse to
{}inline bodies with a preceding space. (PER §4.4) - Formatting.TrailingComma – ensures multi-line lists end with a comma and single-line lists do not. (PER §2.6)
All other PER/PSR-12 expectations are inherited by referencing the upstream PSR12 standard.
Installation
- Install PHP_CodeSniffer (globally or per-project), for example:
composer global require squizlabs/php_codesniffer
- Install Oscar standard (globally or per-project), for example:
composer global require oscar-team/per-coding-standard
- Register the Oscar standard so PHPCS can discover it:
phpcs --config-set installed_paths path/to/oscar-team/per-coding-standard
Example for global:phpcs --config-set installed_paths ~/.composer/vendor/oscar-team/per-coding-standardExample for project:phpcs --config-set installed_paths ~/Projects/my-project/vendor/oscar-team/per-coding-standardAlternatively, provide the ruleset path directly when runningphpcs. - Run
phpcs -ito confirm thatOscarappears in the installed standards list.
Usage
- Analyse code:
phpcs --standard=Oscar path/to/your/php/files
- Auto-fix fixable violations (where safe):
phpcbf --standard=Oscar path/to/your/php/files
Testing
- Install dependencies with
composer install. - Run the automated fixtures with
./tests/run-phpcs.sh.
Development Notes
- Baseline PSR-12 is referenced, with
Squiz.WhiteSpace.ScopeClosingBrace.ContentBeforeexcluded to avoid conflicts with inline empty bodies. - Sniffs live under
Oscar/Sniffs. - Error codes on each sniff reference the matching PER section to aid suppression and maintenance.
- Extend the ruleset by adding new
<rule>entries underOscar/ruleset.xml; PHPCS will autoload them via the configured installed path.