Skip to content

Commit 4035be8

Browse files
committed
update project files
1 parent 7575e88 commit 4035be8

7 files changed

Lines changed: 32 additions & 24 deletions

File tree

‎.aagh/pre-commit/lint‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
phpfiles=$(git diff --cached --name-only --diff-filter=ACM | { grep '.php$' || true; })
2-
[ -z "$phpfiles" ] && exit 0
1+
files=$(git diff --cached --name-only --diff-filter=ACM | { grep '.php$' || true; })
2+
[ -z "$files" ] && exit 0
33

4-
unformatted=$(./vendor/bin/phpcs --basepath=$(pwd) $phpfiles | grep -E 'FILE:' | cut -d' ' -f2 | tr '\n' ' ')
5-
[ -z "$unformatted" ] && exit 0
4+
failed=$(composer run lint $files 2>&1 | grep 'FILE: ' | cut -d ' ' -f2 | tr '\n' ' ')
5+
[ -z "$failed" ] && exit 0
66

77
echo >&2 "Files incorrectly formatted. Try running:"
8-
echo >&2 " composer run fix $unformatted"
8+
echo >&2 " composer run fix $failed"
99

1010
exit 1

‎.aagh/pre-commit/test‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
phpfiles=$(git diff --cached --name-only --diff-filter=ACM | { grep '.php$' || true; })
2-
[ -z "$phpfiles" ] && exit 0
1+
files=$(git diff --cached --name-only --diff-filter=ACM | { grep '.php$' || true; })
2+
[ -z "$files" ] && exit 0
33

4-
failed=$(./vendor/bin/phpunit --testsuite default tests | grep -E 'tests/.*\.php:' | sed -e "s|$(pwd)/||" -e 's/:[0-9]*$//' | sort -u)
4+
failed=$(composer run test 2>&1 | grep -E '.*\.php:[0-9]+' | sed -e "s|$(pwd)/||" -e 's/:[0-9]*$//' | sort -u)
55
[ -z "$failed" ] && exit 0
66

77
echo >&2 "Unsuccessful \`composer run test\` files:"

‎composer.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"minimum-stability": "dev",
1212
"prefer-stable": true,
1313
"config": {
14+
"platform": {
15+
"php": "7.4"
16+
},
1417
"allow-plugins": {
1518
"dealerdirect/phpcodesniffer-composer-installer": true,
1619
"phpstan/extension-installer": true

‎phpcs.xml‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<description>The code standard rules for ThemePlate.</description>
99

1010
<!-- Strip the file paths down to the relevant bit. -->
11-
<arg name="basepath" value="./" />
11+
<arg name="basepath" value="." />
1212
<!-- A comma separated list of file extensions to check. -->
1313
<arg name="extensions" value="php" />
1414
<!-- Show sniff and progress. -->
@@ -21,19 +21,21 @@
2121
<!-- What to scan. -->
2222
<file>.</file>
2323
<!-- Exclude the Composer Vendor directory. -->
24-
<exclude-pattern>/vendor/</exclude-pattern>
24+
<exclude-pattern>vendor</exclude-pattern>
2525
<!-- Exclude the Tester Cache directory. -->
26-
<exclude-pattern>/.cache/</exclude-pattern>
26+
<exclude-pattern>.cache</exclude-pattern>
27+
<!-- Exclude the dependencies directory. -->
28+
<exclude-pattern>dependencies</exclude-pattern>
2729

2830
<!-- Include PHP cross-version compatibility. -->
2931
<config name="testVersion" value="7.4-" />
3032
<!-- Include minimum supported WP version. -->
3133
<config name="minimum_supported_wp_version" value="5.9" />
3234

35+
<!-- Include PHP Compatibility Coding Standard. -->
36+
<rule ref="PHPCompatibilityWP" />
3337
<!-- Include the WordPress ruleset. -->
3438
<rule ref="WordPress-Extra" />
35-
<!-- Include PHP Compatibility Coding Standard for WordPress. -->
36-
<rule ref="PHPCompatibilityWP" />
3739

3840
<!-- Custom Rules -->
3941
<rule ref="WordPress.Files">

‎phpstan.neon‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
parameters:
22
level: 5
33
excludePaths:
4-
- vendor
4+
analyse:
5+
- %currentWorkingDirectory%/dependencies?
6+
analyseAndScan:
7+
- %currentWorkingDirectory%/vendor
58
scanDirectories:
69
- %currentWorkingDirectory%/.cache/wordpress
710
- %currentWorkingDirectory%/.cache/wordpress-tests-lib

‎phpunit.xml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
>
1313
<testsuites>
1414
<testsuite name="default">
15-
<directory suffix="Test.php">./tests/</directory>
15+
<directory suffix="Test.php">tests</directory>
1616
</testsuite>
1717
<testsuite name="integration">
18-
<directory suffix="Test.php">./tests/Integration</directory>
18+
<directory suffix="Test.php">tests/Integration</directory>
1919
</testsuite>
2020
<testsuite name="unit">
21-
<directory suffix="Test.php">./tests/Unit</directory>
21+
<directory suffix="Test.php">tests/Unit</directory>
2222
</testsuite>
2323
</testsuites>
2424

2525
<coverage>
2626
<include>
27-
<directory suffix=".php">./src/</directory>
27+
<directory suffix=".php">src</directory>
2828
</include>
2929
</coverage>
3030
</phpunit>

‎tests/bootstrap.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
$_test_suite = array_search( '--testsuite', $GLOBALS['argv'], true );
1010

11-
if ( false === $_test_suite || ! in_array( strtolower( $GLOBALS['argv'][ $_test_suite + 1 ] ), array( 'default', 'integration' ), true ) ) {
11+
if ( false === $_test_suite || ! in_array( strtolower( $GLOBALS['argv'][ (int) $_test_suite + 1 ] ), array( 'default', 'integration' ), true ) ) {
1212
return;
1313
}
1414

1515
$_tests_dir = getenv( 'WP_TESTS_DIR' );
1616

17-
if ( ! $_tests_dir ) {
17+
if ( '' === $_tests_dir || false === $_tests_dir ) {
1818
$_tests_dir = getcwd() . '/.cache/wordpress-tests-lib';
1919
}
2020

@@ -24,14 +24,14 @@
2424
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path );
2525
}
2626

27-
if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) {
27+
if ( ! file_exists( $_tests_dir . '/includes/functions.php' ) ) {
2828
$_work_dir = '.';
2929

3030
if ( getcwd() !== dirname( __DIR__ ) ) {
3131
$_work_dir .= '/vendor';
3232
}
3333

34-
echo "Could not find {$_tests_dir}/includes/functions.php, have you run `{$_work_dir}/bin/themeplate setup` ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
34+
echo sprintf( 'Could not find %s/includes/functions.php, have you run `%s/bin/themeplate setup` ?', $_tests_dir, $_work_dir ) . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3535
exit( 1 );
3636
}
3737

@@ -40,7 +40,7 @@
4040
}
4141

4242
// Give access to tests_add_filter() function.
43-
require_once "{$_tests_dir}/includes/functions.php";
43+
require_once $_tests_dir . '/includes/functions.php';
4444

4545
// Start up the WP testing environment.
46-
require "{$_tests_dir}/includes/bootstrap.php";
46+
require $_tests_dir . '/includes/bootstrap.php';

0 commit comments

Comments
 (0)