Skip to content

Added testing of embedded PHP snippets#3166

Draft
mnocon wants to merge 2 commits into
test-yamlsfrom
test-php-snippets
Draft

Added testing of embedded PHP snippets#3166
mnocon wants to merge 2 commits into
test-yamlsfrom
test-php-snippets

Conversation

@mnocon
Copy link
Copy Markdown
Contributor

@mnocon mnocon commented Apr 24, 2026

This PR makes it possible to run code quality checks (PHPStan, CS-Fixer, Rector, Deptrac) on embedded PHP code samples.

Thanks to this, we no longer need to extract the code samples to separate files - they can stay within the Markdown files, making it easier to work with them, while keeping the advantage of the code quality tools.

How it works

Before a code quality tool is run, the code samples are extracted from Markdown files.

They are not extracted if:

  • the code sample uses one of the include_file/include_code functions
  • the code sample is marked with {skip-validation}

The rest of them are extracted to code_samples/_inline_php for the tools to pick up.

When the tool can automatically fix the issue (CS-Fixer, Rector), the changes are synced back to the Markdown files.

All the existing inline code samples are marked with {skip-validation}, a special attribute to disable the code sample checking.

This keeps this PR small and allow us using this for new content - the fixing of code samples will be done in a follow-up (#3206)

@mnocon mnocon changed the base branch from 5.0 to test-yamls April 24, 2026 07:13
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 24, 2026

Preview of modified files: Too many files modified in a single PR, preview link list is skipped. (309 files > 100)

@mnocon mnocon force-pushed the test-php-snippets branch from ccd63b3 to 7463431 Compare May 16, 2026 12:48
@mnocon mnocon changed the title Test and fix embedded PHP snippets Added testing of embedded PHP snippets May 16, 2026
@mnocon mnocon force-pushed the test-php-snippets branch 2 times, most recently from 5bdb095 to b767494 Compare May 17, 2026 13:35
@mnocon mnocon force-pushed the test-php-snippets branch from 2e6778b to 84ab43c Compare May 17, 2026 14:16
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant