Skip to content

Commit

Permalink
Generate files for multiple versions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
shish committed Jan 27, 2025
1 parent 81210ac commit cfa3246
Show file tree
Hide file tree
Showing 500 changed files with 215,921 additions and 40,315 deletions.
17 changes: 4 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,10 @@
"lib/DateTime.php",
"lib/DateTimeImmutable.php",
"lib/Exceptions/",
"deprecated/Exceptions/",
"generated/Exceptions/"
],
"files": [
"deprecated/apc.php",
"deprecated/array.php",
"deprecated/datetime.php",
"deprecated/libevent.php",
"deprecated/misc.php",
"deprecated/password.php",
"deprecated/mssql.php",
"deprecated/stats.php",
"deprecated/strings.php",
"lib/special_cases.php",
"deprecated/mysqli.php",
"generated/apache.php",
"generated/apcu.php",
"generated/array.php",
Expand All @@ -43,6 +32,7 @@
"generated/ftp.php",
"generated/funchand.php",
"generated/gettext.php",
"generated/gmp.php",
"generated/gnupg.php",
"generated/hash.php",
"generated/ibase.php",
Expand All @@ -60,6 +50,7 @@
"generated/mbstring.php",
"generated/misc.php",
"generated/mysql.php",
"generated/mysqli.php",
"generated/network.php",
"generated/oci8.php",
"generated/opcache.php",
Expand All @@ -72,7 +63,6 @@
"generated/ps.php",
"generated/pspell.php",
"generated/readline.php",
"generated/rnp.php",
"generated/rpminfo.php",
"generated/rrd.php",
"generated/sem.php",
Expand All @@ -98,7 +88,8 @@
"generated/yaml.php",
"generated/yaz.php",
"generated/zip.php",
"generated/zlib.php"
"generated/zlib.php",
"generated/rnp.php"
]
},
"require": {
Expand Down
11 changes: 0 additions & 11 deletions deprecated/Exceptions/LibeventException.php

This file was deleted.

11 changes: 0 additions & 11 deletions deprecated/Exceptions/MssqlException.php

This file was deleted.

15 changes: 0 additions & 15 deletions deprecated/Exceptions/PasswordException.php

This file was deleted.

11 changes: 0 additions & 11 deletions deprecated/Exceptions/StatsException.php

This file was deleted.

238 changes: 0 additions & 238 deletions deprecated/apc.php

This file was deleted.

Loading

0 comments on commit cfa3246

Please sign in to comment.