Commit Graph

21 Commits

Author SHA1 Message Date
d789c75c00 Improve PHPStan error reporting for unsafe foreaches
these are actually two separate concerns: one for dodgy PHPStan type suppression on implicit keys, and the other for arrays being casted to strings by PHP.
2025-05-08 02:26:09 +01:00
95284bc9de change error identifier 2025-03-09 00:54:39 +00:00
2291546610 phpstan: added rule to ban new $class
see #6635 for rationale on why we want to get rid of this

for now, this rule will prevent this anti-feature from being used in new code
2025-03-09 00:51:12 +00:00
d0d84d4c51 New rule: explode() limit parameter must be set 2025-03-04 20:44:01 +00:00
9633b7d8a7 Update to PHPStan 2.x 2025-01-07 22:34:43 +00:00
5325ecee37 Deal with a whole lot of PHPStan suppressed key casting errors
closes #6534
2024-11-25 14:30:58 +00:00
3906600d44 Fix CS 2023-09-20 19:44:53 +01:00
3f7abf29a8 Added PHPStan rule to flag usages of legacy enum accessors provided by LegacyEnumShimTrait
closes #6061
2023-09-20 19:42:21 +01:00
c1638ffaab Ban foreach by-reference at the PHPStan level 2023-08-08 17:08:13 +01:00
537721fe7d Replace Closure::fromCallable() usages with first-class callables
PHP 8.1 <3
2023-07-19 13:34:42 +01:00
38d6284671 Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
345ac75aac Remove PHPStan rules (no longer needed)
this is enforced by php-cs-fixer now instead.
2022-01-20 19:25:34 +00:00
6846f1e78a Replace disallowed operators in tests/ 2022-01-20 16:48:36 +00:00
b60dd1e9b4 Ban 'and' and 'or' operators via PHPStan 2022-01-20 16:44:59 +00:00
f1723acfd3 UnsafeForeachArrayOfStringRule: use statically analysable function reference
this will ensure that it get automatically updated during refactors.
2022-01-18 00:23:29 +00:00
8da27ea0aa UnsafeForeachArrayOfStringRule: fixed outdated function name 2022-01-18 00:15:44 +00:00
6d249026cc Merge branch 'legacy/pm3' into stable 2022-01-07 20:15:15 +00:00
269231c228 Ban foreach(arrayWithStringKeys as k => v)
this is not as good as phpstan/phpstan-src#769 (e.g. array_key_first()/array_key_last() aren't covered by this, nor is array_rand()) but it does eliminate the most infuriating cases where this usually crops up.
2021-11-15 22:52:05 +00:00
b534ae050e DisallowEnumComparisonRule: detect bugs involving union types (Enum|null compared to Enum|null) 2020-11-14 16:51:13 +00:00
0e1cea043a added some phpstan-specific generic type annotations 2020-01-13 15:05:02 +00:00
a733f094ac phpstan: added a custom rule to disallow strict equality operators on enum members
comparing enums with equality operators is unreliable because there is no guarantee that the enum objects won't be somehow duplicated, through serialization, cloning or ext-parallel dumb object copying. This means that two equal enum objects may not be thw same object.
2020-01-08 19:45:05 +00:00