1#!/usr/bin/env php
2<?php
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
12$functions         = require __DIR__ . '/arginfo.php';
13$resourceFunctions = [];
14
15foreach ($functions as $function => $arguments) {
16    foreach ($arguments as $argument) {
17        if ($argument == 'resource') {
18            $resourceFunctions[] = $function;
19        }
20    }
21}
22
23$resourceFunctions = array_unique($resourceFunctions);
24sort($resourceFunctions);
25
26$buffer = <<<EOT
27<?php
28/*
29 * This file is part of resource-operations.
30 *
31 * (c) Sebastian Bergmann <sebastian@phpunit.de>
32 *
33 * For the full copyright and license information, please view the LICENSE
34 * file that was distributed with this source code.
35 */
36
37namespace SebastianBergmann\ResourceOperations;
38
39class ResourceOperations
40{
41    /**
42     * @return string[]
43     */
44    public static function getFunctions()
45    {
46        return [
47
48EOT;
49
50foreach ($resourceFunctions as $function) {
51    $buffer .= sprintf("            '%s',\n", $function);
52}
53
54$buffer .= <<< EOT
55        ];
56    }
57}
58
59EOT;
60
61file_put_contents(__DIR__ . '/../src/ResourceOperations.php', $buffer);
62
63