Skip to content

Commit 4422f0b

Browse files
authored
Merge pull request #94 from PHPCSStandards/develop
Release 1.0.0-alpha2
2 parents 17c3692 + a6f14a1 commit 4422f0b

File tree

257 files changed

+26609
-365
lines changed

Some content is hidden

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

257 files changed

+26609
-365
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
/.gitignore export-ignore
1111
/.travis.yml export-ignore
1212
/phpcs.xml.dist export-ignore
13+
/phpdoc.xml.dist export-ignore
1314
/phpunit.xml.dist export-ignore
15+
/docs/ export-ignore
1416
/Tests/ export-ignore
1517

1618
#

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ vendor/
33
/composer.lock
44
/.phpcs.xml
55
/phpcs.xml
6+
/phpdoc.xml
67
/phpunit.xml
78
/.phpunit.result.cache

.travis.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
include:
4444
#### SNIFF STAGE ####
4545
- stage: sniff
46-
php: 7.3
46+
php: 7.4
4747
env: PHPCS_VERSION="dev-master"
4848
addons:
4949
apt:
@@ -165,12 +165,6 @@ install:
165165
if [[ $PHPCS_VERSION == "n/a" ]]; then
166166
# Don't install PHPUnit when it's not needed.
167167
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
174168
fi
175169
176170
# --prefer-dist will allow for optimal use of the travis caching ability.

