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
Php Codesniffer Sniffs

Php Codesniffer Sniffs Laravel Package

moxio/php-codesniffer-sniffs

Custom PHP_CodeSniffer 3.x sniffs from Moxio to catch subtle PHP bugs and unexpected behavior. Provides a standalone ruleset or individual sniffs for other standards, enforcing safer comparisons, strict base64_decode, switch continue rules, and more.

View on GitHub
Deep Wiki
Context7

Custom sniffs for PHP_CodeSniffer

Frequently asked questions about Php Codesniffer Sniffs
How do I install and run these sniffs in a Laravel project?
Install via Composer with `composer require --dev moxio/php-codesniffer-sniffs`, then run `./vendor/bin/phpcs --standard=vendor/moxio/php-codesniffer-sniffs` on your project directory. Works seamlessly with Laravel’s existing PHP_CodeSniffer setup.
Does this package support Laravel’s Facade usage (e.g., `Route::get()`) without false positives?
The sniffs are designed to avoid Laravel-specific false positives, but some stricter rules (like Slevomat’s) may still flag Facade usage. Test thoroughly in your CI and add exceptions in `phpcs.xml` if needed.
Can I use these sniffs alongside Slevomat Coding Standard in the same project?
Yes, but you’ll need to configure both tools separately (e.g., `phpcs.xml` for PHP_CodeSniffer and `coding-standard.neon` for Slevomat). Be cautious of rule overlaps—prioritize one framework or document exceptions in both configs.
Which Laravel versions are compatible with this package?
This package is framework-agnostic and works with any Laravel version (5.8+ recommended). Focus on PHP 7.4+ compatibility, as some sniffs (e.g., strict comparisons) target modern PHP behavior.
Will these sniffs break my existing CI pipeline if I add them?
Unlikely, but test incrementally. Start with a subset of sniffs (e.g., `DisallowBareContinueInSwitch`) and monitor CI runtime. Slevomat’s stricter rules may increase execution time—benchmark both frameworks if using both.
Are there any sniffs specifically for Blade templates or Laravel helpers?
Currently, the sniffs focus on PHP code only. Blade templates are not analyzed, but you can extend the package or use Slevomat’s Blade-specific rules if needed. Laravel helpers (e.g., `app()`, `Str::`) may trigger false positives under Slevomat.
How do I exclude certain files or directories from these sniffs?
Use PHP_CodeSniffer’s built-in exclusions in your `phpcs.xml` file. For example, add `<exclude-pattern>*/tests/*</exclude-pattern>` to skip test files. Slevomat’s `coding-standard.neon` supports similar exclusions.
What’s the difference between using this package standalone vs. integrating with Slevomat?
Standalone (PHP_CodeSniffer) is lightweight and Laravel-friendly, while Slevomat adds stricter PSR compliance but may conflict with Laravel idioms. Use standalone for bug detection; Slevomat for PSR-22/PSR-12 enforcement.
Do these sniffs work with PHP 8.x features like named arguments or union types?
Yes, the sniffs are compatible with PHP 8.x. Some rules (e.g., `DisallowImplicitLooseComparison`) are designed to catch edge cases in modern PHP, including union types and named arguments.
How can I contribute or request new sniffs for Laravel-specific patterns?
Check the [GitHub repository](https://github.com/Moxio/php-codesniffer-sniffs) for contribution guidelines. Submit issues or pull requests with clear examples of Laravel patterns (e.g., Eloquent queries, Facade macros) that need coverage.
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor