Skip to content

[Testing] Check fixtures use *.php.inc suffix, not bare *.inc - #8306

Merged
TomasVotruba merged 1 commit into
mainfrom
fixture-php-inc-suffix
Aug 6, 2026
Merged

[Testing] Check fixtures use *.php.inc suffix, not bare *.inc#8306
TomasVotruba merged 1 commit into
mainfrom
fixture-php-inc-suffix

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

yieldFilesFromDirectory() defaults to a *.php.inc suffix, so a fixture named *.inc is silently never executed. 8 such files existed in the repo — including 2 accidental file-manager duplicates named * copy.inc.

Script change

scripts/no-php-file-in-fixtures.php already rejected *.php files in Fixture/. It now also rejects any *.inc that is not *.php.inc, and covers tests/ in addition to rules-tests/.

     private function findIncompleteIncFiles(array $directories): array
     {
         $finder = new Finder()
             ->files()
             ->in($directories)
             ->path('/Fixture')
             ->notPath('Source')
+            ->name('*.inc')
+            ->notName('*.php.inc')

Output on the offending state:

 [ERROR] The following files were found in /Fixtures directory, but only
         "*.php.inc" files are picked up and allowed. Rename their suffix or
         remove them

 * rules-tests/Arguments/.../ArgumentAdderRector/Fixture/skip_named_arguments.inc
 * rules-tests/Php73/.../SetcookieRector/Fixture/skip_non_integer_third_arg.inc
 * rules-tests/Php83/.../JsonValidateRector/Fixture/skip_json_validate_invalid_depth.php copy.inc
 * rules-tests/Php85/.../ArrayFirstLastRector/Fixture/skip_as_assign_variable.inc
 * rules-tests/TypeDeclaration/.../AddParamTypeBasedOnPHPUnitDataProviderRector/Fixture/skip_with_nested_method.inc
 * rules-tests/TypeDeclaration/.../BoolReturnTypeFromBooleanStrictReturnsRector/Fixture/skip_possible_void.inc
 * rules-tests/TypeDeclaration/.../ReturnUnionTypeRector/Fixture/change_nullable_union_different_in_parent.php copy.inc
 * tests/Issues/InlineTags/Fixture/with_punctuation.inc

Fixture triage

6 renamed to *.php.inc and now run — all pass, so this recovers real coverage that was dead:

  • ArgumentAdderRector/Fixture/skip_named_arguments
  • SetcookieRector/Fixture/skip_non_integer_third_arg
  • JsonValidateRector/Fixture/skip_json_validate_invalid_depth (was .php copy.inc)
  • ArrayFirstLastRector/Fixture/skip_as_assign_variable
  • AddParamTypeBasedOnPHPUnitDataProviderRector/Fixture/skip_with_nested_method
  • BoolReturnTypeFromBooleanStrictReturnsRector/Fixture/skip_possible_void

1 had a stale expectationtests/Issues/InlineTags/Fixture/with_punctuation.php.inc. Its expected output predates #6674 and dropped part of the docblock text. Actual current output is correct (text preserved verbatim), so the expectation was corrected to match:

- * @copyright Some Value. {@link https://example.com}.
+ * @copyright Some Value. Something.({@link https://example.com}).

1 removedReturnUnionTypeRector/Fixture/change_nullable_union_different_in_parent.php copy.inc. Never passed: it expects ReturnUnionTypeRector to add ?\stdClass where the parent declares the same return, which the rule does not do. Unimplemented-feature WIP, not a regression guard, so it is deleted rather than revived.

Bare "*.inc" files in Fixture/ directories are never picked up by
yieldFilesFromDirectory(), which defaults to a "*.php.inc" suffix.
8 such files existed and silently never ran, 2 of them accidental
"* copy.inc" file-manager duplicates.

Extend scripts/no-php-file-in-fixtures.php to report them, and cover
tests/ as well as rules-tests/ for this check.
@TomasVotruba
TomasVotruba merged commit a265831 into main Aug 6, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the fixture-php-inc-suffix branch August 6, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant