Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Coding Standard Laravel Package

dms/coding-standard

DMS Coding Standard provides a customized PHPCS ruleset for consistent PHP code style across repositories. Based on PSR-1/PSR-2 with Doctrine flavor, enforcing strict_types declarations and return type spacing rules.

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install via Composer: composer require --dev dms/coding-standard
  2. Create phpcs.xml (or phpcs.xml.dist) in your project root with:
    <?xml version="1.0"?>
    <ruleset name="MyProject">
        <rule ref="DMS"/>
    </ruleset>
    
  3. Run checks: vendor/bin/phpcs src/
  4. Fix where possible: vendor/bin/phpcbf src/
    Start with enforcing declare(strict_types=1) and return type formatting—these are two of the most immediately noticeable deviations from stock PSR-2.

Implementation Patterns

  • CI Integration: Add phpcs and phpcbf to pre-commit hooks and CI workflows (e.g., GitHub Actions) to catch violations early. Use phpcs --report-summary for concise feedback.
  • IDE Integration: Configure PHPStorm/VSCode with PHPCS to show live sniffs. Ensure the External Tools > PHP Code Sniffer points to vendor/bin/phpcs.
  • Gradual Adoption: For legacy codebases, start with a baseline: vendor/bin/phpcs --baseline=phpcs-baseline.xml src/, then incrementally shrink the baseline as you refactor.
  • Override Strategically: Extend the DMS ruleset only where needed—e.g., allow @deprecated annotations on methods only in test files—by adding <rule ref="DMS.PHP.StrictTypes"> or custom filePattern filters.

Gotchas and Tips

  • ⚠️ Strict types placement: Requires declare(strict_types=1) exactly one line after the opening PHP tag—even after docblocks like @codeCoverageIgnore. Misalignment causes sniff failures.
  • ⚠️ Return type colons: The sniff enforces no space before :, but a space after in return types, e.g., function foo(): array {}, not function foo() : array {}. Double-check closures with function (): void {}.
  • 🔧 Maturity warning: With only 1 star and last release in 2023, verify compatibility with modern PHPCS (3.7+) and PHP (8.0–8.3). Check phpcs -i to confirm the DMS standard is registered.
  • 🧪 Test suites: Run phpcs only on src/ and tests/, but exclude vendor/, build/, and generated code (e.g., var/, dist/).
  • 🔍 Debugging: Use phpcs -s -i to list enabled sniffs, and phpcs -v for verbose output when a sniff fails silently. If errors persist, inspect vendor/dms/coding-standard/Doctrine/ruleset.xml directly—its rules are inherited directly from Doctrine CS v8.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport