Skip to content

Commit

Permalink
Merge branch 'master' into docs_8
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Dec 24, 2023
2 parents 04d19b2 + c0c69e5 commit 3d14adb
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 2 deletions.
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,57 @@ CHANGELOG for PHP CS Fixer

This file contains changelogs for stable releases only.

Changelog for v3.42.0
---------------------

* chore: aim to not rely on internal array pointer but use array_key_first (#7613)
* chore: deprecate Token::isKeyCaseSensitive (#7599)
* chore: deprecate Token::isKeyCaseSensitive, 2nd part (#7601)
* chore: do not check PHP_VERSION_ID (#7602)
* chore: FileFilterIteratorTest - more accurate type in docs (#7542)
* chore: minor code cleanup (#7607)
* chore: more types (#7598)
* chore: PHPDoc key-value spacing (#7592)
* chore: PHPUnit - run defects first (#7570)
* chore: ProjectCodeTest - DRY on Tokens creation (#7574)
* chore: ProjectCodeTest - prepare for symfony/console v7 (#7605)
* chore: ProjectCodeTest::provide*ClassCases to return iterable with key for better tests execution log (#7572)
* chore: ProjectCodeTest::testDataProvidersDeclaredReturnType - use better DataProvider to simplify test logic (#7573)
* chore: TokensAnalyzer - string-enum for better typehinting (#7571)
* chore: unify tests not agnostic of PHP version (#7581)
* chore: use ::class more (#7545)
* CI: Introduce `composer-unused` (#7536)
* DX: add types to anonymous functions (#7561)
* DX: Allow running smoke tests within Docker runtime (#7608)
* DX: check fixer's options for wording (#7543)
* DX: cleanup deprecation message (#7576)
* DX: do not allow overriding constructor of `PHPUnit\Framework\TestCase` (#7563)
* DX: do not import ExpectDeprecationTrait in UtilsTest (#7562)
* DX: Enforce consistent naming in tests (#7556)
* DX: fix checking test class extends `PhpCsFixer\Tests\TestCase` (#7567)
* DX: make sure that exceptions in `AbstractFixerTestCase::testProperMethodNaming` are not already fixed (#7588)
* DX: remove recursion from AbstractIntegrationTestCase::testIntegration (#7577)
* DX: remove `PhpUnitNamespacedFixerTest::testClassIsFixed` (#7564)
* DX: remove `symfony/phpunit-bridge` (#7578)
* DX: replace fixture classes with anonymous ones (#7533)
* DX: Unify Docker mount points and paths (#7549)
* DX: unify fixer's test method names - quick wins (#7584)
* DX: unify tests for casing fixers (#7558)
* DX: use anonymous function over concrete classes (#7553)
* feat(EXPERIMENTAL): ClassKeywordFixer (#2918)
* feat(EXPERIMENTAL): ClassKeywordFixer, part 2 (#7550)
* feat(PhpdocToCommentFixer): Add option to handle return as valid docblock usage (#7401) (#7402)
* feat: Ability to import FQCNs found during analysis (#7597)
* feat: add phpDoc support for `fully_qualified_strict_types` fixer (#5620)
* feat: Handle deprecated rule sets similarly to deprecated fixers (#7288)
* feat: PhpUnitTestCaseStaticMethodCallsFixer - cover PHPUnit v10 methods (#7604)
* feat: Support more FQCNs cases in `fully_qualified_strict_types` (#7459)
* fix: AbstractFixerTestCase - fix checking for correct casing (#7540)
* fix: Better OS detection in integration tests (#7547)
* fix: NativeTypeDeclarationCasingFixe - handle static property without type (#7589)
* test: AutoReview - unify data provider returns (#7544)
* test: check to have DataProviders code agnostic of PHP version (#7575)

Changelog for v3.41.1
---------------------

Expand Down
4 changes: 2 additions & 2 deletions src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
*/
final class Application extends BaseApplication
{
public const VERSION = '3.41.2-DEV';
public const VERSION_CODENAME = 'Long Night';
public const VERSION = '3.42.1-DEV';
public const VERSION_CODENAME = 'Three Keys';

private ToolInfo $toolInfo;

Expand Down
46 changes: 46 additions & 0 deletions tests/AutoReview/ProjectCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use PhpCsFixer\Tests\TestCase;
use PhpCsFixer\Tokenizer\Token;
use PhpCsFixer\Tokenizer\Tokens;
use PhpCsFixer\Tokenizer\TokensAnalyzer;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Finder\SplFileInfo;

Expand Down Expand Up @@ -471,6 +472,51 @@ public function testExpectedInputOrder(string $testClassName): void
}
}

/**
* @dataProvider provideDataProviderMethodCases
*/
public function testDataProvidersAreNonPhpVersionConditional(string $testClassName, \ReflectionMethod $dataProvider): void
{
$dataProviderName = $dataProvider->getName();
$methodId = $testClassName.'::'.$dataProviderName;

$tokens = $this->createTokensForClass($testClassName);
$tokensAnalyzer = new TokensAnalyzer($tokens);
$dataProviderElements = array_filter($tokensAnalyzer->getClassyElements(), static function (array $v, int $k) use ($tokens, $dataProviderName) {
$nextToken = $tokens[$tokens->getNextMeaningfulToken($k)];

// element is data provider method
return 'method' === $v['type'] && $nextToken->equals([T_STRING, $dataProviderName]);
}, ARRAY_FILTER_USE_BOTH);

if (1 !== \count($dataProviderElements)) {
throw new \UnexpectedValueException(sprintf('DataProvider `%s` should be found exactly once, got %d times.', $methodId, \count($dataProviderElements)));
}

$methodIndex = array_key_first($dataProviderElements);
$startIndex = $tokens->getNextTokenOfKind($methodIndex, ['{']);
$endIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_CURLY_BRACE, $startIndex);

$versionTokens = array_filter($tokens->findGivenKind(T_STRING, $startIndex, $endIndex), static function (Token $v): bool {
return $v->equalsAny([
[T_STRING, 'PHP_VERSION_ID'],
[T_STRING, 'PHP_MAJOR_VERSION'],
[T_STRING, 'PHP_MINOR_VERSION'],
[T_STRING, 'PHP_RELEASE_VERSION'],
[T_STRING, 'phpversion'],
], false);
});

self::assertCount(
0,
$versionTokens,
sprintf(
"DataProvider '%s' should not check PHP version and provide different cases depends on it. It leads to situation when DataProvider provides 'sometimes 10, sometimes 11' test cases, depends on PHP version. That makes John Doe to see 'you run 10/10' and thinking all tests are executed, instead of actually seeing 'you run 10/11 and 1 skipped'.",
$methodId,
),
);
}

/**
* @dataProvider provideDataProviderMethodCases
*/
Expand Down

0 comments on commit 3d14adb

Please sign in to comment.