Skip to content

Commit f509789

Browse files
committed
Update dependencies. Rename tests. Fix deprecations
1 parent aaceba3 commit f509789

14 files changed

+52
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ composer.phar
22
/vendor
33
phpcs-report.xml
44
composer.lock
5+
.phpunit.result.cache
56

67
# Mac OS custom attribute store and thumbnails
78
*.DS_Store

CHANGELOG.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ The semantic versioning started from version 0.2.1.
1010

1111
_No documentation available about unreleased changes yet._
1212

13+
## [3.0.1](https://github.com/infinum/eightshift-coding-standards/compare/3.0.0...3.0.1)
14+
15+
### Changed
16+
- Updated dependencies. PHPUnit had a security vulnerability that needed to be addressed. More recent versions of PHPUnit (v10+) introduced breaking changes that would require a major version bump. Priority of this release was to fix the security vulnerability.
17+
- Added exclude to deprecated ruleset since WordPressCS v3.3.0. Covered by PHPCompatibilityWP.
18+
- Renamed tests.
19+
1320
## [3.0.0](https://github.com/infinum/eightshift-coding-standards/compare/2.0.0...3.0.0)
1421

1522
### Changed
@@ -60,7 +67,7 @@ _No documentation available about unreleased changes yet._
6067
- Add ignoreComments property for the line length sniff
6168

6269
### Fixed
63-
- Fixed the edge case with overwriting libs classes.
70+
- Fixed the edge case with overwriting libs classes.
6471

6572
### Changed
6673
- Code cleanup in EightShift ComponentsEscape sniff
@@ -76,22 +83,22 @@ _No documentation available about unreleased changes yet._
7683

7784
### Fixed
7885
- Fixed `Eightshift.Security.ComponentsEscape` sniff
79-
- There was a case where the next string token caused issue because there was no guard clause
86+
- There was a case where the next string token caused issue because there was no guard clause
8087
to check if the string is actually a Components class or not.
8188

8289

8390
## [1.4.0](https://github.com/infinum/eightshift-coding-standards/compare/1.3.0...1.4.0) - 2022-03-09
8491

8592
### Added
86-
- EightShift ruleset: add rules for use statements
93+
- EightShift ruleset: add rules for use statements
8794
- Adds a new dependency on the Slevomat Coding Standard library.
8895
- Adds four sniffs from this coding standard to the ruleset:
8996
1. Forbidding unused `use` statements.
9097
2. Enforcing fully qualified global functions and constants.
9198
3. Enforcing import `use` statements for everything else.
9299
- Includes fixing up the EightShift coding standards code base for these new rules.
93100
- Ref: https://github.com/slevomat/coding-standard
94-
- Add new EightShift FunctionComment sniff
101+
- Add new EightShift FunctionComment sniff
95102
- This sniff overloads the `Squiz.Commenting.FunctionComment` sniff which normally comes included via the `WordPress-Docs` ruleset and makes an allowance for the `__invoke` method in the CLI classes.
96103
- Includes:
97104
- Unit tests.
@@ -157,7 +164,7 @@ A huge thanks to Juliette Reinders Folmer (@jrfnl) for amazing help in fixing to
157164

158165
### Changed
159166
- Updated sniffs namespace
160-
167+
161168
### Fixed
162169
- Fix docblocks in the sniffs
163170

@@ -181,7 +188,7 @@ We renamed the package from `infinum/coding-standards-wp` to `infinum/eightshift
181188

182189
This is the official release of the Eightshift coding standards for WordPress. It contains breaking changes, mostly in
183190
regard
184-
of the naming scheme.
191+
of the naming scheme.
185192
To equate the way we write our PHP and JS we opted to follow a modified PSR standards.
186193
What this means is that we will remove liberal spacing, add some PSR12 modifications regarding arguments placing in closures, change snake_case with CamelCase for classes (for autoload puropses) and some other minor changes that will be documented below.
187194
If you wish to use the old standards, be sure to modify your projects `composer.json` file with the appropriate version.
File renamed without changes.

Eightshift/Sniffs/Security/HelpersEscapeSniff.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,17 @@ public function process_token($stackPtr)
111111
}
112112
}
113113

114-
// Check for Helpers string token.
115-
$helpersClassNamePtr = $phpcsFile->findNext(\T_STRING, ($stackPtr + 1), null, false, 'Helpers');
114+
// Check for Helpers string token that is followed by the double colon (static method call).
115+
// We need the class name "Helpers", not a namespace segment "Helpers".
116+
$helpersClassNamePtr = false;
117+
$searchPtr = $stackPtr;
118+
119+
while (($searchPtr = $phpcsFile->findNext(\T_STRING, ($searchPtr + 1), null, false, 'Helpers')) !== false) {
120+
if (isset($tokens[$searchPtr + 1]) && $tokens[$searchPtr + 1]['code'] === \T_DOUBLE_COLON) {
121+
$helpersClassNamePtr = $searchPtr;
122+
break;
123+
}
124+
}
116125

117126
if (!$helpersClassNamePtr) {
118127
// If there is no Helpers down the line, just run the regular sniff.
@@ -180,7 +189,10 @@ public function process_token($stackPtr)
180189
$checkedClassName = \explode('\\', $className);
181190
$firstNamespacePart = $checkedClassName[0];
182191

183-
if ($lastNamespacePart === $firstNamespacePart) {
192+
// For partial imports, the className must contain multiple parts (e.g. Helpers\Helpers::method())
193+
// A single-part className like Helpers::method() with a partial import to the namespace
194+
// would resolve to the namespace, not the class.
195+
if ($lastNamespacePart === $firstNamespacePart && \count($checkedClassName) > 1) {
184196
// Correctly used class name.
185197
$methodNamePtr = $phpcsFile->findNext(
186198
\T_STRING,

Eightshift/Tests/Security/ComponentsEscapeUnitTest.1.inc renamed to Eightshift/Tests/Security/HelpersEscapeUnitTest.1.inc

File renamed without changes.

Eightshift/Tests/Security/ComponentsEscapeUnitTest.2.inc renamed to Eightshift/Tests/Security/HelpersEscapeUnitTest.2.inc

File renamed without changes.

Eightshift/Tests/Security/ComponentsEscapeUnitTest.3.inc renamed to Eightshift/Tests/Security/HelpersEscapeUnitTest.3.inc

File renamed without changes.

Eightshift/Tests/Security/ComponentsEscapeUnitTest.4.inc renamed to Eightshift/Tests/Security/HelpersEscapeUnitTest.4.inc

File renamed without changes.

Eightshift/Tests/Security/ComponentsEscapeUnitTest.5.inc renamed to Eightshift/Tests/Security/HelpersEscapeUnitTest.5.inc

File renamed without changes.

Eightshift/Tests/Security/ComponentsEscapeUnitTest.6.inc renamed to Eightshift/Tests/Security/HelpersEscapeUnitTest.6.inc

File renamed without changes.

0 commit comments

Comments
 (0)