Skip to content

Commit a1a938c

Browse files
Initial commit
0 parents  commit a1a938c

File tree

7 files changed

+831
-0
lines changed

7 files changed

+831
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.idea
2+
/build/arginfo.php
3+

LICENSE

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Resource Operations
2+
3+
Copyright (c) 2015, Sebastian Bergmann <sebastian@phpunit.de>.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions
8+
are met:
9+
10+
* Redistributions of source code must retain the above copyright
11+
notice, this list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright
14+
notice, this list of conditions and the following disclaimer in
15+
the documentation and/or other materials provided with the
16+
distribution.
17+
18+
* Neither the name of Sebastian Bergmann nor the names of his
19+
contributors may be used to endorse or promote products derived
20+
from this software without specific prior written permission.
21+
22+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Resource Operations
2+
3+
Provides a list of PHP built-in functions that operate on resources.
4+
5+
## Installation
6+
7+
To add this component as a local, per-project dependency to your project, simply add a dependency on `sebastian/resource-operations` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on this component:
8+
9+
```JSON
10+
{
11+
"require": {
12+
"sebastian/resource-operations": "~1.0"
13+
}
14+
}
15+
```
16+

build.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project name="resource-operations" default="build">
3+
<target name="build" depends="generate" />
4+
5+
<target name="generate" depends="download-arginfo">
6+
<exec executable="${basedir}/build/generate.php" taskname="generate" />
7+
</target>
8+
9+
<target name="download-arginfo">
10+
<tstamp>
11+
<format property="thirty.days.ago" pattern="MM/dd/yyyy hh:mm aa" offset="-30" unit="day"/>
12+
</tstamp>
13+
14+
<delete>
15+
<fileset dir="${basedir}/build">
16+
<include name="arginfo.php" />
17+
<date datetime="${thirty.days.ago}" when="before"/>
18+
</fileset>
19+
</delete>
20+
21+
<get src="https://raw.githubusercontent.com/rlerdorf/phan/master/includes/arginfo.php" dest="${basedir}/build/arginfo.php" skipexisting="true"/>
22+
</target>
23+
</project>
24+

build/generate.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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+
15+
foreach ($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);
24+
sort($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+
37+
namespace SebastianBergmann\ResourceOperations;
38+
39+
class ResourceOperations
40+
{
41+
/**
42+
* @return string[]
43+
*/
44+
public static function getFunctions()
45+
{
46+
return [
47+
48+
EOT;
49+
50+
foreach ($resourceFunctions as $function) {
51+
$buffer .= sprintf(" '%s',\n", $function);
52+
}
53+
54+
$buffer .= <<< EOT
55+
];
56+
}
57+
}
58+
59+
EOT;
60+
61+
file_put_contents(__DIR__ . '/../src/ResourceOperations.php', $buffer);
62+

composer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "sebastian/resource-operations",
3+
"description": "Provides a list of PHP built-in functions that operate on resources",
4+
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
5+
"license": "BSD-3-Clause",
6+
"authors": [
7+
{
8+
"name": "Sebastian Bergmann",
9+
"email": "sebastian@phpunit.de"
10+
}
11+
],
12+
"require": {
13+
"php": ">=5.6.0"
14+
},
15+
"autoload": {
16+
"classmap": [
17+
"src/"
18+
]
19+
},
20+
"extra": {
21+
"branch-alias": {
22+
"dev-master": "1.0.x-dev"
23+
}
24+
}
25+
}
26+

0 commit comments

Comments
 (0)