Download the PHP package slevomat/coding-standard without Composer

On this page you can find all versions of the php package slevomat/coding-standard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package coding-standard

Slevomat Coding Standard

Latest version Downloads Build status Code coverage PHPStan

Slevomat Coding Standard for PHP_CodeSniffer provides sniffs that fall into three categories:

Table of contents

  1. Alphabetical list of sniffs
  2. Installation
  3. How to run the sniffs
    • Choose which sniffs to run
    • Exclude sniffs you don't want to run
  4. Fixing errors automatically
  5. Suppressing sniffs locally
  6. Contributing

Alphabetical list of sniffs

🔧 = Automatic errors fixing

🚧 = Sniff check can be suppressed locally

Installation

The recommended way to install Slevomat Coding Standard is through Composer.

It's also recommended to install php-parallel-lint/php-parallel-lint which checks source code for syntax errors. Sniffs count on the processed code to be syntactically valid (no parse errors), otherwise they can behave unexpectedly. It is advised to run PHP-Parallel-Lint in your build tool before running PHP_CodeSniffer and exiting the build process early if PHP-Parallel-Lint fails.

How to run the sniffs

You can choose one of two ways to run only selected sniffs from the standard on your codebase:

Choose which sniffs to run

The recommended way is to write your own ruleset.xml by referencing only the selected sniffs. This is a sample ruleset.xml:

Then run the phpcs executable the usual way:

Exclude sniffs you don't want to run

You can also mention Slevomat Coding Standard in your project's ruleset.xml and exclude only some sniffs:

However it is not a recommended way to use Slevomat Coding Standard, because your build can break when moving between minor versions of the standard (which can happen if you use ^ or ~ version constraint in composer.json). We regularly add new sniffs even in minor versions meaning your code won't most likely comply with new minor versions of the package.

Fixing errors automatically

Sniffs in this standard marked by the 🔧 symbol support automatic fixing of coding standard violations. To fix your code automatically, run phpcbf instead of phpcs:

Always remember to back up your code before performing automatic fixes and check the results with your own eyes as the automatic fixer can sometimes produce unwanted results.

Suppressing sniffs locally

Selected sniffs in this standard marked by the 🚧 symbol can be suppressed for a specific piece of code using an annotation. Consider the following example:

The parameter $max could have a native int scalar typehint. But because the method in the parent class does not have this typehint, so this one cannot have it either. PHP_CodeSniffer shows a following error:

If we want to suppress this error instead of fixing it, we can take the error code (SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint) and use it with a @phpcsSuppress annotation like this:

Contributing

To make this repository work on your machine, clone it and run these two commands in the root directory of the repository:

After writing some code and editing or adding unit tests, run phing again to check that everything is OK:

We are always looking forward to your bugreports, feature requests and pull requests. Thank you.

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.


All versions of coding-standard with dependencies

PHP Build Version
Package Version
Requires php Version ^7.2 || ^8.0
dealerdirect/phpcodesniffer-composer-installer Version ^0.6.2 || ^0.7 || ^1.0
phpstan/phpdoc-parser Version ^1.23.1
squizlabs/php_codesniffer Version ^3.9.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package slevomat/coding-standard contains the following files

Loading the files please wait ....