Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate files for multiple versions #503

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Generate files for multiple versions #503

wants to merge 1 commit into from

Conversation

shish
Copy link
Collaborator

@shish shish commented Dec 5, 2024

tl;dr:

replace

$function_list = read_docs();
generate_files($function_list, "../generated/");

with

foreach(["8.1", "8.2", "8.3", "8.4"] as $version) {
    exec("cd docs && git checkout $version");
    $function_list = read_docs();
    generate_files($function_list, "../generated/$version/");
}

generate a bunch of stubs like generated/misc.php:

<?php
if(PHP_VERSION == "8.1") require_once __DIR__ . "/8.1/misc.php";
if(PHP_VERSION == "8.2") require_once __DIR__ . "/8.2/misc.php";
if(PHP_VERSION == "8.3") require_once __DIR__ . "/8.3/misc.php";
if(PHP_VERSION == "8.4") require_once __DIR__ . "/8.4/misc.php";

This also automates generation of "deprecated" safe functions (ie, instead of hard-coding deprecated/apache.php, any functions which were generated in 8.1/apache.php but are no longer needed and thus not-generated in 8.2/apache.php will end up in 8.2/deprecated.php. Perhaps it'd be better to put them at the tail of 8.2/apache.php? PRs welcome)

Currently the Exceptions are shared between all versions, which I think is a good idea? (Thoughts, anybody?)

This isn't even remotely tested, just a proof of concept to show what this kind of approach might look like

@shish shish changed the title regenerate Generate separete wrappers for multiple PHP versions Dec 5, 2024
@shish shish marked this pull request as draft December 5, 2024 19:18
@shish shish mentioned this pull request Jan 7, 2025
9 tasks
@jhdxr
Copy link

jhdxr commented Jan 22, 2025

The CI looks unhappy because of redeclaration, probaly caused by files pending for clean up?

I think we may split this huge PR into several small PR (one for generating scripts, and one for each PHP version), which makes the PR easy to read & review.

@shish shish changed the title Generate separete wrappers for multiple PHP versions Generate files for multiple versions Jan 23, 2025
@shish shish force-pushed the pr503 branch 6 times, most recently from cfa3246 to 0d40a34 Compare January 27, 2025 12:00
tl;dr:

replace

```php
$function_list = read_docs();
generate_files($function_list, "../generated/");
```

with

```php
foreach(["8.1", "8.2", "8.3", "8.4"] as $version) {
    exec("cd docs && git checkout $version");
    $function_list = read_docs();
    generate_files($function_list, "../generated/$version/");
}
```

generate a bunch of stubs like generated/misc.php:

```php
<?php
if(PHP_VERSION == "8.1") require_once __DIR__ . "/8.1/misc.php";
if(PHP_VERSION == "8.2") require_once __DIR__ . "/8.2/misc.php";
if(PHP_VERSION == "8.3") require_once __DIR__ . "/8.3/misc.php";
if(PHP_VERSION == "8.4") require_once __DIR__ . "/8.4/misc.php";
```

This also automates generation of "deprecated" `safe` functions (ie, instead of hard-coding `deprecated/apache.php`, any functions which were generated in `8.1/apache.php` but are no longer needed and thus not-generated in `8.2/apache.php` will end up in `8.2/deprecated.php`. Perhaps it'd be better to put them at the tail of `8.2/apache.php`? PRs welcome)

Currently the `Exceptions` are shared between all versions, which I _think_ is a good idea? (Thoughts, anybody?)

This isn't even remotely tested, just a proof of concept to show what this kind of approach might look like
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