Skip to content

Commit 17c3692

Browse files
authored
Merge pull request #66 from PHPCSStandards/develop
1.0.0-alpha1
2 parents 0c0e832 + 0d57749 commit 17c3692

File tree

197 files changed

+32073
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+32073
-10
lines changed

.coveralls.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
coverage_clover: build/logs/clover.xml
2+
json_path: build/logs/coveralls-upload.json
3+
service_name: travis-ci

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
# https://www.reddit.com/r/PHP/comments/2jzp6k/i_dont_need_your_tests_in_my_production
66
# https://blog.madewithlove.be/post/gitattributes/
77
#
8+
/.coveralls.yml export-ignore
89
/.gitattributes export-ignore
910
/.gitignore export-ignore
1011
/.travis.yml export-ignore
12+
/phpcs.xml.dist export-ignore
13+
/phpunit.xml.dist export-ignore
14+
/Tests/ export-ignore
1115

1216
#
1317
# Auto detect text files and perform LF normalization

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1+
build/
12
vendor/
2-
composer.lock
3+
/composer.lock
4+
/.phpcs.xml
5+
/phpcs.xml
6+
/phpunit.xml
7+
/.phpunit.result.cache

.travis.yml

Lines changed: 180 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,203 @@ language: php
44

55
## Cache composer and apt downloads.
66
cache:
7+
apt: true
78
directories:
89
# Cache directory for older Composer versions.
910
- $HOME/.composer/cache/files
1011
# Cache directory for more recent Composer versions.
1112
- $HOME/.cache/composer/files
1213

1314
php:
14-
- 5.4
15-
- 7.3
15+
- 5.5
16+
- 5.6
17+
- 7.0
18+
- 7.1
19+
- 7.2
20+
21+
env:
22+
- PHPCS_VERSION="dev-master" LINT=1
23+
- PHPCS_VERSION="3.1.0"
24+
- PHPCS_VERSION="2.9.2"
25+
- PHPCS_VERSION="2.6.0"
26+
27+
# Define the stages used.
28+
# For non-PRs, only the sniff and quicktest stages are run.
29+
# For pull requests and merges, the full script is run (skipping quicktest).
30+
# Note: for pull requests, "develop" is the base branch name.
31+
# See: https://docs.travis-ci.com/user/conditions-v1
32+
stages:
33+
- name: sniff
34+
- name: quicktest
35+
if: type = push AND branch NOT IN (master, develop)
36+
- name: test
37+
if: branch IN (master, develop)
38+
- name: coverage
39+
if: branch IN (master, develop)
1640

1741
jobs:
1842
fast_finish: true
43+
include:
44+
#### SNIFF STAGE ####
45+
- stage: sniff
46+
php: 7.3
47+
env: PHPCS_VERSION="dev-master"
48+
addons:
49+
apt:
50+
packages:
51+
- libxml2-utils
52+
install: skip
53+
script:
54+
# Validate the composer.json file.
55+
# @link https://getcomposer.org/doc/03-cli.md#validate
56+
- composer validate --no-check-all --strict
57+
58+
# Check the code style of the code base.
59+
- composer travis-checkcs
60+
61+
# Validate the xml files.
62+
# @link http://xmlsoft.org/xmllint.html
63+
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCSUtils/ruleset.xml
64+
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./PHPCS23Utils/ruleset.xml
65+
66+
# Check the code-style consistency of the xml files.
67+
- diff -B ./PHPCSUtils/ruleset.xml <(xmllint --format "./PHPCSUtils/ruleset.xml")
68+
- diff -B ./PHPCS23Utils/ruleset.xml <(xmllint --format "./PHPCS23Utils/ruleset.xml")
69+
70+
#### QUICK TEST STAGE ####
71+
# This is a much quicker test which only runs the unit tests and linting against the low/high
72+
# supported PHP/PHPCS combinations.
73+
# These are basically the same builds as in the Coverage stage, but then without doing
74+
# the code-coverage.
75+
- stage: quicktest
76+
php: 7.4
77+
env: PHPCS_VERSION="dev-master" LINT=1
78+
- stage: quicktest
79+
php: 7.3
80+
# PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
81+
env: PHPCS_VERSION="2.9.2"
82+
83+
- stage: quicktest
84+
php: 5.4
85+
env: PHPCS_VERSION="dev-master" LINT=1
86+
- stage: quicktest
87+
php: 5.4
88+
env: PHPCS_VERSION="2.6.0"
89+
90+
#### TEST STAGE ####
91+
# Additional builds to prevent issues with PHPCS versions incompatible with certain PHP versions.
92+
- stage: test
93+
php: 7.3
94+
env: PHPCS_VERSION="dev-master" LINT=1
95+
- php: 7.3
96+
# PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
97+
env: PHPCS_VERSION="3.3.1"
98+
99+
- php: 5.4
100+
env: PHPCS_VERSION="3.1.0"
101+
- php: 5.4
102+
env: PHPCS_VERSION="2.9.2"
103+
104+
# PHPCS is only compatible with PHP 7.4 as of version 3.5.0.
105+
- php: 7.4
106+
env: PHPCS_VERSION="3.5.0"
107+
108+
# One extra build to verify issues around PHPCS annotations when they weren't fully accounted for yet.
109+
- php: 7.2
110+
env: PHPCS_VERSION="3.2.0"
111+
112+
- php: "nightly"
113+
env: PHPCS_VERSION="n/a" LINT=1
114+
115+
#### CODE COVERAGE STAGE ####
116+
# N.B.: Coverage is only checked on the lowest and highest stable PHP versions for all PHPCS versions.
117+
# These builds are left out off the "test" stage so as not to duplicate test runs.
118+
# The script used is the default script below, the same as for the `test` stage.
119+
- stage: coverage
120+
php: 7.4
121+
env: PHPCS_VERSION="dev-master" LINT=1 COVERALLS_VERSION="^2.0"
122+
- php: 7.3
123+
# PHPCS is only compatible with PHP 7.3 as of version 3.3.1/2.9.2.
124+
env: PHPCS_VERSION="2.9.2" COVERALLS_VERSION="^2.0"
125+
126+
- php: 5.4
127+
env: PHPCS_VERSION="dev-master" LINT=1 COVERALLS_VERSION="^1.0"
128+
- php: 5.4
129+
env: PHPCS_VERSION="2.6.0" COVERALLS_VERSION="^1.0"
130+
131+
132+
allow_failures:
133+
# Allow failures for unstable builds.
134+
- php: "nightly"
19135

