Download the PHP package fig-r/psr2r-sniffer without Composer

On this page you can find all versions of the php package fig-r/psr2r-sniffer. 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 psr2r-sniffer

PSR-2-R Sniffer

CI Latest Stable Version Minimum PHP Version License Total Downloads Coding Standards

For details on PSR-2-R see fig-rectified-standards.

For PHP version compatibility see version map.

Documentation @ /docs/.

This branch is for use with PHP 8.1+ repos.

Included sniffs

The following sniffers are bundles together as PSR2R already, but you can also use them standalone/separately in any way you like.

Currently, PSR2R ships with over 190 sniffs.

Furthermore, the following ones are recommended to add:

This library uses squizlabs/PHP_CodeSniffer. It can detect all issues and fix some of them automatically and is ideal for CI integration (travis, jenkins, circleci, GA etc).

Usage

How to use for your project

Most likely you are using composer. As such, put it into the require-dev dependencies:

Set up a phpcs.xml in the root of your library. Define here the standard to use as well as the project paths, usually

You can then use it like this:

The path is optional if you want to run it on a specific subset of your defined paths. Otherwise, it defaults to the paths defined in your XML file.

Customizing

You can always customize your phpcs.xml further, e.g.:

Useful commands

Verbose output with -v is always useful. With -vv or even -vvv you get even more debug output.

If you want a list of all sniffs in this standard, use -e:

It will list them all grouped by their standard name and sniff type.

To just run a single sniff, use --sniffs=... and a comma separated list of sniffs, e.g.:

Usually, if you run it over your complete repository, you would want to exclude dirs like tests/test_files/:

Windows usage

For Win OS you should be using \ as separator:

Include it in your IDE via hotkey

E.g. for PHPStorm:

Hook it into your IDE for live-correction

You can also easily make a "watcher" for your IDE, so any file you work on, will be auto-corrected when (auto-)saving. But here you should better only whitelist certain sniffs that only add things and don't remove anything.

Note: For PHPStorm, for example, make sure you switch Show Console to never to not be disturbed by it all the time.

Writing new sniffs

You can contribute by adding new sniffs as per PSR-2-R standard.

Tokenizing Tool

It really helps to see what the code looks like for the sniffer. So we can parse a PHP file into its tokens using the following tool:

(If you run this from your application, it will have to be run as vendor/bin/tokenize)

With more verbose output:

For a file MyClass.php it will create a token file MyClass.tokens.php in the same folder.

Example output of a single line of PHP code:

Using the verbose option:


All versions of psr2r-sniffer with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
php-collective/code-sniffer Version ^0.2.6
slevomat/coding-standard Version ^8.3.0
squizlabs/php_codesniffer Version ^3.7.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 fig-r/psr2r-sniffer contains the following files

Loading the files please wait ....