Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/Tests export-ignore
/tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpunit.xml.dist export-ignore
tests_bootstrap.php export-ignore
phpcs.xml.dist export-ignore
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor/
*.phpunit.xml
phpcs.xml
composer.lock
tests/input2
phpcs.log
41 changes: 25 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
dist: trusty
sudo: false
language: php

sudo: false
php:
- 7.1
- 7.2
- nightly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nightly should be allowed to fail


cache:
directories:
- $HOME/.composer/cache

before_install:
- composer self-update
- mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available"
- composer self-update

install: travis_retry composer update --prefer-dist

install:
- composer install --prefer-source
script:
- vendor/bin/phpcs
- vendor/bin/phpcs tests/input --report=summary --report-file=phpcs.log; diff tests/expected_report.txt phpcs.log

matrix:
include:
- php: 5.3
- php: 5.4
- php: 5.5
- php: 5.6
- php: nightly
- php: hhvm
allow_failures:
- php: nightly
- php: hhvm
jobs:
allow_failures:
- php: nightly

script: ./vendor/bin/phpunit
include:
- stage: Apply fixes
before_script:
- cp -R tests/input/ tests/input2/
script: vendor/bin/phpcbf tests/input2; diff tests/input2 tests/fixed
38 changes: 0 additions & 38 deletions Docs/README.md

This file was deleted.

29 changes: 0 additions & 29 deletions Docs/Strings/ConcatenationSpacingSniff.xml

This file was deleted.

87 changes: 17 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,108 +9,55 @@ The [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) Coding Stand
Installation
------------

You have three possibilities to use the Doctrine Coding Standard with PHP_CodeSniffer in a particular project.
You have two possibilities to use the Doctrine Coding Standard with PHP_CodeSniffer in a particular project.

### 1. Standalone installation
### 1. As a composer dependency of your project

You can install the Doctrine Coding Standard as a plugin into your global system PHP_CodeSniffer installation:

```bash
$ cd /path/to/phpcs/CodeSniffer/Standards
$ php composer create-project doctrine/coding-standard Doctrine ~0.1@dev
```

Then you can use it like
(assuming that you have the `phpcs` binary in your search path):

```bash
$ phpcs --standard=Doctrine /path/to/some/file/to/sniff.php
```

Or even set it as default standard
(assuming that you have the `phpcs` binary in your search path):

```bash
$ phpcs --config-set default_standard Doctrine
```

And just sniff a particular file with
(assuming that you have the `phpcs` binary in your search path):

```bash
$ phpcs /path/to/some/file/to/sniff.php
```

### 2. Global installation

You also can install the Doctrine Coding Standard globally:
You can install the Doctrine Coding Standard as a composer dependency to your particular project.
Just add the following block to your project's `composer.json` file:

```bash
$ php composer global require doctrine/coding-standard:~0.1@dev
$ php composer require doctrine/coding-standard:~0.1@dev
```

Then you can use it like:

```bash
$ phpcs --standard=~/.composer/vendor/doctrine/coding-standard/Doctrine /path/to/some/file/to/sniff.php
```

Or even set it as default standard:

```bash
$ phpcs --config-set default_standard ~/.composer/vendor/doctrine/coding-standard/Doctrine
$ ./vendor/bin/phpcs --standard=Doctrine /path/to/some/file/to/sniff.php
```

And just sniff a particular file with:
You might also do automatic fixes using `phpcbf`:

```bash
$ phpcs /path/to/some/file/to/sniff.php
$ ./vendor/bin/phpcbf --standard=Doctrine /path/to/some/file/to/sniff.php
```

### 3. Custom installation
### 2. Global installation

You can install the Doctrine Coding Standard anywhere you want:
You can also install the Doctrine Coding Standard globally:

```bash
$ php composer create-project doctrine/coding-standard /path/to/coding-standard/Doctrine ~0.1@dev
$ composer global require doctrine/coding-standard:~0.1@dev
```

Then you can use it like:

```bash
$ ./vendor/bin/phpcs --standard=. /path/to/some/file/to/sniff.php
```

### 4. As a composer dependency of your project

You can install the Doctrine Coding Standard as a composer dependency to your particular project.
Just add the following block to your project's `composer.json` file:

```bash
$ php composer require doctrine/coding-standard:~0.1@dev
$ phpcs --standard=Doctrine /path/to/some/file/to/sniff.php
```

Then you can use it like:
You might also do automatic fixes using `phpcbf`:

```bash
$ ./vendor/bin/phpcs --standard=vendor/doctrine/coding-standard/Doctrine /path/to/some/file/to/sniff.php
$ phpcbf --standard=Doctrine /path/to/some/file/to/sniff.php
```

Testing
-------

If you are contributing to the Doctrine Coding Standard and want to test your contribution, you have to
make sure all dependencies are correctly installed:

```bash
$ php composer install --prefer-source
```

The option `--prefer-source` is particularly necessary to ensure the test suite from PHP_CodeSniffer is
installed. Otherwise the test suite for the Doctrine Coding Standard won't work!

Run the test suite with:
If you are contributing to the Doctrine Coding Standard and want to test your contribution, you just
need to execute PHPCS with the tests folder and ensure it matches the expected report:

```bash
$ ./vendor/bin/phpunit
$ ./vendor/bin/phpcs tests/input --report=summary --report-file=phpcs.log; diff tests/expected_report.txt phpcs.log
```
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "doctrine/coding-standard",
"type": "library",
"type": "phpcodesniffer-standard",
"description": "Doctrine Coding Standard",
"keywords": ["doctrine", "coding", "standard", "cs", "code", "style", "sniffer"],
"homepage": "http://www.doctrine-project.org",
Expand All @@ -9,14 +9,16 @@
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
{"name": "Steve Müller", "email": "st.mueller@dzh-online.de"}
],
"require": {
"php": ">=5.3",
"squizlabs/php_codesniffer": "~1.0"
"autoload": {
"psr-4": {
"Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs"
}
},
"require-dev": {
"phpunit/phpunit": "~4.7"
"require": {
"php": "^7.1",
"squizlabs/php_codesniffer": "~3.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2"
},
"target-dir": "Doctrine",
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
Expand Down
Loading