Add ShipMonk custom sniffs ported from monorepo#17
Merged
Conversation
Adds 8 generic custom sniffs under the ShipMonkCodingStandard standard, ported from the monorepo CodingStyle ruleset and backported to PHP 7.4: - Arrays.DoubleArrowSpacing (fixable) - ControlStructures.EmptyConditionBody - ControlStructures.SwitchStatementToMatchExpr - Whitespaces.CatchSpacing (fixable) - Whitespaces.DisallowOneLineDocComment (fixable) - Whitespaces.MultilineConditionSpacing (fixable) - Whitespaces.MultilineTernary (fixable) - Whitespaces.OpenParenthesisSpacing (fixable) Each sniff has tests (pass/fail fixtures, plus .fixed fixtures for the fixable ones). PHPUnit is now wired into `composer check` so the suite runs in CI. Supporting changes: - production namespace root ShipMonk\CodingStandard -> ShipMonkCodingStandard so PHPCS emits clean ShipMonkCodingStandard.* sniff codes - require squizlabs/php_codesniffer and ext-tokenizer explicitly - PHPStan: bootstrap PHP_CodeSniffer, add a token-stream stub, and relax reportPossiblyNonexistentGeneralArrayOffset / internalTag for sniff code Co-Authored-By: Claude Code
name-collision-detector parses files with the runtime PHP, so PHP 8.0+ syntax (e.g. match) in tests/Data fixtures fails to parse on PHP 7.4 CI. Fixtures are not real code, so exclude tests/Data from collision scanning via collision-detector.json. Co-Authored-By: Claude Code
janedbal
marked this pull request as ready for review
June 19, 2026 07:55
For a multiline catch whose closing brace of the preceding try sits at column 1 (e.g. a top-level try/catch in a script), the indentation token read for the catch line is actually the line break, so `$catchIndent` became "\n". The closing-indent check then reported a false positive on valid code and the fixer inserted a blank line before the `)`. Strip the leading newline from `$catchIndent` and handle the empty-indent (column 1) case explicitly. Adds top-level fixtures and locks the fixer output of the multiline cases with `.fixed` files (previously only the error count was asserted). Co-Authored-By: Claude Code
It bans `switch` outright, but `match` cannot replace statement/control-flow switches (multiple statements per case, fall-through, `continue`/`break` with levels). On the ShipMonk OSS libraries it only ever flagged such legitimate switches, with no safe auto-fix. Keep it out of the shared standard. Co-Authored-By: Claude Code
Completes the previous commit, which deleted the sniff files but left the ruleset reference, breaking phpcs with "Referenced sniff does not exist". Co-Authored-By: Claude Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports 7 generic custom sniffs from the monorepo
CodingStyleruleset into this OSS standard, with tests, backported to PHP 7.4 (CI matrix 7.4–8.5).Sniffs added
Arrays.DoubleArrowSpacingControlStructures.EmptyConditionBodyWhitespaces.CatchSpacingWhitespaces.DisallowOneLineDocCommentWhitespaces.MultilineConditionSpacingWhitespaces.MultilineTernaryWhitespaces.OpenParenthesisSpacingEach sniff has pass/fail fixtures (and
.fixedfixtures for fixable ones). PHPUnit is now wired intocomposer checkso the suite runs in CI.Intentionally excluded
GeneralSpacing— superseded by the already-enabledSlevomatCodingStandard.Whitespaces.DuplicateSpaces(+Squiz.WhiteSpace.OperatorSpacing).SwitchStatementToMatchExpr— kept internal (monorepo) only. It bansswitchoutright, butmatchcan't replace statement/control-flow switches (multiple statements, fall-through,continue/breaklevels); across the OSS libs it only flagged such legitimate switches with no safe auto-fix.Supporting changes
ShipMonk\CodingStandard→ShipMonkCodingStandardfor cleanShipMonkCodingStandard.*sniff codes (non-breaking; the--standard=ShipMonkCodingStandardref is unchanged).require: addedsquizlabs/php_codesnifferandext-tokenizer.reportPossiblyNonexistentGeneralArrayOffset/internalTagfor sniff code (the monorepo does the same).Co-Authored-By: Claude Code