20136

21137
before_install:
22138
# Speed up build time by disabling Xdebug when its not needed.
23-
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
139+
- |
140+
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Coverage" ]]; then
141+
phpenv config-rm xdebug.ini || echo 'No xdebug config.'
142+
fi
143+
144+
# On stable PHPCS versions, allow for PHP deprecation notices.
145+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
146+
- |
147+
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPCS_VERSION != "dev-master" && "$PHPCS_VERSION" != "n/a" ]]; then
148+
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
149+
fi
150+
151+
- export XMLLINT_INDENT=" "
152+
153+
154+
install:
155+
# Set up test environment using Composer.
156+
- |
157+
if [[ $PHPCS_VERSION != "n/a" ]]; then
158+
composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
159+
fi
160+
- |
161+
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
162+
composer require --dev --no-update --no-suggest --no-scripts php-coveralls/php-coveralls:${COVERALLS_VERSION}
163+
fi
164+
- |
165+
if [[ $PHPCS_VERSION == "n/a" ]]; then
166+
# Don't install PHPUnit when it's not needed.
167+
composer remove --dev phpunit/phpunit --no-update --no-scripts
168+
elif [[ "$PHPCS_VERSION" < "3.1.0" ]]; then
169+
# PHPCS < 3.1.0 is not compatible with PHPUnit 6.x.
170+
composer require --dev phpunit/phpunit:"^4.0||^5.0" --no-update --no-scripts
171+
elif [[ "$PHPCS_VERSION" < "3.2.3" ]]; then
172+
# PHPCS < 3.2.3 is not compatible with PHPUnit 7.x.
173+
composer require --dev phpunit/phpunit:"^4.0||^5.0||^6.0" --no-update --no-scripts
174+
fi
24175
25176
# --prefer-dist will allow for optimal use of the travis caching ability.
177+
# The Composer PHPCS plugin takes care of setting the installed_paths for PHPCS.
26178
- composer install --prefer-dist --no-suggest
27179

28180

181+
before_script:
182+
- if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then mkdir -p build/logs; fi
183+
- phpenv rehash
184+
185+
29186
script:
30-
# Validate the composer.json file on low/high PHP versions.
31-
# @link https://getcomposer.org/doc/03-cli.md#validate
32-
- composer validate --no-check-all --strict
187+
# Lint PHP files against parse errors.
188+
- if [[ "$LINT" == "1" ]]; then composer lint; fi
189+
190+
# Run the unit tests.
191+
- |
192+
if [[ $PHPCS_VERSION != "n/a" && "$TRAVIS_BUILD_STAGE_NAME" != "Coverage" ]]; then
193+
composer test
194+
elif [[ $PHPCS_VERSION != "n/a" && "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
195+
composer coverage
196+
fi
197+
198+
after_success:
199+
- |
200+
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^1.0" ]]; then
201+
php vendor/bin/coveralls -v -x build/logs/clover.xml
202+
fi
203+
- |
204+
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^2.0" ]]; then
205+
php vendor/bin/php-coveralls -v -x build/logs/clover.xml
206+
fi
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers.
4+
*
5+
* @package PHPCSUtils
6+
* @copyright 2019 PHPCSUtils Contributors
7+
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
8+
* @link https://github.com/PHPCSStandards/PHPCSUtils
9+
*/
10+
11+
namespace PHPCS23Utils\Sniffs\Load;
12+
13+
/*
14+
* Here be magic.
15+
*
16+
* This include allows for the Utility functions to work PHPCS cross-version.
17+
*/
18+
require_once \dirname(\dirname(\dirname(__DIR__))) . '/phpcsutils-autoload.php';
19+
20+
/**
21+
* Dummy Sniff.
22+
*
23+
* This sniff doesn't do anything. It's just here to trigger the above include.
24+
*
25+
* @since 1.0.0
26+
*/
27+
class LoadUtilsSniff
28+
{
29+
30+
/**
31+
* Returns an array of tokens this test wants to listen for.
32+
*
33+
* @return array
34+
*/
35+
public function register()
36+
{
37+
return [];
38+
}
39+
40+
/**
41+
* Processes this test, when one of its tokens is encountered.
42+
*
43+
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
44+
* @param int $stackPtr The position of the current token in
45+
* the stack passed in $tokens.
46+
*
47+
* @return void
48+
*/
49+
public function process($phpcsFile, $stackPtr)
50+
{
51+
}
52+
}

PHPCS23Utils/ruleset.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHPCS23Utils" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
3+
<description>Standard which makes the PHPCSUtils utility methods for external PHPCS standards available in PHPCS 2.x.</description>
4+
</ruleset>

0 commit comments

Comments
 (0)