Sider Documentation

Sider Documentation

  • Enterprise
  • News
  • Sider Top

›PHP

Getting Started

  • Home
  • Intro Videos
  • Setting up Sider
  • Dashboard Overview
  • Repository Settings
  • Custom Analysis Configuration
  • Recommended Ruleset
  • Working with Issues
  • Permissions
  • Skip Analyzing

Analysis Tools

    Ruby

    • RuboCop
    • Reek
    • Querly
    • Rails Best Practices
    • Brakeman
    • HAML-Lint
    • Slim-Lint (beta)

    Java

    • Checkstyle
    • PMD
    • JavaSee

    Kotlin

    • ktlint (beta)
    • detekt (beta)

    JavaScript and Flavors

    • ESLint
    • JSHint
    • TyScan
    • CoffeeLint
    • TSLint (deprecated)

    CSS

    • stylelint
    • SCSS-Lint (deprecated)

    PHP

    • PHP_CodeSniffer
    • PHPMD
    • Phinder

    Python

    • Flake8
    • Pylint (beta)

    Swift

    • SwiftLint

    Go

    • GolangCI-Lint

    C/C++

    • Cppcheck
    • cpplint
    • Clang-Tidy (beta)

    C#

    • FxCop (beta)

    Shell script

    • ShellCheck

    Dockerfile

    • hadolint

    Markdown

    • remark-lint

    Others

    • Goodcheck
    • Misspell
    • LanguageTool (beta)
    • PMD CPD (beta)

Custom Rules

  • Intro to Custom Rules
  • Goodcheck
  • Tips & Tricks

Advanced Settings

  • Inline Comments
  • Private Dependencies
  • Restricting access to Close button
  • Transferring a repository

Billing and Plans

  • Billing and Plans

Troubleshooting

  • Troubleshooting

Enterprise

  • Outline
  • System Overview
  • Installation
  • Configuration
  • Operation
  • Update
  • Load Balancer
  • MySQL
  • Redis
  • MinIO
  • Amazon S3
  • GitHub Enterprise Server
  • Clustering
  • Example Deployments

    • Single Node with Docker Compose

    Releases

    • Overview
    • January 2021
    • December 2020
    • October 2020
    • September 2020
    • August 2020
    • July 2020
    • June 2020
    • May 2020
    • April 2020
    • February 2020
    • January 2020
    • November 2019
    • Older releases

News

  • 2021
  • 2020
  • 2019
Edit

PHP_CodeSniffer

Supported VersionLanguageWebsite
3.5.8PHPhttps://pear.php.net/package/PHP_CodeSniffer

PHP_CodeSniffer is a style checker to enforce a defined set of PHP coding standards.

Getting Started

To start using PHP_CodeSniffer, enable it in your repository settings. To configure the coding standard you want to follow, add sider.yml in your repository and set the standard option:

linter:
  code_sniffer:
    dir: app/
    standard: CakePHP

Default Configuration

If you don't specify anything, Sider tries to detect the standard and target directory for your project automatically. If it cannot find an appropriate standard, it assumes PSR2 as its standard and analyzes all PHP files in your repository.

Standard and Analysis Target

Sider tries to detect the most suitable standard and target directory for your project, based on the framework your project is using.

The following standards are detected automatically:

  • CakePHP
  • Symfony

The auto-detection is based on file names and directory structure in your repository. If this auto-detection fails, you can specify a standard in sider.yml.

Configuration via sider.yml

An example setting for PHP_CodeSniffer under code_sniffer:

linter:
  code_sniffer:
    dir: app/
    standard: phpcs.xml
    extensions: php,inc,lib
    encoding: utf-8
    ignore:
      - app/vendor
      - test/ignored.php

You can use several options to fine-tune PHP_CodeSniffer to your project:

NameTypeDefault
root_dirstring-
dirstring.
standardstringPSR2
extensionsstring, string[]php
encodingstring-
ignorestring, string[][]

dir

This option controls directories to be analyzed. The default value is dependent on the frameworks PHP_CodeSniffer supports. If you are not using any frameworks or are using a framework PHP_CodeSniffer does not support, . is used.

If you would like to exclude specific directories, you can specify them in a custom ruleset file.

standard

This option controls a coding standard of your project. If you leave this value empty, Sider tries to detect the standard automatically. PSR2 is used when auto detection fails.

You can use the following third-party standards in addition to the standards which PHP_CodeSniffer supports natively:

  • Symfony
  • CakePHP
  • WordPress

If you want to see the actual standard lists, run the command phpcs -i. The following output is a standard list that we prepare.

$ phpcs -i
The installed coding standards are Zend, PSR12, MySource, Squiz, PSR2, PSR1, PEAR, CakePHP, Symfony, WordPress, WordPress-Extra, WordPress-Docs and WordPress-Core

You can also define your own standard, and enter the path to the config file here.

extensions

This option controls a comma-separated list of file extensions to be analyzed. You also can specify an array of extensions.

encoding

This option controls an encoding of files to be analyzed.

ignore

This option controls a comma-separated list of file or directory patterns to be ignored. You also can specify an array of patterns.

← SCSS-Lint (deprecated)PHPMD →
  • Getting Started
  • Default Configuration
    • Standard and Analysis Target
  • Configuration via sider.yml
    • dir
    • standard
    • extensions
    • encoding
    • ignore
Sider Documentation
Docs
Getting StartedAnalysis ToolsEnterprise
Sider
Sider TopTerms of ServicePrivacy
Social
BlogGitHubStar
Copyright © 2021 Sider, Inc.