Nextcloud Coding Standard
Nextcloud's shared PHP CS Fixer ruleset for Nextcloud apps and server code
Repository Health
Technical Analysis
nextcloud/coding-standard packages Nextcloud’s PHP coding-standard rules as a reusable PHP CS Fixer configuration class. Instead of every Nextcloud app or server module re-declaring the same fixer rule set by hand, projects install this package, instantiate its Config class in their .php-cs-fixer.dist.php, and get Nextcloud’s house style (plus a curated set of extra fixers from kubawerlos/php-cs-fixer-custom-fixers) applied automatically.
It bundles PHP CS Fixer itself (via php-cs-fixer/shim) as a dependency, so consuming projects only need to add this one package as a dev dependency to get both the fixer and Nextcloud’s specific rule configuration.
What You Get
- A
Nextcloud\CodingStandard\Configclass implementing PHP CS Fixer’s config interface with Nextcloud’s house rule set pre-applied - Bundled
php-cs-fixer/shimdependency, so installing this one package provides both the fixer and Nextcloud’s ruleset - Integration of
kubawerlos/php-cs-fixer-custom-fixersfor additional style rules beyond PHP CS Fixer’s built-ins - Ready-to-copy
composer.jsonscript entries (cs:check,cs:fix) for dry-run diff checking and in-place fixing - A documented upgrade path (v0.x to v1.0) tracking PHP CS Fixer’s own v2-to-v3 migration
Common Use Cases
- Applying Nextcloud’s exact PHP coding style to a Nextcloud server app without copying its
.php-cs-fixer.dist.phprules by hand - Keeping a fleet of related PHP projects (e.g. multiple Nextcloud apps maintained by the same team) style-consistent by sharing one config dependency
- Wiring
cs:check/cs:fixcomposer scripts into CI so pull requests are checked against Nextcloud’s house style automatically - Bootstrapping a new Nextcloud app’s linting setup in minutes instead of hand-configuring PHP CS Fixer rule-by-rule
Under The Hood
Architecture The entire package is a single class, src/Config.php, which extends/implements PHP CS Fixer’s own ConfigInterface machinery to pre-populate a Finder and rule set matching Nextcloud’s conventions; consuming projects import this class into their own .php-cs-fixer.dist.php entry point and customize only the finder’s include/exclude paths, leaving the rule set itself centrally owned by this package.
Tech Stack It’s a PHP 8.0+ Composer package (type: library, PSR-4 autoloaded under Nextcloud\CodingStandard\) with php-cs-fixer/shim and kubawerlos/php-cs-fixer-custom-fixers as its only two dependencies, so installing it transitively pulls in a working PHP CS Fixer binary alongside the shared config.
Code Quality Given the package’s single-class, configuration-only scope, correctness is largely validated by downstream usage across Nextcloud’s own apps and server codebase rather than a dedicated internal test suite; its own lint composer script runs php -l over its (minimal) source as a basic syntax check, and a maintained CHANGELOG.md tracks rule-set changes across releases.
API Design The integration surface is intentionally tiny — new Config() plus finder configuration — mirroring PHP CS Fixer’s own config-object pattern so teams already familiar with PHP CS Fixer need essentially no new concepts to adopt it.