Skip to content

Added testing of embedded PHP snippets#3166

Open
mnocon wants to merge 6 commits into
test-yamlsfrom
test-php-snippets
Open

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

Conversation

@mnocon

@mnocon mnocon commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

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

It build upon the code samples extraction mechanism added in #3165

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

github-actions Bot commented Apr 24, 2026

Copy link
Copy Markdown

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

@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 3 times, most recently from 2e6778b to 84ab43c Compare May 17, 2026 14:16
@sonarqubecloud

Copy link
Copy Markdown

@mnocon mnocon marked this pull request as ready for review June 23, 2026 07:57
@mnocon mnocon force-pushed the test-php-snippets branch 3 times, most recently from 1bff95b to 5150030 Compare June 23, 2026 11:44
@mnocon mnocon force-pushed the test-php-snippets branch 3 times, most recently from 02b34ef to c72a5c4 Compare June 23, 2026 14:05
@mnocon mnocon force-pushed the test-php-snippets branch 2 times, most recently from e00a7df to 3c8d5ef Compare July 2, 2026 10:36
Comment thread tools/extract-inline-php.php Outdated

// Clean up the output directory from the previous run to avoid stale files
// (e.g. from docs that were renamed, moved, or had snippets removed).
removeDirectory(OUTPUT_DIR);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this OUTPUT_DIR could be used for cache but I don't see how. The code must be extracted and the hash computed to know that the extraction file already exist, so the time is lost anyway. Afterward, there the php-cs-fixer.cache that might remember already checked files.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No error to catch there if the directory can't be removed?

Comment thread tools/extract-inline-php.php Outdated
@mnocon mnocon force-pushed the test-php-snippets branch from 4806847 to 6fcae4d Compare July 3, 2026 12:51
@github-actions

github-actions Bot commented Jul 3, 2026

Copy link
Copy Markdown

Summary

Status Count
🔍 Total 758288
🔗 Unique 14993
✅ Successful 7252
⏳ Timeouts 1
🔀 Redirected 26
👻 Excluded 751026
❓ Unknown 0
🚫 Errors 9
⛔ Unsupported 0

Errors per input

Errors in site/administration/project_organization/bundles/index.html

Errors in site/api/rest_api/rest_api_usage/rest_api_usage/index.html

Errors in site/cdp/cdp_activation/cdp_data_export/index.html

Errors in site/content_management/field_types/field_type_reference/countryfield/index.html

Errors in site/recommendations/raptor_integration/connector_installation_configuration/index.html

Errors in site/recommendations/raptor_integration/raptor_connector/index.html

Errors in site/recommendations/raptor_integration/raptor_connector_guide/index.html

Errors in site/release_notes/ibexa_dxp_v4.6/index.html

Errors in site/release_notes/ibexa_dxp_v5.0/index.html

Timeouts per input

Timeouts in site/search/search_engines/solr_search_engine/install_solr/index.html

Redirects per input

Redirects in site/release_notes/ez_platform_v1.9.0/index.html

Redirects in site/release_notes/ez_platform_v3.0/index.html

Redirects in site/release_notes/ez_platform_v3.0_deprecations/index.html

Redirects in site/release_notes/ez_platform_v3.1/index.html

Redirects in site/release_notes/ibexa_dxp_v4.2/index.html

Redirects in site/resources/new_in_doc/index.html

Full Github Actions output

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.

2 participants