Search by

pieceofcake2 / phpcs-cakephp2

ttsurupieceofcake2

PHP_CodeSniffer ruleset for CakePHP 2 applications and plugins, based on the CakePHP coding standard

Package info

github.com/pieceofcake2/phpcs-cakephp2

Type:phpcodesniffer-standard

pkg:composer/pieceofcake2/phpcs-cakephp2

Statistics

Installs: 14 879

Dependents: 35

Suggesters: 0

Stars: 0

v1.2.0 2026-10-23 03:40 UTC

README

GitHub License Packagist Version PHP CI

A PHP_CodeSniffer standard for CakePHP 2 applications and plugins running on pieceofcake2/cakephp. It is the CakePHP standard of cakephp/cakephp-codesniffer 5.x, with the exceptions that CakePHP 2 code needs: no namespaces, App::uses(), underscored controller actions, DATABASE_CONFIG and no native types in signatures. The CakePHP rules are used as they are, not copied, so their updates arrive with cakephp/cakephp-codesniffer.

The package has two standards:

  • CakePHP2 for code with global classes, the way CakePHP 2 has always worked (App::uses(), no namespaces).
  • CakePHP2Namespace for code whose classes are in namespaces, as CakePHP 2.13 allows (namespace App\Controller;, use statements, PSR-4). It is CakePHP2 with the namespace rules turned back on, and with class names in annotations imported like in the code.

Documentation

The Markdown documentation is also included in the Composer package, at vendor/pieceofcake2/phpcs-cakephp2/docs/README.md. Install the package with --dev if you only need it for development.

Requirements

  • PHP 8.1+ to run PHP_CodeSniffer (installable on PHP 8.0)
  • cakephp/cakephp-codesniffer 5.x

Installation

composer require --dev pieceofcake2/phpcs-cakephp2

Allow the dealerdirect/phpcodesniffer-composer-installer plugin when Composer asks. Then use the standard in your phpcs.xml:

<?xml version="1.0"?>
<ruleset>
    <file>./src</file>
    <file>./tests</file>

    <rule ref="CakePHP2"/>
</ruleset>

If your classes are in namespaces, use <rule ref="CakePHP2Namespace"/> instead.

Contributing

See the contribution guidelines.

License

Licensed under the MIT License. See LICENSE.