CHANGELOG.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Change Log for PHPCSUtils for PHP Codesniffer
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
This projects adheres to [Keep a CHANGELOG](http://keepachangelog.com/) and uses [Semantic Versioning](http://semver.org/).
6+
7+
8+
## [Unreleased]
9+
10+
_Nothing yet._
11+
12+
13+
## [1.0.0-alpha2] - 2020-02-16
14+
15+
### Added
16+
17+
* New `PHPCSUtils\Utils\ControlStructures` class: Utility functions for use when examining control structures. [#70](https://github.com/PHPCSStandards/PHPCSUtils/pull/70)
18+
* New `PHPCSUtils\Utils\FunctionDeclarations::isArrowFunction()` method. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
19+
* New `PHPCSUtils\Utils\FunctionDeclarations::getArrowFunctionOpenClose()` method. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
20+
21+
#### PHPCS Backcompat
22+
* `BCFile::isReference()`: support for arrow functions returning by reference. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77)
23+
* `BCFile::getMethodParameters()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
24+
* `BCFile::getMethodProperties()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79), [#89](https://github.com/PHPCSStandards/PHPCSUtils/pull/89)
25+
* `BCFile::getDeclarationName()`: allow functions to be called "fn". [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77)
26+
* `BCFile::findEndOfStatement()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
27+
* `BCFile::findStartOfStatement()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77)
28+
29+
#### Tokens
30+
* New `Collections::$alternativeControlStructureSyntaxTokens` property. [#70](https://github.com/PHPCSStandards/PHPCSUtils/pull/70)
31+
* New `Collections::$alternativeControlStructureSyntaxCloserTokens` property. [#68](https://github.com/PHPCSStandards/PHPCSUtils/pull/68), [#69](https://github.com/PHPCSStandards/PHPCSUtils/pull/69)
32+
* New `Collections::$controlStructureTokens` property. [#70](https://github.com/PHPCSStandards/PHPCSUtils/pull/70)
33+
* New `Collections::arrowFunctionTokensBC()` method. [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
34+
35+
#### Utils
36+
* `Arrays::getDoubleArrowPtr()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79), [#84](https://github.com/PHPCSStandards/PHPCSUtils/pull/84)
37+
* `FunctionDeclarations::getParameters()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
38+
* `FunctionDeclarations::getProperties()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
39+
* `Operators::isReference()`: support for arrow functions returning by reference. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77)
40+
* `Parentheses::getOwner()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77)
41+
* `Parentheses::isOwnerIn()`: support for arrow functions. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77), [#79](https://github.com/PHPCSStandards/PHPCSUtils/pull/79)
42+
43+
#### Other
44+
* Documentation website at https://phpcsutils.com/
45+
46+
### Changed
47+
48+
#### PHPCS Backcompat
49+
* `BCFile::getCondition()`: sync with PHPCS 3.5.4 - added support for new `$first` parameter. [#73](https://github.com/PHPCSStandards/PHPCSUtils/pull/73)
50+
51+
#### Tokens
52+
* The `Collections::$returnTypeTokens` property now includes `T_ARRAY` to allow for supporting arrow functions in PHPCS < 3.5.3. [#77](https://github.com/PHPCSStandards/PHPCSUtils/pull/77)
53+
54+
#### Utils
55+
* :warning: `Conditions::getCondition()`: sync with PHPCS 3.5.4 - renamed the existing `$reverse` parameter to `$first` and reversing the meaning of the boolean values, to stay in line with PHPCS itself. [#73](https://github.com/PHPCSStandards/PHPCSUtils/pull/73)
56+
* :warning: `Numbers`: the `$unsupportedPHPCSVersions` property has been replaced with an `UNSUPPORTED_PHPCS_VERSION` constant.
57+
58+
#### Other
59+
* Various housekeeping.
60+
61+
62+
## 1.0.0-alpha1 - 2020-01-23
63+
64+
Initial alpha release containing:
65+
* A `PHPCS23Utils` standard which can be used to allow an external PHPCS standard to be compatible with both PHPCS 2.x as well as 3.x.
66+
* A `PHPCSUtils` standard which contains generic utilities which can be used when writing sniffs.
67+
**_This standard does not contain any sniffs!_**
68+
To use these utilities in PHPCS 3.x, all that is needed is for this package to be installed and registered with PHPCS using `installed_paths`. If the package is requested via Composer, this will automatically be handled by the [DealerDirect Composer PHPCS plugin].
69+
To use these utilities in PHPCS 2.x, make sure the external standard includes the `PHPCS23Utils` standard in the `ruleset.xml` file like so: `<rule ref="PHPCS23Utils"/>`.
70+
71+
All utilities offered are compatible with PHP_CodeSniffer 2.6.0 up to the latest stable release.
72+
73+
This initial alpha release contains the following utility classes:
74+
75+
### Abstract Sniffs
76+
* `AbstractArrayDeclarationSniff`: to examine array declarations.
77+
78+
### Backcompat
79+
* `BCFile`: Backport of the latest versions of PHPCS native utility functions from the `PHP_CodeSniffer\Files\File` class to make them available in older PHPCS versions without the bugs and other quirks that the older versions of the native functions had.
80+
* `BCTokens`: Backport of the latest versions of PHPCS native token arrays from the `PHP_CodeSniffer\Util\Tokens` class to make them available in older PHPCS versions.
81+
* `Helper`: Utility methods to retrieve (configuration) information from PHP_CodeSniffer 2.x as well as 3.x.
82+
83+
### Fixers
84+
* `SpacesFixer`: Utility to check and, if necessary, fix the whitespace between two tokens.
85+
86+
### TestUtils
87+
* `UtilityMethodTestCase`: Base class for use when testing utility methods for PHP_CodeSniffer.
88+
Compatible with both PHPCS 2.x as well as 3.x. Supports PHPUnit 4.x up to 8.x.
89+
See the usage instructions in the class docblock.
90+
91+
### Tokens
92+
* `Collections`: Collections of related tokens as often used and needed for sniffs.
93+
These are additional "token groups" to compliment the ones available through the PHPCS native `PHP_CodeSniffer\Util\Tokens` class.
94+
95+
### Utils
96+
* `Arrays`: Utility functions for use when examining arrays.
97+
* `Conditions`: Utility functions for use when examining token conditions.
98+
* `FunctionDeclarations`: Utility functions for use when examining function declaration statements.
99+
* `GetTokensAsString`: Utility functions to retrieve the content of a set of tokens as a string.
100+
* `Lists`: Utility functions to retrieve information when working with lists.
101+
* `Namespaces`: Utility functions for use when examining T_NAMESPACE tokens and to determine the namespace of arbitrary tokens.
102+
* `Numbers`: Utility functions for working with integer/float tokens.
103+
* `ObjectDeclarations`: Utility functions for use when examining object declaration statements.
104+
* `Operators`: Utility functions for use when working with operators.
105+
* `Orthography`: Utility functions for checking the orthography of arbitrary text strings.
106+
* `Parentheses`: Utility functions for use when examining parenthesis tokens and arbitrary tokens wrapped in parentheses.
107+
* `PassedParameters`: Utility functions to retrieve information about parameters passed to function calls, array declarations, isset and unset constructs.
108+
* `Scopes`: Utility functions for use when examining token scopes.
109+
* `TextStrings`: Utility functions for working with text string tokens.
110+
* `UseStatements`: Utility functions for examining use statements.
111+
* `Variables`: Utility functions for use when examining variables.
112+
113+
114+
[DealerDirect Composer PHPCS plugin]: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/
115+
116+
117+
[Unreleased]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.0-alpha2...HEAD
118+
[1.0.0-alpha2]: https://github.com/PHPCSStandards/PHPCSUtils/compare/1.0.0-alpha1...1.0.0-alpha2
119+

PHPCS23Utils/Sniffs/Load/LoadUtilsSniff.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers.
44
*
55
* @package PHPCSUtils
6-
* @copyright 2019 PHPCSUtils Contributors
6+
* @copyright 2019-2020 PHPCSUtils Contributors
77
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
88
* @link https://github.com/PHPCSStandards/PHPCSUtils
99
*/
@@ -13,7 +13,7 @@
1313
/*
1414
* Here be magic.
1515
*
16-
* This include allows for the Utility functions to work PHPCS cross-version.
16+
* This `include` allows for the Utility functions to work in both PHPCS 2.x as well as PHPCS 3.x.
1717
*/
1818
require_once \dirname(\dirname(\dirname(__DIR__))) . '/phpcsutils-autoload.php';
1919

PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers.
44
*
55
* @package PHPCSUtils
6-
* @copyright 2019 PHPCSUtils Contributors
6+
* @copyright 2019-2020 PHPCSUtils Contributors
77
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
88
* @link https://github.com/PHPCSStandards/PHPCSUtils
99
*/
@@ -483,8 +483,6 @@ public function getActualArrayKey(File $phpcsFile, $startPtr, $endPtr)
483483
* an acceptable index key for an array and if not, what it would turn into.
484484
*/
485485

486-
$integerKey = false;
487-
488486
switch (\gettype($key)) {
489487
case 'NULL':
490488
// An array key of `null` will become an empty string.

0 commit comments

Comments
 (0)