PHPUnit's assertStringContainsString() and assertStringNotContainsString() take the needle first, then the haystack, which is the opposite of PHP's strpos(). This results in an incorrect fix.
Steps to Reproduce:
mkdir /tmp/test
cd /tmp/test
cat <<'EOF' > test.php
<?php
class FooTest {
function test() {
$this->assertFalse( strpos( $haystack, $needle ) );
$this->assertNotFalse( strpos( $haystack, $needle ) );
$this->assertIsInt( strpos( $haystack, $needle ) );
}
}
EOF
composer require mediawiki/mediawiki-codesniffer
vendor/bin/phpcbf --standard=vendor/mediawiki/mediawiki-codesniffer/MediaWiki/ruleset.xml test.phpActual Results:
test.php contains
<?php class FooTest { function test() { $this->assertStringNotContainsString( $haystack, $needle ); $this->assertStringContainsString( $haystack, $needle ); $this->assertStringContainsString( $haystack, $needle ); } }
Expected Results:
test.php contains
<?php class FooTest { function test() { $this->assertStringNotContainsString( $needle, $haystack ); $this->assertStringContainsString( $needle, $haystack ); $this->assertStringContainsString( $needle, $haystack ); } }