Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility-fix for PHPCS 3.4.0 #1517

Merged
merged 1 commit into from Nov 2, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPress/Tests/PHP/TypeCastsUnitTest.inc
Expand Up @@ -17,7 +17,7 @@ $a = (real) $b;
// Warning: Discouraged casts.
$a = (unset) $b; // Warning.
$a = (binary) $b; // Warning.
$a = b"binary string"; // Warning. Currently false negative. Related to PHPCS bug report #1574.
$a = b"binary string"; // Warning.
$a = b"binary $string"; // Warning.

// Error: Mixed case.
Expand Down
2 changes: 1 addition & 1 deletion WordPress/Tests/PHP/TypeCastsUnitTest.inc.fixed
Expand Up @@ -17,7 +17,7 @@ $a = (float) $b;
// Warning: Discouraged casts.
$a = (unset) $b; // Warning.
$a = (binary) $b; // Warning.
$a = b"binary string"; // Warning. Currently false negative. Related to PHPCS bug report #1574.
$a = b"binary string"; // Warning.
$a = b"binary $string"; // Warning.

// Error: Mixed case.
Expand Down
3 changes: 2 additions & 1 deletion WordPress/Tests/PHP/TypeCastsUnitTest.php
Expand Up @@ -10,6 +10,7 @@
namespace WordPress\Tests\PHP;

use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
use WordPress\PHPCSHelper;

/**
* Unit test class for the TypeCasts sniff.
Expand Down Expand Up @@ -67,7 +68,7 @@ public function getWarningList() {
return array(
18 => 1,
19 => 1,
// 20 => 1,
20 => ( version_compare( PHPCSHelper::get_version(), '3.4.0', '<' ) === true ? 0 : 1 ),
21 => 1,
34 => 1,
35 => 1,
Expand Down
7 changes: 7 additions & 0 deletions WordPress/Tests/PHP/YodaConditionsUnitTest.inc
Expand Up @@ -135,3 +135,10 @@ function is_windows() {
if ( $something == ( false !== ( $test_is_windows = getenv( 'WP_CLI_TEST_IS_WINDOWS' ) ) ? (bool) $test_is_windows : 0 === stripos( PHP_OS, 'WIN' ) ) ) {} // Bad.

if ( ( false !== ( $test_is_windows = getenv( 'WP_CLI_TEST_IS_WINDOWS' ) ) ? (bool) $test_is_windows : 0 === stripos( PHP_OS, 'WIN' ) ) === $something ) {} // OK.

// Test with binary casts.
if ( (binary) $binary === b"binary $foo" ) { // Bad x 1.
echo 'True';
} elseif ( b"binary $foo" === (binary) $binary ) { // Good.
echo 'False';
}
1 change: 1 addition & 0 deletions WordPress/Tests/PHP/YodaConditionsUnitTest.php
Expand Up @@ -46,6 +46,7 @@ public function getErrorList() {
119 => 1,
125 => 1,
135 => 1,
140 => 1,
);
}

Expand Down
6 changes: 6 additions & 0 deletions WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.inc
Expand Up @@ -49,3 +49,9 @@ wp_enqueue_script( 'someScript-js' ); // OK.

wp_register_style( 'someScript-js' ); // OK.
wp_enqueue_style( 'someScript-js' ); // OK.

wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), (bool) 1, true ); // OK.
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), (bool) 0, true ); // Error - 0, false or NULL are not allowed.

wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), (binary) 123, true ); // OK.
wp_register_script( 'someScript-js', 'https://example.com/someScript.js' , array( 'jquery' ), b'0', true ); // Error - 0, false or NULL are not allowed.
2 changes: 2 additions & 0 deletions WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php
Expand Up @@ -39,6 +39,8 @@ public function getErrorList() {
39 => 1,
42 => 1,
45 => 1,
54 => 1,
57 => 1,
);
}

Expand Down