-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I'm testing my code using phpcs and wpcs on Travis CI and I received this error when the build failed.
Fatal error: Uncaught Error: Class 'PHP_CodeSniffer\Tests\FileList' not found in /home/travis/build/nepmisdev/partners_arissto/vendor/squizlabs/php_codesniffer/tests/Core/AllTests.php:42
Stack trace:
#0 /home/travis/build/nepmisdev/partners_arissto/vendor/squizlabs/php_codesniffer/tests/AllTests.php(59): PHP_CodeSniffer\Tests\Core\AllTests::suite()
#1 [internal function]: PHP_CodeSniffer\Tests\PHP_CodeSniffer_AllTests::suite('PHP_CodeSniffer...')
#2 /home/travis/build/nepmisdev/partners_arissto/vendor/phpunit/phpunit/src/Runner/BaseTestRunner.php(125): ReflectionMethod->invoke(NULL, 'PHP_CodeSniffer...')
#3 /home/travis/build/nepmisdev/partners_arissto/vendor/phpunit/phpunit/src/TextUI/Command.php(183): PHPUnit\Runner\BaseTestRunner->getTest('./vendor/squizl...', '/home/travis/bu...', Array)
#4 /home/travis/build/nepmisdev/partners_arissto/vendor/phpunit/phpunit/src/TextUI/Command.php(162): PHPUnit\TextUI\Command->run(Array, true)
#5 /home/travis/build/nepmisdev/partners_arissto/vendor/phpunit/phpunit/phpunit(61): PHPUnit in /home/travis/build/nepmisdev/partners_arissto/vendor/squizlabs/php_codesniffer/tests/Core/AllTests.php on line 42
What I understand from the error is that the class 'PHP_CodeSniffer\Tests\FileList' can't be loaded due to the 'T' in the 'Test' directory being capitalized while the directory should be 'test', am I interpreting this correctly?
This is the .travis.yml for my project
dist: trusty
cache:
apt: true
directories:
# Cache directory for older Composer versions.
- $HOME/.composer/cache/files
# Cache directory for more recent Composer versions.
- $HOME/.cache/composer/files
language: php
php:
- 7.1
- 7.2
- 7.3
- 7.4
- "nightly"
env:
# PHPCS master.
- PHPCS_BRANCH="dev-master" LINT=1
# Lowest supported release in the 3.x series with which WPCS is compatible.
- PHPCS_BRANCH="3.5.0"
# Define the stages used.
# For non-PRs, only the sniff, ruleset and quicktest stages are run.
# For pull requests and merges, the full script is run (skipping quicktest).
# Note: for pull requests, "develop" should be the base branch name.
# See: https://docs.travis-ci.com/user/conditions-v1
stages:
- name: sniff
- name: quicktest
if: branch NOT IN (master, develop)
- name: test
if: branch IN (master, develop)
jobs:
fast_finish: true
include:
#### SNIFF STAGE ####
- stage: sniff
php: 7.4
env: PHPCS_BRANCH="dev-master"
addons:
apt:
packages:
- libxml2-utils
before_script:
- export PHPCS_DIR=/tmp/phpcs
- export SNIFFS_DIR=/tmp/sniffs
- git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR
- git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_DIR
script:
# WordPress Coding Standards.
# @link https://github.com/WordPress/WordPress-Coding-Standards
# @link http://pear.php.net/package/PHP_CodeSniffer/
# - $PHPCS_DIR/bin/phpcs --runtime-set ignore_warnings_on_exit 1
_# Validate the xml files.
# @link http://xmlsoft.org/xmllint.html
# For the build to properly error when validating against a scheme, these each have to be in their own condition.
- xmllint --noout --schema $PHPCS_DIR/phpcs.xsd ./*/ruleset.xml
# - xmllint --noout --schema $PHPCS_DIR/phpcs.xsd $PHPCS_DIR/phpcs.xml.dist.sample_
_# Check the code-style consistency of the xml files.
- diff -B --tabsize=4 $SNIFFS_DIR/WordPress/ruleset.xml <(xmllint --format "$SNIFFS_DIR/WordPress/ruleset.xml")
- diff -B --tabsize=4 $SNIFFS_DIR/WordPress-Core/ruleset.xml <(xmllint --format "$SNIFFS_DIR/WordPress-Core/ruleset.xml")
- diff -B --tabsize=4 $SNIFFS_DIR/WordPress-Docs/ruleset.xml <(xmllint --format "$SNIFFS_DIR/WordPress-Docs/ruleset.xml")
- diff -B --tabsize=4 $SNIFFS_DIR/WordPress-Extra/ruleset.xml <(xmllint --format "$SNIFFS_DIR/WordPress-Extra/ruleset.xml")
- diff -B --tabsize=4 $SNIFFS_DIR/phpcs.xml.dist.sample <(xmllint --format "$SNIFFS_DIR/phpcs.xml.dist.sample")_
_# Validate the composer.json file.
# @link https://getcomposer.org/doc/03-cli.md#validate
- composer validate --no-check-all --strict_
_# Check that the sniffs available are feature complete.
# For now, just check that all sniffs have unit tests.
# At a later stage the documentation check can be activated.
- composer check-complete_
_#### QUICK TEST STAGE ####
# This is a much quicker test which only runs the unit tests and linting against the low/high
# supported PHP/PHPCS combinations.
- stage: quicktest
php: 7.4
env: PHPCS_BRANCH="dev-master" LINT=1
- php: 7.3
env: PHPCS_BRANCH="3.5.0"
- php: 7.0
env: PHPCS_BRANCH="3.5.0"
- php: 5.4
env: PHPCS_BRANCH="3.5.0"_
_#### TEST STAGE ####
# Add extra build to test against PHPCS 4.
- stage: test
php: 7.4
env: PHPCS_BRANCH="4.0.x-dev as 3.9.99"_
allow_failures:
# Allow failures for unstable builds.
- php: "nightly"
- env: PHPCS_BRANCH="4.0.x-dev as 3.9.99"
before_install:
# Speed up build time by disabling Xdebug.
# https://johnblackbourn.com/reducing-travis-ci-build-times-for-wordpress-projects/
# https://twitter.com/kelunik/status/954242454676475904
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
_# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
- |
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" != "Sniff" && $PHPCS_BRANCH != "dev-master" ]]; then
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
fi
- export XMLLINT_INDENT=" "_
install:
_- |
if [[ ${PHPCS_BRANCH:0:2} == "4." ]]; then
# Set Composer up to download only PHPCS from source for PHPCS 4.x.
# The source is needed to get the base testcase from PHPCS.
composer config preferred-install.squizlabs/php_codesniffer source
else
composer config preferred-install.squizlabs/php_codesniffer auto
fi
- composer require squizlabs/php_codesniffer:"${PHPCS_BRANCH}" --no-update --no-suggest --no-scripts
- |
if [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
# requirements to get PHPUnit 7.x to install on nightly.
composer install --ignore-platform-reqs --no-suggest
else
# Do a normal dev install in all other cases.
composer install --no-suggest
fi
script:
# Lint the PHP files against parse errors.
- if [[ "$LINT" == "1" ]]; then composer lint; fi_
# Run the unit tests.
- composer run-tests
So, is there any workaround for this or am I doing something wrong cause this shouldn't be an issue?
P.S.: this is my first issue, please let me know if i did something bad on opening issues