Skip to content

feat: implement DisallowVoidType sniff and related tests#2

Merged
yCodeTech merged 1 commit intomasterfrom
feat/disallowVoidType-sniff
Mar 26, 2026
Merged

feat: implement DisallowVoidType sniff and related tests#2
yCodeTech merged 1 commit intomasterfrom
feat/disallowVoidType-sniff

Conversation

@yCodeTech
Copy link
Owner

This pull request introduces a new PHPCS sniff, DisallowVoidTypeSniff, to the yCodeTech standard. The sniff enforces the rule that explicit void return type declarations are not allowed on functions, methods, or closures - absence of a return type already implies void. The PR includes documentation, the implementation of the sniff, comprehensive tests, and updates to the test files and README.

Sniff Implementation

  • Introduced the new DisallowVoidTypeSniff in yCodeTech/Sniffs/Types/DisallowVoidTypeSniff.php, which detects and auto-fixes explicit : void return types in function, method, and closure signatures.
function example(): void {}

Testing and Test Coverage

  • Added a new test file (DisallowVoidTypeUnitTest.inc) and its fixed counterpart to verify detection and auto-fixing of explicit void return types, ensuring the sniff works as intended.
  • Created a unit test class (DisallowVoidTypeUnitTest.php) to assert that the sniff flags the correct lines and does not produce warnings.

Documentation Updates

  • Updated inline documentation in existing test files to clarify that explicit void return types should now be flagged and auto-fixed, and to specify what should and should not be fixed.
  • Create xml documentation for the sniff.
  • Update README with the new sniff documentation.

These changes collectively add a new rule to the coding standard, improve documentation, and ensure robust automated testing for the new behaviour.

~ Summary partly generated by Copilot

- Add `DisallowVoidTypeSniff` to disallow explicit `: void` return types.
- Create documentation for the disallowed void type standard.
- Add unit tests to verify detection of explicit void return types.
- Update existing test files to remove explicit void return types.
- Update README with the new sniff documentation.
@yCodeTech yCodeTech added documentation Improvements or additions to documentation enhancement New feature or request sniff A new Sniff labels Mar 26, 2026
@yCodeTech yCodeTech merged commit c0fb401 into master Mar 26, 2026
2 checks passed
@yCodeTech yCodeTech deleted the feat/disallowVoidType-sniff branch March 26, 2026 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request sniff A new Sniff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant