You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I might be able to help set this up.
Started on a proof of concept extractor already.
<?php$lines = file(__DIR__ . '/en/tutorials/composite-primary-keys.rst', FILE_IGNORE_NEW_LINES);
$indent = null;
$blockCounter = 0;
$block = [];
foreach($linesas$i => $line) {
// Check if this is the start of a php block.if ($indent === null && preg_match('/^(\s*)\<\?php/', $line, $matches)) {
echo"Start PHP block\n";
$indent = strlen($matches[1]);
$block[] = "<?php //Extracted from line $i\n";
} elseif ($indent !== null && preg_match("/^\s{{$indent}}(.*)|^()$/", $line, $matches)) {
$block[] = ($matches[1] ?? ''); // . "\t\t\t\t# Extracted from line $i";
} elseif ($indent !== null) {
$indent = null;
print_r($block);
file_put_contents("/tmp/check/block{$blockCounter}.php", implode("\n", $block));
$blockCounter++;
$block = [];
}
}
The idea is simple:
Parse each .rst file crudely extracting PHP code blocks.
Add missing imports automatically (or decide that we want copy paste friendly docs and just add missing imports to the examples)
Run phpstan to analyse the code.
The extractor above also adds a comment to know where we got it from:
<?php//Extracted from line 112namespaceVehicleCatalogue\Model;
// $em is the EntityManager$car = newCar("Audi A8", 2010);
$em->persist($car);
$em->flush();
I'll look into creating a github action that just does this for all RST files in a directory.
The text was updated successfully, but these errors were encountered:
Originally posted by @greg0ire in #11492 (comment)
I might be able to help set this up.
Started on a proof of concept extractor already.
The idea is simple:
.rst
file crudely extracting PHP code blocks.phpstan
to analyse the code.The extractor above also adds a comment to know where we got it from:
I'll look into creating a github action that just does this for all RST files in a directory.
The text was updated successfully, but these errors were encountered: