Repo | Old phpstan level | Latest phpstan level | PR | Status |
fundraising-memberships | 5 | 9 | https://github.com/wmde/fundraising-memberships/pull/145 | ✅ |
fundraising-address-change | 7 | 9 | https://github.com/wmde/fundraising-address-change/pull/46 | ✅ |
fundraising-donations | 8 | 9 | https://github.com/wmde/fundraising-donations/pull/236 | ✅ |
fundraising-application | 5 | 9 | Add 'void' return type wherever it's missing ✅ Take care of potential 'false' values ✅ Clean up ✅ Take care of 'getEntityManager()' related errors ✅ Prepare for stricter phpstan rules ✅ Add 'phpstan-phpunit' rules ✅ Take care of potential 'null' values ✅ Make 'GetApplicationVarsTrait' type safe ✅ Type arrays ✅ Take care of potential 'false' values in tests ✅ Type iterables ✅ Take care of 'undefined method' errors ✅ Take care of 'cannot call method on mixed' errors ✅ Take care of 'cannot access offset on mixed' errors ✅ Take care of 'offset' errors ✅ Take care of 'expectation' issues ✅ Upgrade phpstan level ✅ | ✅ |
fundraising-backend | 5 | 9 | TBD | ⚪ |
Following repositories already have phpstan level 9:
Lernings:
- Always strictly type functions, variables, arrays
- Whenever possible use scalar type instead of mixed
- If possible, do not make your function return null, take care of the null value then and there
- string[] and array<int, string> are different! (string[] has consecutive keys, it's a list, while array<int, string> can have arbitrary keys)
- If you encounter any code smell, please create a ticket to take care of it in the future
- You should use assertTrue() instead of assertSame() when expecting true
- You should use assertCount() instead of assertSame() when comparing count of something
- If you don't want json_encode() to return null, give it a second argument JSON_THROW_ON_ERROR
- To make sure a string is non-empty use assertNotEmpty() function in tests.