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.

65 lines
1.4 KiB

3 years ago
  1. #!/usr/bin/env php
  2. <?php declare(strict_types=1);
  3. /*
  4. * This file is part of resource-operations.
  5. *
  6. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. $functions = require __DIR__ . '/FunctionSignatureMap.php';
  12. $resourceFunctions = [];
  13. foreach ($functions as $function => $arguments) {
  14. foreach ($arguments as $argument) {
  15. if (strpos($argument, '?') === 0) {
  16. $argument = substr($argument, 1);
  17. }
  18. if ($argument === 'resource') {
  19. $resourceFunctions[] = explode('\'', $function)[0];
  20. }
  21. }
  22. }
  23. $resourceFunctions = array_unique($resourceFunctions);
  24. sort($resourceFunctions);
  25. $buffer = <<<EOT
  26. <?php declare(strict_types=1);
  27. /*
  28. * This file is part of resource-operations.
  29. *
  30. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  31. *
  32. * For the full copyright and license information, please view the LICENSE
  33. * file that was distributed with this source code.
  34. */
  35. namespace SebastianBergmann\ResourceOperations;
  36. final class ResourceOperations
  37. {
  38. /**
  39. * @return string[]
  40. */
  41. public static function getFunctions(): array
  42. {
  43. return [
  44. EOT;
  45. foreach ($resourceFunctions as $function) {
  46. $buffer .= sprintf(" '%s',\n", $function);
  47. }
  48. $buffer .= <<< EOT
  49. ];
  50. }
  51. }
  52. EOT;
  53. file_put_contents(__DIR__ . '/../src/ResourceOperations.php', $buffer);