-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Milestone
Description
Summary
Update PHPCS configuration to allow importing WP_Error via use statements instead of requiring fully qualified references (\WP_Error) throughout the codebase.
Background
During PR #123 review, @JasonTheAdams suggested importing WP_Error to drop the root namespace prefix. Investigation revealed that the current SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions rule enforces fully qualified references for classes ending with Error, which includes WP_Error.
However, WP_Error is not an actual exception class (it doesn't extend Exception or Throwable) - it's a WordPress utility class for error handling. The rule's documentation explicitly supports adding such classes to ignoredNames.
Proposed Changes
- Update
phpcs.xmlto addWP_ErrortoignoredNames:
<rule ref="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions">
<properties>
<property name="ignoredNames" type="array">
<element value="WP_Error" />
</property>
</properties>
</rule>- Update all namespaced files that use
\WP_Error:- Add
use WP_Error;import statement - Replace
\WP_ErrorwithWP_Errorin code - Update PHPDoc
@returntypes from\WP_ErrortoWP_Error
- Add
References
- PR [5/6] Update core layer and built-in abilities for MCP schema #123 review comment: [5/6] Update core layer and built-in abilities for MCP schema #123
- Slevomat Coding Standard docs: https://github.com/slevomat/coding-standard/blob/master/doc/namespaces.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
No status