Skip to content

rentpost/coding-standard-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

296 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RentPost Coding Standard for PHP

A reusable PHP_CodeSniffer ruleset plus the related static-analysis dependencies that RentPost uses across its PHP codebases.

Overview

This package provides a single phpcs.xml that combines hand-picked rules from Slevomat, the standard PHP_CodeSniffer sniffs (PSR/Generic/Squiz/PEAR/Zend), and a few RentPost-flavoured tweaks.

The goal is to surface coding-style problems so they can be fixed thoughtfully — not to auto-rewrite code. Tools like PHP-CS-Fixer are intentionally not part of this package; we prefer that developers learn the rules and fix violations themselves rather than rely on automated rewrites.

Installation

Add this package as a dev dependency:

composer require --dev rentpost/coding-standard-php

Then point your phpcs invocation at the bundled ruleset:

vendor/bin/phpcs --standard=vendor/rentpost/coding-standard-php/phpcs.xml src/

Most editors/IDEs with a PHP_CodeSniffer plugin support pointing at a custom phpcs.xml path — point them at vendor/rentpost/coding-standard-php/phpcs.xml.

Optional: Git hooks

A simple pre-commit hook template is bundled under .git-hooks/. It runs phpcs and phpstan against staged files. The hook is disabled by default (it starts with exit 0); remove that line and adjust the vendorPath variable to your project's vendor directory if you want to use it.

To install the bundled hook into your repo's .git/hooks/, run:

vendor/bin/init-githooks ./vendor

The argument is the path to your composer vendor directory relative to the repository root. The script copies hooks from this package into .git/hooks/ and substitutes the vendorPath placeholder in each.

Configuring static analysis

The package also pulls in PHPStan as a dependency. This repo does not ship a default phpstan.neon; configure your project's PHPStan ruleset however suits your code base.

Going forward

Future expansion may include:

About

Coding standards for all RentPost repositories

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors