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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. exec('php patch.php');
  9. }
  10. function patchDir(string $base, string $dir): int
  11. {
  12. $count = 0;
  13. $entries = scandir($dir);
  14. foreach ($entries as $entry) {
  15. if ($entry === '.' || $entry === '..') {
  16. continue;
  17. }
  18. $filename = "$base/$dir/$entry";
  19. if (is_dir($filename)) {
  20. $count += patchDir($base, "$dir/$entry");
  21. }
  22. }
  23. foreach ($entries as $entry) {
  24. $filename = "$base/$dir/$entry";
  25. if (is_file($filename)) {
  26. if (substr($entry, -4) != '.php') {
  27. continue;
  28. }
  29. $patched = $original = file_get_contents($filename);
  30. $patched = preg_replace('/\):\s*(\?[a-zA-Z]+|void)\s*\n/', ") /*:$1*/\n", $patched);
  31. $patched = preg_replace('/private const/', "/*private*/ const", $patched);
  32. if ($patched && $patched != $original) {
  33. echo "$filename\n";
  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. echo sprintf("%d files patched in %d ms\n", $count, $time);
  52. }
  53. }
  54. patch(__DIR__, ['vendor']);