simbiat / sniffs
Custom sniffs for PHP Code Sniffer
dev-main
2026-09-25 11:58 UTC
Requires
- php: ^8.4
- ext-mbstring: *
- squizlabs/php_codesniffer: ^4.0.4
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-25 11:58:38 UTC
README
Custom sniffs PHP Code Sniffer, that are used in simbiat.eu project. Mostly generated by Claude.ai, with some clean-up and testing done afterward.
What's in here
| Sniff | Code | Fixable? |
|---|---|---|
Simbiat.Strings.PreferMultibyte |
Recommend using multibyte (mb_*) fucntions instead of single-byte functions. Useful for projects that deal with multi-langauge strings and emojis. Using arguments with a name which one of binary, blob, bytes, raw, hash, digest, checksum, signature, ciphertext, plaintext, salt, iv, key, will serve as a hint, that this is binary data, and thus suppress the sniff. |
No |
Simbiat.Strings.MultibyteEncoding |
Highlights mb_* calls missing an explicit encoding. UTF-8 is recommended in most modern environments. |
Yes |
Simbiat.PHP.ExitCode |
Suggests adding a status code to exit/die without one for the sake of being explicit. |
Yes |
Simbiat.PHP.PreferWhiteString |
Suggest using \Simbiat\StringHelpers\Sanitize::whiteString($string) call instead of preg_match('/^\s*$/', $string) === 1 to capture more whitespace characters. |
No |
Simbiat.Twig.SafeFilterOption |
Highlights new TwigFunction(...) / new TwigFilter(...) with is_safe flag. Usingt he flag bears risks, so you may want to ensure, that the function/filter is sanitized enough. |
No |
Simbiat.SQL.DateTimeFunctions.PreferCurrent |
Prefer CURRENT_* functions in SQL literals instead of UTC_* ones. UTC_* bypasses whatever timezone you are using on the server, and unless it is already UTC, can result in time-related bugs. This sniff helps with that, even if you do not use UTC as default timezone (which you should). |
Yes |
Simbiat.SQL.DateTimeFunctions.MissingPrecision |
Enforce explicit precission argument for date and time functions in SQL literals. 0 by default. |
Yes |
Simbiat.Regex.MissingUnicodeFlag |
Highlights preg_*() literal patterns missing the u flag. Useful in projects dealing with unicode. |
Yes |
Simbiat.Regex.MissingCaselessRestrictFlag |
Highlights preg_*() literal patterns that have both u (PCRE_UTF8) and i (PCRE_CASELESS) but not r (PCRE2_EXTRA_CASELESS_RESTRICT) to prevent matching of K (Kelvin character), when you are searching for k and K. Results in stricter matches. |
Yes |