Skip to content

Commit d4e7d6a

Browse files
committed
add phpstorm stub helper
1 parent 9e4a795 commit d4e7d6a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

bin/phpstorm-stubs.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ $# -ne 1 ]; then
6+
echo "Usage: $0 <version>"
7+
exit 1
8+
fi
9+
10+
VERSION="$1"
11+
12+
URL="https://builds.r2.relay.so/${VERSION}/relay.stub.php"
13+
14+
echo "Downloading ${VERSION} stubs..."
15+
curl -s -o "relay.stub.php" "$URL"
16+
17+
if [[ "$OSTYPE" == "darwin"* ]]; then
18+
SED="gsed"
19+
else
20+
SED="sed"
21+
fi
22+
23+
echo "Adjusting stubs..."
24+
25+
"$SED" -i -E \
26+
-e 's/^(.*\bfunction\b.*);/\1 {}/' \
27+
-e 's/^(\s*)\);$/\1) {}/'\
28+
-e 's/^(\s*)\): ([^;]+);$/\1): \2 {}/' \
29+
-e 's/^(\s+\*) @alias (.+)$/\1 @see \2()/' \
30+
-e 's/^(\s+\*) @var \$context array/\1 @example $context array/' \
31+
relay.stub.php

0 commit comments

Comments
 (0)