Skip to content
This repository was archived by the owner on Feb 5, 2026. It is now read-only.

Commit c1e76fc

Browse files
committed
Adjust directory structure to align with WP core
See rules for PHP Tests at https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/. See best practices for plugins at https://developer.wordpress.org/plugins/plugin-basics/best-practices/.
1 parent 5c337b7 commit c1e76fc

15 files changed

Lines changed: 51 additions & 51 deletions

abilities-api.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@
3434
/**
3535
* First the WP_Ability class that users can extend.
3636
*/
37-
require_once WP_ABILITIES_API_DIR . 'src/class-wp-ability.php';
37+
require_once WP_ABILITIES_API_DIR . 'includes/abilities-api/class-wp-ability.php';
3838

3939
/**
4040
* Then the WP_Abilities_Registry class that manages the abilities.
4141
*/
42-
require_once WP_ABILITIES_API_DIR . 'src/class-wp-abilities-registry.php';
42+
require_once WP_ABILITIES_API_DIR . 'includes/abilities-api/class-wp-abilities-registry.php';
4343

4444
/**
4545
* Then the public access functions that users can use to interact with the abilities.
4646
*/
47-
require_once WP_ABILITIES_API_DIR . 'src/abilities-api.php';
47+
require_once WP_ABILITIES_API_DIR . 'includes/abilities-api.php';
4848

4949
/**
5050
* Initialize REST API controllers.
5151
*/
52-
require_once WP_ABILITIES_API_DIR . 'src/rest/class-wp-rest-abilities-init.php';
52+
require_once WP_ABILITIES_API_DIR . 'includes/rest/class-wp-rest-abilities-init.php';
File renamed without changes.
File renamed without changes.

src/rest/class-wp-rest-abilities-init.php renamed to includes/rest-api/class-wp-rest-abilities-init.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class WP_REST_Abilities_Init {
2222
* @return void
2323
*/
2424
public static function register_routes(): void {
25-
require_once __DIR__ . '/class-wp-rest-abilities-run-controller.php';
26-
require_once __DIR__ . '/class-wp-rest-abilities-list-controller.php';
25+
require_once __DIR__ . '/endpoints/class-wp-rest-abilities-run-controller.php';
26+
require_once __DIR__ . '/endpoints/class-wp-rest-abilities-list-controller.php';
2727

2828
$run_controller = new WP_REST_Abilities_Run_Controller();
2929
$run_controller->register_routes();

src/rest/class-wp-rest-abilities-list-controller.php renamed to includes/rest-api/endpoints/class-wp-rest-abilities-list-controller.php

File renamed without changes.

src/rest/class-wp-rest-abilities-run-controller.php renamed to includes/rest-api/endpoints/class-wp-rest-abilities-run-controller.php

File renamed without changes.

phpcs.xml.dist

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<description>Sniffs for Abilities API plugin</description>
88

99
<!-- What to scan: include any root-level PHP files, and the /inc folder -->
10-
<file>./src/</file>
10+
<file>./includes/</file>
1111
<file>./abilities-api.php</file>
1212

1313
<!-- These are excluded from the above paths.-->
@@ -193,21 +193,21 @@
193193
<property name="enableStandaloneNullTrueFalseTypeHints" value="false" /><!-- Only available in PHP 8.2+ -->
194194
</properties>
195195
</rule>
196-
197-
<!--
196+
197+
<!--
198198
Exclude REST controllers from type hint requirements.
199199
WordPress core's WP_REST_Controller doesn't have type hints on its methods.
200200
Adding type hints to our overridden methods causes fatal errors at runtime
201201
due to signature mismatch. We must match the parent class signatures exactly.
202202
-->
203203
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
204-
<exclude-pattern>src/rest/class-wp-rest-abilities-*-controller.php</exclude-pattern>
204+
<exclude-pattern>includes/rest-api/endpoints/class-wp-rest-abilities-*-controller.php</exclude-pattern>
205205
</rule>
206206
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
207-
<exclude-pattern>src/rest/class-wp-rest-abilities-*-controller.php</exclude-pattern>
207+
<exclude-pattern>includes/rest-api/endpoints/class-wp-rest-abilities-*-controller.php</exclude-pattern>
208208
</rule>
209209
<rule ref="Squiz.Commenting.FunctionComment.TypeHintMissing">
210-
<exclude-pattern>src/rest/class-wp-rest-abilities-*-controller.php</exclude-pattern>
210+
<exclude-pattern>includes/rest-api/endpoints/class-wp-rest-abilities-*-controller.php</exclude-pattern>
211211
</rule>
212212

213213
<rule ref="SlevomatCodingStandard.Variables.DisallowVariableVariable" />

phpstan.neon.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ parameters:
2121
- abilities-api.php
2222
paths:
2323
- abilities-api.php
24-
- src/
24+
- includes/
2525
excludePaths:
2626
analyse:
2727
- tests/
@@ -38,5 +38,5 @@ parameters:
3838
-
3939
message: '#has parameter \$request with generic class WP_REST_Request but does not specify its types#'
4040
paths:
41-
- src/rest/*.php
41+
- includes/rest-api/**/*.php
4242

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
>
1616
<testsuites>
1717
<testsuite name="unit">
18-
<directory suffix="Test.php">tests/unit</directory>
18+
<directory suffix=".php">tests/unit</directory>
1919
</testsuite>
2020
</testsuites>
2121
<coverage processUncoveredFiles="false">
2222
<include>
23-
<directory suffix=".php">src</directory>
23+
<directory suffix=".php">includes</directory>
2424
<file>abilities-api.php</file>
2525
</include>
2626
<report>

0 commit comments

Comments
 (0)