Skip to content

Commit

Permalink
Merge pull request #71 from PHPCSStandards/develop
Browse files Browse the repository at this point in the history
Release 1.0.0-alpha3
  • Loading branch information
jrfnl committed Jun 29, 2020
2 parents 65e057f + 51e0cb4 commit a8415f9
Show file tree
Hide file tree
Showing 71 changed files with 3,576 additions and 53 deletions.
68 changes: 40 additions & 28 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ php:

env:
jobs:
# `master`
# PHPCS `master`.
- PHPCS_VERSION="dev-master" LINT=1
# Lowest supported PHPCS version.
- PHPCS_VERSION="3.3.1"
Expand All @@ -32,19 +32,28 @@ env:
# See: https://docs.travis-ci.com/user/conditions-v1
stages:
- name: sniff
- name: validate
- name: quicktest
if: type = push AND branch NOT IN (master, develop)
if: type = push AND branch NOT IN (stable, develop)
- name: test
if: branch IN (master, develop)
if: branch IN (stable, develop)
- name: coverage
if: branch IN (master, develop)
if: branch IN (stable, develop)

jobs:
fast_finish: true

include:
#### SNIFF STAGE ####
- stage: sniff
php: 7.4
install: skip
before_script: skip
script:
# Check the code style of the code base.
- composer travis-checkcs

- stage: validate
php: 7.4
env: PHPCS_VERSION="dev-master"
addons:
Expand All @@ -56,9 +65,6 @@ jobs:
# @link https://getcomposer.org/doc/03-cli.md#validate
- composer validate --no-check-all --strict

# Check the code style of the code base.
- composer travis-checkcs

# Validate the xml files.
# @link http://xmlsoft.org/xmllint.html
- xmllint --noout --schema ./vendor/squizlabs/php_codesniffer/phpcs.xsd ./NormalizedArrays/ruleset.xml
Expand Down Expand Up @@ -96,8 +102,11 @@ jobs:
- php: 7.3
env: PHPCS_VERSION="dev-master" LINT=1

- php: 7.4
env: PHPCS_VERSION="4.0.x-dev@dev"

- php: "nightly"
env: PHPCS_VERSION="n/a" LINT=1
env: PHPCS_VERSION="dev-master" LINT=1

#### CODE COVERAGE STAGE ####
# N.B.: Coverage is only checked on the lowest and highest stable PHP versions for all PHPCS versions.
Expand All @@ -117,12 +126,13 @@ jobs:
allow_failures:
# Allow failures for unstable builds.
- php: "nightly"
- env: PHPCS_VERSION="4.0.x-dev@dev"


