[PR #11495] feat(ci): implement automated syntax and static analysers for code samples in docs #13059

Open
opened 2026-01-22 16:16:02 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/11495

State: closed
Merged: No


This implements what was discussed in https://github.com/doctrine/orm/issues/11494.

It works roughly as follows:

  1. Iterate over all .rst files in the docs/ folder.
  2. For each of them look for a string containing whitespace and <?php.
  3. Extract the block by looking for the indentation from 2 to end.
  4. Check the content of each block against a list of ignored md5 hashes (think if this as a baseline for blocks that are too broken for PHPStan to be able to ignore them).
  5. Write each block to a file.
  6. Analyse the written files using PHPStan.

Locally you can improve existing blocks by looking for issues in the baseline. Alternatively you can edit the docs/extract.php and remove hashes from the $badBlocks array, this will lead to new errors for you to solve.
Extract blocks locally by doing php docs/extract.php docs/extracted_blocks.
Then run vendor/bin/phpstan -b phpstan-docs.neon.

Of course, before executing anything locally, read the source of docs/extract.php.

**Original Pull Request:** https://github.com/doctrine/orm/pull/11495 **State:** closed **Merged:** No --- This implements what was discussed in https://github.com/doctrine/orm/issues/11494. It works roughly as follows: 1. Iterate over all `.rst` files in the `docs/` folder. 2. For each of them look for a string containing whitespace and `<?php`. 3. Extract the block by looking for the indentation from 2 to end. 4. Check the content of each block against a list of ignored md5 hashes (think if this as a baseline for blocks that are too broken for PHPStan to be able to ignore them). 5. Write each block to a file. 6. Analyse the written files using PHPStan. Locally you can improve existing blocks by looking for issues in the baseline. Alternatively you can edit the `docs/extract.php` and remove hashes from the `$badBlocks` array, this will lead to new errors for you to solve. Extract blocks locally by doing `php docs/extract.php docs/extracted_blocks`. Then run `vendor/bin/phpstan -b phpstan-docs.neon`. Of course, before executing anything locally, read the source of `docs/extract.php`.
admin added the pull-request label 2026-01-22 16:16:02 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#13059