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.

update.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. // download composer and update 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. exec('php composer.phar update');
  8. // patch files for PHP 7.0 compatibility
  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|public|protected) const/', "/*$1*/ 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']);