api de gestion de ticket, basé sur php-crud-api. Le but est de décorrélé les outils de gestion des données, afin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

install.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. if (!file_exists('composer.phar')) {
  3. $composer = file_get_contents('https://getcomposer.org/composer.phar');
  4. file_put_contents('composer.phar', $composer);
  5. }
  6. if (!file_exists('vendor')) {
  7. exec('php composer.phar install');
  8. }
  9. function patchDir(string $base, string $dir): int
  10. {
  11. $count = 0;
  12. $entries = scandir($dir);
  13. foreach ($entries as $entry) {
  14. if ($entry === '.' || $entry === '..') {
  15. continue;
  16. }
  17. $filename = "$base/$dir/$entry";
  18. if (is_dir($filename)) {
  19. $count += patchDir($base, "$dir/$entry");
  20. }
  21. }
  22. foreach ($entries as $entry) {
  23. $filename = "$base/$dir/$entry";
  24. if (is_file($filename)) {
  25. if (substr($entry, -4) != '.php') {
  26. continue;
  27. }
  28. $patched = $original = file_get_contents($filename);
  29. $patched = preg_replace('/\):\s*(\?[a-zA-Z]+|void)\s*\n/', ") /*:$1*/\n", $patched);
  30. $patched = preg_replace('/private const/', "/*private*/ const", $patched);
  31. if ($patched && $patched != $original) {
  32. file_put_contents($filename, $patched);
  33. $count++;
  34. }
  35. }
  36. }
  37. return $count;
  38. }
  39. function patch(string $base, array $dirs)
  40. {
  41. $start = microtime(true);
  42. $count = 0;
  43. foreach ($dirs as $dir) {
  44. $count += patchDir($base, $dir);
  45. }
  46. $end = microtime(true);
  47. $time = ($end - $start) * 1000;
  48. if ($count) {
  49. fwrite(STDERR, sprintf("%d files patched in %d ms\n", $count, $time));
  50. }
  51. }
  52. patch(__DIR__, ['vendor']);