Download the PHP package chancedigital/wp-coding-standards without Composer

On this page you can find all versions of the php package chancedigital/wp-coding-standards. 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 wp-coding-standards

Chance Digital WordPress Coding Standards

Build Status

This is a codified version of the Chance Digital PHP CodeSniffer rules. It began as a fork of the the Human Made coding standards.

Setup

  1. composer require --dev chancedigital/wp-coding-standards
  2. Run the following command to run the standards checks:

The final . here specifies the files you want to test; this is typically the current directory (.), but you can also selectively check files or directories by specifying them instead.

You can add this to your Travis YAML file as a test:

Excluding Files

This standard includes special support for a .phpcsignore file (in the future, this should be built into phpcs itself). Simply place a .phpcsignore file in your root directory (wherever you're going to run phpcs from).

The format of this file is similar to .gitignore and similar files: one pattern per line, comment lines should start with a #, and whitespace-only lines are ignored:

Note that the patterns should match the PHP_CodeSniffer style: * is translated to .* for convenience, but all other characters work like a regular expression.

Patterns are relative to the directory that the .phpcsignore file lives in. On load, they are translated to absolute patterns: e.g. */tests/* in /your/dir/.phpcsignore will become /your/dir/.*/tests/.* as a regular expression. This differs from the regular PHP_CodeSniffer practice.

Advanced/Extending

If you want to add further rules (such as WordPress.com VIP-specific rules), you can create your own custom standard file (e.g. phpcs.ruleset.xml):

You can then reference this file when running phpcs:

Excluding/Disabling Checks

You can also customise the rule to exclude elements if they aren't applicable to the project:

Rules can also be disabled inline. phpcs rules can be disabled with a // @codingStandardsIgnoreLine comment.

To find out what these codes are, specify -s when running phpcs, and the code will be output as well. You can specify a full code, or a partial one to disable groups of errors.

Included Checks

The phpcs standard is based upon the WordPress-Extra standard from WordPress Coding Standards, with customisation and additions to match our style guide.

Testing

Running tests

To run the tests locally, you'll need the source version of PHP CodeSniffer.

If you haven't already installed your Composer dependencies:

If you already have, and need to convert the phpcs directory to a source version:

Writing sniff tests

To add tests you should mirror the directory structure of the sniffs. For example a test for ChanceDigital/Sniffs/Layout/OrderSniff.php would require the following files:

Effectively you are replacing the suffix Sniff.php with UnitTest.php.

A basic unit test class looks like the following:

Fixture Tests

Rather than testing sniffs individually, FixtureTests.php also tests the files in the tests/fixtures directory and ensures that whole files pass.

To add an expected-pass file, simply add it into tests/fixtures/pass in the appropriate subdirectory/file.

To add an expected-fail file, add it into tests/fixtures/fail in the appropriate subdirectory/file. You then need to add the expected errors to the JSON file accompanying the tested file (i.e. the filename with .json appended). This file should contain a valid JSON object keyed by line number, with each item being a list of error objects:

An error object contains:


All versions of wp-coding-standards with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
wp-coding-standards/wpcs Version ^2.1.0
fig-r/psr2r-sniffer Version ^0.5.0
squizlabs/php_codesniffer Version ^3.4.2
dealerdirect/phpcodesniffer-composer-installer Version ^0.5.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 chancedigital/wp-coding-standards contains the following files

Loading the files please wait ...