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.7KB

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