before_install:
# Speed up build time by disabling Xdebug when its not needed.
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Coverage" ]]; then
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" != "Coverage" ]]; then
phpenv config-rm xdebug.ini || echo 'No xdebug config.'
fi
Expand All @@ -131,35 +141,37 @@ before_install:
# 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" && "$PHPCS_VERSION" != "n/a" ]]; then
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
install:
# Set up test environment using Composer.
- composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
- |
if [[ $PHPCS_VERSION != "n/a" ]]; then
composer require --no-update --no-scripts squizlabs/php_codesniffer:${PHPCS_VERSION}
fi
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" ]]; then
composer require --no-update --no-suggest --no-scripts php-coveralls/php-coveralls:${COVERALLS_VERSION}
fi
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Sniff" || $PHPCS_VERSION == "n/a" ]]; then
# The sniff stage doesn't run the unit tests, so no need for PHPUnit.
# The build on nightly also doesn't run the tests (yet).
composer remove --dev phpunit/phpunit --no-update --no-scripts
if [[ "${PHPCS_VERSION:0:3}" == "4.0" ]]; then
# Remove devtools as it will not (yet) install on PHPCS 4.x.
composer remove --dev phpcsstandards/phpcsdevtools --no-update
# --prefer-source ensures that the PHPCS native unit test framework will be available in PHPCS 4.x.
composer install --prefer-source --no-suggest
elif [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
# Ignore PHPUnit platform requirements for installing on nightly.
composer install --prefer-dist --no-suggest --ignore-platform-reqs
else
# --prefer-dist will allow for optimal use of the travis caching ability.
composer install --prefer-dist --no-suggest
fi
# --prefer-dist will allow for optimal use of the travis caching ability.
# The Composer PHPCS plugin takes care of setting the installed_paths for PHPCS.
- composer install --prefer-dist --no-suggest
# The Composer PHPCS plugin takes care of setting the installed_paths for PHPCS.
before_script:
- if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then mkdir -p build/logs; fi
- if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" ]]; then mkdir -p build/logs; fi
- phpenv rehash


Expand All @@ -169,18 +181,18 @@ script:

# Run the unit tests.
- |
if [[ $PHPCS_VERSION != "n/a" && "$TRAVIS_BUILD_STAGE_NAME" != "Coverage" ]]; then
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" != "Coverage" ]]; then
composer test
elif [[ $PHPCS_VERSION != "n/a" && "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" ]]; then
elif [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" ]]; then
composer coverage
fi
after_success:
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^1.0" ]]; then
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" && $COVERALLS_VERSION == "^1.0" ]]; then
php vendor/bin/coveralls -v -x build/logs/clover.xml
fi
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" == "Coverage" && $COVERALLS_VERSION == "^2.0" ]]; then
if [[ "${TRAVIS_BUILD_STAGE_NAME^}" == "Coverage" && $COVERALLS_VERSION == "^2.0" ]]; then
php vendor/bin/php-coveralls -v -x build/logs/clover.xml
fi
51 changes: 49 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,54 @@ This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses

_Nothing yet._

## [1.0.0-alpha3] - 2020-06-29

## 1.0.0-alpha2 - 2020-02-18
### Added

#### Universal

* :wrench: :books: New `Universal.Arrays.DisallowShortArraySyntax` sniff to disallow short array syntax. [#40](https://github.com/PHPCSStandards/PHPCSExtra/pull/40)
In contrast to the PHPCS native `Generic.Arrays.DisallowShortArraySyntax` sniff, this sniff will ignore short list syntax and not cause parse errors when the fixer is used.
* :wrench: :bar_chart: :books: New `Universal.Constants.UppercaseMagicConstants` sniff to enforce that PHP native magic constants are in uppercase. [#64](https://github.com/PHPCSStandards/PHPCSExtra/pull/64)
* :bar_chart: :books: New `Universal.Namespaces.DisallowDeclarationWithoutName` sniff to disallow namespace declarations without a namespace name. [#50](https://github.com/PHPCSStandards/PHPCSExtra/pull/50)
* :bar_chart: :books: New `Universal.Operators.DisallowLogicalAndOr` sniff to enforce the use of the boolean `&&` and `||` operators instead of the logical `and`/`or` operators. [#52](https://github.com/PHPCSStandards/PHPCSExtra/pull/52)
Note: as the [operator precedence](https://www.php.net/manual/en/language.operators.precedence.php) of the logical operators is significantly lower than the operator precedence of boolean operators, this sniff does not contain an auto-fixer.
* :bar_chart: :books: New `Universal.Operators.DisallowShortTernary` sniff to disallow the use of short ternaries `?:`. [#42](https://github.com/PHPCSStandards/PHPCSExtra/pull/42)
While short ternaries are useful when used correctly, the principle of them is often misunderstood and they are more often than not used incorrectly, leading to hard to debug issues and/or PHP warnings/notices.
* :wrench: :bar_chart: :books: New `Universal.Operators.DisallowStandalonePostIncrementDecrement` sniff disallow the use of post-in/decrements in stand-alone statements and discourage the use of multiple increment/decrement operators in a stand-alone statement. [#65](https://github.com/PHPCSStandards/PHPCSExtra/pull/65)
* :wrench: :bar_chart: :books: New `Universal.Operators.StrictComparisons` sniff to enforce the use of strict comparisons. [#48](https://github.com/PHPCSStandards/PHPCSExtra/pull/48)
Warning: the auto-fixer for this sniff _may_ cause bugs in applications and should be used with care! This is considered a _risky_ fixer.
* :wrench: :bar_chart: :books: New `Universal.OOStructures.AlphabeticExtendsImplements` sniff to verify that the names used in a class "implements" statement or an interface "extends" statement are listed in alphabetic order. [#55](https://github.com/PHPCSStandards/PHPCSExtra/pull/55)
* This sniff contains a public `orderby` property to determine the sort order to use for the statement.
If all names used are unqualified, the sort order won't make a difference.
However, if one or more of the names are partially or fully qualified, the chosen sort order will determine how the sorting between unqualified, partially and fully qualified names is handled.
The sniff supports two sort order options:
- _'name'_ : sort by the interface name only (default);
- _'full'_ : sort by the full name as used in the statement (without leading backslash).
In both cases, the sorting will be done using natural sort, case-insensitive.
* The sniff has modular error codes to allow for selective inclusion/exclusion:
- `ImplementsWrongOrder` - for "class implements" statements.
- `ImplementsWrongOrderWithComments` - for "class implements" statements interlaced with comments. These will not be auto-fixed.
- `ExtendsWrongOrder` - for "interface extends" statements.
- `ExtendsWrongOrderWithComments` - for "interface extends" statements interlaced with comments. These will not be auto-fixed.
* When fixing, the existing spacing between the names in an `implements`/`extends` statement will not be maintained.
The fixer will separate each name with a comma and one space.
If alternative formatting is desired, a sniff which will check and fix the formatting should be added to the ruleset.
* :wrench: :bar_chart: :books: New `Universal.UseStatements.LowercaseFunctionConst` sniff to enforce that `function` and `const` keywords when used in an import `use` statement are always lowercase. [#58](https://github.com/PHPCSStandards/PHPCSExtra/pull/58)
* :wrench: :bar_chart: :books: New `Universal.UseStatements.NoLeadingBackslash` sniff to verify that a name being imported in an import `use` statement does not start with a leading backslash. [#46](https://github.com/PHPCSStandards/PHPCSExtra/pull/46)
Names in import `use` statements should always be fully qualified, so a leading backslash is not needed and it is strongly recommended not to use one.
This sniff handles all types of import use statements supported by PHP, in contrast to other sniffs for the same in, for instance, the PSR12 or the Slevomat standard, which are incomplete.
* :wrench: :books: New `Universal.WhiteSpace.DisallowInlineTabs` sniff to enforce using spaces for mid-line alignment. [#43](https://github.com/PHPCSStandards/PHPCSExtra/pull/43)

### Changed

#### Other
* The `master` branch has been renamed to `stable`.
* Composer: The version requirements for the [DealerDirect Composer PHPCS plugin] have been widened to allow for version 0.7.0 which supports Composer 2.0.0. [#62](https://github.com/PHPCSStandards/PHPCSExtra/pull/62)
* Various housekeeping.


## [1.0.0-alpha2] - 2020-02-18

### Added

Expand Down Expand Up @@ -104,5 +150,6 @@ This initial alpha release contains the following sniffs:
Individual sub-types can be allowed by excluding specific error codes.


[Unreleased]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.0-alpha2...HEAD
[Unreleased]: https://github.com/PHPCSStandards/PHPCSExtra/compare/stable...HEAD
[1.0.0-alpha3]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.0-alpha2...1.0.0-alpha3
[1.0.0-alpha2]: https://github.com/PHPCSStandards/PHPCSExtra/compare/1.0.0-alpha1...1.0.0-alpha2
Loading

0 comments on commit a8415f9

Please sign in to comment.