Skip to content

Commit 449a99a

Browse files
committed
Update and add stubs generators
1 parent f195140 commit 449a99a

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

stub-generators/acf-generate-stubs.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
#
3+
# Generate ACF stubs of functions only.
4+
#
5+
6+
PLUGIN_VERSION="5.8.0"
7+
8+
Fix_phpdoc()
9+
{
10+
# - Fix type and variable name order for @param
11+
# - Remove remaining parentheses for @param
12+
# - Fix type and variable name order for @return
13+
# - Remove remaining parentheses for @return
14+
# - Fix "void"
15+
find ./includes/ -type f -name "*.php" -exec sed \
16+
-e 's#^\(\s*\*\s*@param\s\+\)\(\$\S\+\)\s\+(\(\S\+\))\(.*\)$#\1\3 \2\4#' \
17+
-e 's#^\(\s*\*\s*@param\s\+\)(\(\S\+\))\(.*\)$#\1\2\3#' \
18+
-e 's#^\(\s*\*\s*@return\s\+\)\(\$\S\+\)\s\+(\(\S\+\))\(.*\)$#\1\3 \2\4#' \
19+
-e 's#^\(\s*\*\s*@return\s\+\)(\(\S\+\))\(.*\)$#\1\2\3#' \
20+
-e 's#n/a#void#i' \
21+
-i "{}" ";"
22+
}
23+
24+
# Check plugin
25+
if ! grep -q 'Plugin Name:\s\+Advanced Custom Fields' ./acf.php 2>/dev/null; then
26+
echo "Please extract ACF into the current directory!" 1>&2
27+
echo "wget https://downloads.wordpress.org/plugin/advanced-custom-fields.${PLUGIN_VERSION}.zip && unzip advanced-custom-fields.${PLUGIN_VERSION}.zip" 1>&2
28+
exit 10
29+
fi
30+
31+
Fix_phpdoc
32+
33+
# Generate stubs
34+
if [ ! -x vendor/bin/generate-stubs ]; then
35+
composer require --no-interaction --update-no-dev --prefer-dist giacocorsiglia/stubs-generator
36+
fi
37+
# Functions only
38+
vendor/bin/generate-stubs --functions --out=acf-stubs-${PLUGIN_VERSION}.php ./includes/

stub-generators/acf-pro-generate-stubs.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ Fix_phpdoc
3434
if [ ! -x vendor/bin/generate-stubs ]; then
3535
composer require --no-interaction --update-no-dev --prefer-dist giacocorsiglia/stubs-generator
3636
fi
37+
# Functions only
3738
vendor/bin/generate-stubs --functions --out=acf-pro-stubs-${PLUGIN_VERSION}.php ./includes/ ./pro/

stub-generators/polylang-generate-stubs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PLUGIN_VERSION="2.5.3"
77

88
# Check plugin
99
if ! grep -q 'Plugin Name:\s\+Polylang' ./polylang.php 2>/dev/null; then
10-
echo "Please extract WooCommerce into the current directory!" 1>&2
10+
echo "Please extract Polylang into the current directory!" 1>&2
1111
echo "git clone https://github.com/polylang/polylang.git" 1>&2
1212
exit 10
1313
fi

0 commit comments

Comments
 (0)