Skip to content

Commit

Permalink
Merge pull request #1090 from WordPress-Coding-Standards/hotfix/issue…
Browse files Browse the repository at this point in the history
…-1087

Hotfix: temporary plaster to fix issue 1087
  • Loading branch information
GaryJones authored Aug 5, 2017
2 parents 2d69383 + 3b00b81 commit 1f64b1a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
4 changes: 4 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your WP

The WordPress Coding Standards are compatible with both PHPCS 2.x as well as 3.x. This has some implications for running the unit tests.

* Make sure you have registered the directory in which you installed WPCS with PHPCS using;
```sh
phpcs --config-set installed_path path/to/WPCS
```
* Navigate to the directory in which you installed WPCS.
* To run the unit tests with PHPCS 3.x:
```sh
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a C

_Nothing yet._

## [0.13.1] - 2017-08-07

### Fixed
- Fatal error when using PHPCS 3.x with the `installed_paths` config variable set via the ruleset.

## [0.13.0] - 2017-08-03

### Added
Expand Down Expand Up @@ -458,6 +463,7 @@ See the comparison for full list.
Initial tagged release.

[Unreleased]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/master...HEAD
[0.13.1]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.13.0...0.13.1
[0.13.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.12.0...0.13.0
[0.12.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.11.0...0.12.0
[0.11.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.10.0...0.11.0
Expand Down
26 changes: 0 additions & 26 deletions Test/phpcs3-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,3 @@
// Load our class aliases.
include_once dirname( __DIR__ ) . $ds . 'WordPress' . $ds . 'PHPCSAliases.php';
unset( $ds, $phpcsDir );

/*
* Register our own autoloader for the WPCS abstract classes & the helper class.
*
* This can be removed once the minimum required version of WPCS for the
* PHPCS 3.x branch has gone up to 3.1.0 (unreleased as of yet).
*
* @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1564
*/
spl_autoload_register( function ( $class ) {
// Only try & load our own classes.
if ( stripos( $class, 'WordPress' ) !== 0 ) {
return;
}

// PHPCS handles the Test and Sniff classes without problem.
if ( stripos( $class, '\Tests\\' ) !== false || stripos( $class, '\Sniffs\\' ) !== false ) {
return;
}

$file = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . strtr( $class, '\\', DIRECTORY_SEPARATOR ) . '.php';

if ( file_exists( $file ) ) {
include_once $file;
}
} );
28 changes: 28 additions & 0 deletions WordPress/PHPCSAliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,32 @@ class_alias( 'PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\OperatorSpacingS
}

define( 'WPCS_PHPCS_ALIASES_SET', true );

/*
* Register our own autoloader for the WPCS abstract classes & the helper class.
*
* This can be removed once the minimum required version of WPCS for the
* PHPCS 3.x branch has gone up to 3.1.0 (unreleased as of yet) or
* whichever version contains the fix for upstream #1591.
*
* @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1564
* @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1591
*/
spl_autoload_register( function ( $class ) {
// Only try & load our own classes.
if ( stripos( $class, 'WordPress' ) !== 0 ) {
return;
}

// PHPCS handles the Test and Sniff classes without problem.
if ( stripos( $class, '\Tests\\' ) !== false || stripos( $class, '\Sniffs\\' ) !== false ) {
return;
}

$file = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . strtr( $class, '\\', DIRECTORY_SEPARATOR ) . '.php';

if ( file_exists( $file ) ) {
include_once $file;
}
} );
}

0 comments on commit 1f64b1a

Please sign in to comment.