bugsnag / bugsnag-php

BugSnag error monitoring and crash reporting tool for PHP apps
https://docs.bugsnag.com/platforms/php
MIT License
554 stars 77 forks source link

Add PHPStan at level 6 #637

Closed imjoehaines closed 2 years ago

imjoehaines commented 2 years ago

Goal

PHPStan is a static analyser for PHP that can catch a bunch of potential bugs in code

This PR is based on https://github.com/bugsnag/bugsnag-php/pull/633, but runs at level 6 instead of max — PHPStan has 9 error levels (currently) that go from loosest (1) - strictest (9)

For the most part this is only changes to comments, but there are a couple of code changes too:

Additionally, some errors have been ignored:

Design

This PR stops at level 6 because this is where the levels become tricky to update to. Level 6 specifically adds checking for iterable types, e.g. a bare array should really be array<KeyType, ValueType>. I've turned this option off for now as we get around 100 errors from it, but this will be turned on in a future PR. Until then, I've not advanced any further as additional errors can appear as a consequence of adding stricter iterable types

Testing

PHPStan now runs on CI on both PHP 7.1 & 8.1

xPaw commented 2 years ago

FYI, once PHP5 support is dropped, types can be added to function arguments