Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions phpcs-sniffs/Tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,25 @@
* @package PluginCheck
*/

$dir_separator = DIRECTORY_SEPARATOR;
$vendor_dir = dirname( __DIR__ ) . $dir_separator . 'vendor' . $dir_separator;

// Load nikic/php-parser token compatibility before PHPCS so T_PUBLIC_SET etc are int.
// Otherwise PHPCS defines them as strings and nikic/php-parser throws on PHP 8.2+.
// This fix can be removed after minimum PHP and PHPCS/nikic packages are upgraded to versions that resolve the token-type conflict.
$nikic_compat = $vendor_dir . 'nikic' . $dir_separator . 'php-parser' . $dir_separator . 'lib' . $dir_separator . 'PhpParser' . $dir_separator . 'compatibility_tokens.php';
if ( file_exists( $nikic_compat ) ) {
require_once $nikic_compat;
}

use PHP_CodeSniffer\Util\Standards;

if ( ! defined( 'PHP_CODESNIFFER_IN_TESTS' ) ) {
define( 'PHP_CODESNIFFER_IN_TESTS', true );
}

$dir_separator = DIRECTORY_SEPARATOR;

// Define the path to the PHPCS directory.
$phpcs_path = dirname( __DIR__ ) . $dir_separator . 'vendor' . $dir_separator . 'squizlabs' . $dir_separator . 'php_codesniffer';
$phpcs_path = $vendor_dir . 'squizlabs' . $dir_separator . 'php_codesniffer';
$autoload_script_path = $phpcs_path . $dir_separator . 'autoload.php';
$bootstrap_script_path = $phpcs_path . $dir_separator . 'tests' . $dir_separator . 'bootstrap.php';

Expand Down Expand Up @@ -47,4 +56,4 @@
putenv( "PHPCS_IGNORE_TESTS={$ignore_standards_string}" );

// Cleanup.
unset( $dir_separator, $phpcs_path, $available_standards, $ignored_standards, $available_standard, $ignore_standards_string );
unset( $dir_separator, $vendor_dir, $nikic_compat, $phpcs_path, $available_standards, $ignored_standards, $available_standard, $ignore_standards_string );
10 changes: 6 additions & 4 deletions phpcs-sniffs/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@
"ext-libxml": "*",
"ext-tokenizer": "*",
"ext-xmlreader": "*",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"phpcsstandards/phpcsutils": "^1.0.8",
"squizlabs/php_codesniffer": "^3.7.2"
},
"require-dev": {
"php-parallel-lint/php-console-highlighter": "^1.0.0",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpcompatibility/php-compatibility": "^9.0",
"phpunit/phpunit": "^7.0 || ^8.0 || ^9.0",
"wp-coding-standards/wpcs": "^3.0",
"slevomat/coding-standard": "^8"
"phpcompatibility/php-compatibility": "^10.0",
"phpunit/phpunit": "^9.0",
"wp-coding-standards/wpcs": "^3.2.0",
"slevomat/coding-standard": "^8.18"
},
"suggest": {
"ext-mbstring": "For improved results"
Expand All @@ -42,6 +43,7 @@
"php": "7.4"
}
},
"minimum-stability": "alpha",
"scripts": {
"check-all": [
"@lint",
Expand Down
Loading
Loading