Add ShipMonk custom sniffs ported from monorepo#17
Draft
janedbal wants to merge 2 commits into
Draft
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
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 8 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.EmptyConditionBodyControlStructures.SwitchStatementToMatchExprWhitespaces.CatchSpacingWhitespaces.DisallowOneLineDocCommentWhitespaces.MultilineConditionSpacingWhitespaces.MultilineTernaryWhitespaces.OpenParenthesisSpacingEach sniff has pass/fail fixtures (and
.fixedfixtures for fixable ones). PHPUnit is now wired intocomposer checkso the suite actually runs in CI (it didn't before).Dropped vs. the original request
GeneralSpacing— dropped: fully superseded by the already-enabledSlevomatCodingStandard.Whitespaces.DuplicateSpaces(+Squiz.WhiteSpace.OperatorSpacing), which also auto-fix.Supporting changes
ShipMonk\CodingStandard→ShipMonkCodingStandardso PHPCS emits cleanShipMonkCodingStandard.*sniff codes (no existing production classes, non-breaking; the--standard=ShipMonkCodingStandardref is unchanged).require: addedsquizlabs/php_codesnifferandext-tokenizer(sniffs use their symbols directly).autoload.php+Tokens.php), add a token-stream stub (build/phpstan/php-codesniffer.stub), and disablereportPossiblyNonexistentGeneralArrayOffset+internalTag(both incompatible with the token-stream / slevomat-@internal-helper idiom — the monorepo does the same).Noise check on ShipMonk OSS packages (real code, fixtures excluded)
Ran the 8 sniffs in isolation across all 19
shipmonk/*packages. Excluding test fixtures (which legitimately contain one-line docblocks etc.), real-code hits total 13:SwitchStatementToMatchExprDisallowOneLineDocCommentMultilineConditionSpacingOpen question
SwitchStatementToMatchExpris the only sniff with real, non-auto-fixable churn (9 hits on legitimate token-dispatchswitches in cda / name-collision-detector / static-reflection). Keep it (mandatematch) or drop it? — left in for now, easy to remove.Co-Authored-By: Claude Code