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 needed safe wrappers in 8.1 but no longer need safe wrappers in 8.2 will have no-op stubs generated instead)

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 28, 2025
1 parent d1ec3ef commit c127a0d
Show file tree
Hide file tree
Showing 498 changed files with 216,746 additions and 40,218 deletions.
14 changes: 3 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,10 @@
"lib/DateTime.php",
"lib/DateTimeImmutable.php",
"lib/Exceptions/",
"deprecated/Exceptions/",
"generated/Exceptions/"
],
"files": [
"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 @@ -42,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 @@ -59,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 Down Expand Up @@ -111,7 +103,7 @@
"php-parallel-lint/php-parallel-lint": "^1.4"
},
"scripts": {
"lint": "parallel-lint deprecated/ lib/ tests/",
"lint": "parallel-lint lib/ tests/",
"test": "phpunit",
"phpstan": "phpstan analyse",
"cs-fix": "phpcbf",
Expand Down
11 changes: 0 additions & 11 deletions deprecated/Exceptions/LibeventException.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.

301 changes: 0 additions & 301 deletions deprecated/array.php

This file was deleted.

Loading

0 comments on commit c127a0d

Please sign in to comment.