-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathgenerate.sh
executable file
·44 lines (36 loc) · 1.28 KB
/
generate.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
HEADER=$'/**\n * Generated stub declarations for ACF PRO\n * @see https://www.advancedcustomfields.com/\n * @see https://github.com/php-stubs/acf-pro-stubs\n */'
FILE="acf-pro-stubs.php"
set -e
test -f "$FILE"
test -d "source/advanced-custom-fields-pro"
# Download dependencies
if [ ! -d vendor ]; then
composer update
fi
"$(dirname "$0")/vendor/bin/generate-stubs" \
--force \
--visitor=visitor.php \
--finder=finder.php \
--header="$HEADER" \
--functions \
--classes \
--interfaces \
--traits \
--out="$FILE"
# Remove determine_locale function
sed -i -e 's#^\s*function determine_locale()$#//&#' "$FILE"
# - Make docblocks start with "/**"
# - Fix type and variable name order for @param
# - Remove remaining parentheses for @param
# - Fix type and variable name order for @return
# - Remove remaining parentheses for @return
# - Fix "void"
find . -type f -name "$FILE" -exec sed \
-e 's#^\(\s*/\*\)$#\1*#' \
-e 's#^\(\s*\*\s*@param\s\+\)\(\$\S\+\)\s\+(\(\S\+\))\(.*\)$#\1\3 \2\4#' \
-e 's#^\(\s*\*\s*@param\s\+\)(\(\S\+\))\(.*\)$#\1\2\3#' \
-e 's#^\(\s*\*\s*@return\s\+\)\(\$\S\+\)\s\+(\(\S\+\))\(.*\)$#\1\3 \2\4#' \
-e 's#^\(\s*\*\s*@return\s\+\)(\(\S\+\))\(.*\)$#\1\2\3#' \
-e 's#n/a#void#i' \
-i "{}" ";"