Add strict type declarations and modernize codebase#96
Add strict type declarations and modernize codebase#96sukhwinder33445 wants to merge 5 commits intomainfrom
Conversation
eefa5b5 to
8686b59
Compare
|
The |
db90247 to
204a7aa
Compare
21ca328 to
c248141
Compare
589584f to
c0df0ec
Compare
ef5f5f3 to
9b2ebce
Compare
9b2ebce to
9fc16d4
Compare
|
The rest looks good. |
c0df0ec to
e1a3680
Compare
e1a3680 to
8bee499
Compare
9fc16d4 to
be685ed
Compare
8bee499 to
891337c
Compare
2ebbbb8 to
9aaf2fd
Compare
The base branch was changed.
214e28b to
d8c9e53
Compare
BastianLedererIcinga
left a comment
There was a problem hiding this comment.
Local unit tests all pass when using the other modernize branches.
41e2a82 to
f59dfc7
Compare
535b1a1 to
9673dad
Compare
lippserd
left a comment
There was a problem hiding this comment.
requires Icinga/ipl-i18n#26 (for tests to run, compatibility issue)
Why? ipl-i18n is not a dependency of either ipl-sql or ipl-stdlib.
77124d2 states "non-breaking", but it does introduce strict types on Cursor::limit() and Cursor::offset(), which requires a newer version of ipl-stdlib. Plus, the changes only become testable through follow-up commits, which spreads related changes across multiple places and makes it harder to reason about the impact.
To keep things manageable especially with all the releases coming soon, it helps if we follow a few rules:
When we say non-breaking, we mean it: no dependency or consumer must need to change. Any test adjustments belong in the same commit, and if a newer PHP version is needed, composer.json should reflect that in the same commit with a note in the description.
When a change in an IPL component does require updates in consumers,
those consumer updates should land in a single commit that also bumps the version constraint in composer.json.
Since we don't have releases yet, pointing to a branch is totally fine:
ipl-i18n#13 is a good example of how to do that.
We'll change those to proper version constraints once we actually release.
In the end, we're aiming for two distinct release steps:
- first a non-breaking IPL release that's safe for Icinga Web and its modules,
- then a follow-up breaking release that coordinates updates across everything affected.
Clean, self-contained commits are important.
One more thing worth clarifying: breaking changes that only affect IPL don't need to live in a separate PR as long as the commits are self-contained.
However, anything that breaks Icinga Web and/or its modules does need to go into a new PR.
@BastianLedererIcinga @Jan-Schuppik Please check your PRs to make sure they comply with these rules. I've already adjusted Icinga/ipl-stdlib#63.
8bafaff to
b244e12
Compare
|
I have adjusted the commits accordingly. Each commit is now self-contained. |
b244e12 to
298d19b
Compare
Add strict type declarations to properties, function/method signatures, where types are unambiguous and no inheritance or interface contract is affected. Align tests with strict typing and tighten PHPDoc where applicable. Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
`setupTest()` had an empty body, so no replacement is necessary.
`ipl-stdlib` introduces strict type declarations, requiring all classes implementing its interfaces to match the exact parameter and return types defined there. Updated affected classes and bumped the required `ipl-stdlib` version in `composer.json` accordingly. Remove the now obsolete `@throws InvalidArgumentException` annotation since the strict `arrayval()` function no longer throws this exception. Remove the now redundant `InAndNotInUtils` trait, which was originally added to suppress PHPStan errors before strict typing was introduced.
298d19b to
e79b3f1
Compare
Add strict type declarations to all method parameters, return types, and
properties throughout the codebase. Remove redundant runtime type checks
now enforced by the type system. Update PHPDoc to use nullable shorthand
and compact format. Replace
list()with array destructuring, andswitch/casewithmatchexpressions. Remove theInAndNotInUtilstrait, which was introduced to suppress PHPStan errors before strict
typing was available. Clean up deprecated test helpers.
Raise the minimum required
ipl/stdlibversion to adopt its strict typedeclarations.
requires Icinga/ipl-stdlib#63