Skip to content

Modernize code#96

Open
sukhwinder33445 wants to merge 7 commits intomainfrom
modernize-code
Open

Modernize code#96
sukhwinder33445 wants to merge 7 commits intomainfrom
modernize-code

Conversation

@sukhwinder33445
Copy link
Contributor

@sukhwinder33445 sukhwinder33445 commented Dec 9, 2025

Modernize and clean up the codebase by adopting the latest PHP features and functions.

Changes made:

  • Add data types for properties, parameters, and method return values
  • Remove the unnecessary InAndNotInUtils trait, as it was only introduced to reduce phpstan errors
  • Replace switch statements with match expressions where possible

requires Icinga/ipl-stdlib#63 (The signature of limit() and offset() methods in Cursor and LimitOffsetInterface must be compatible with ipl\Stdlib\Contract\Paginatable)

@cla-bot cla-bot bot added the cla/signed label Dec 9, 2025
@sukhwinder33445 sukhwinder33445 self-assigned this Dec 9, 2025
@sukhwinder33445 sukhwinder33445 changed the base branch from main to support-php-8.4/8.5 December 9, 2025 08:19
@sukhwinder33445 sukhwinder33445 force-pushed the modernize-code branch 2 times, most recently from eefa5b5 to 8686b59 Compare December 9, 2025 10:51
@BastianLedererIcinga
Copy link
Contributor

The InAndNotUtils trait is currently incompatible with ipl\Stdlib\Filter\Condition.

@sukhwinder33445 sukhwinder33445 force-pushed the modernize-code branch 3 times, most recently from 589584f to c0df0ec Compare December 11, 2025 08:00
@BastianLedererIcinga
Copy link
Contributor

The rest looks good.

@BastianLedererIcinga BastianLedererIcinga force-pushed the support-php-8.4/8.5 branch 2 times, most recently from 2ebbbb8 to 9aaf2fd Compare December 18, 2025 15:01
Base automatically changed from support-php-8.4/8.5 to main January 7, 2026 13:00
@lippserd lippserd dismissed BastianLedererIcinga’s stale review January 7, 2026 13:00

The base branch was changed.

Copy link
Contributor

@BastianLedererIcinga BastianLedererIcinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local unit tests all pass when using the other modernize branches.

Copy link
Contributor

@BastianLedererIcinga BastianLedererIcinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, tests all pass with Icinga/ipl-stdlib#63. Icinga\Module\Reporting\RetryConnection should be the only dependency.

@sukhwinder33445
Copy link
Contributor Author

I created Icinga/icingaweb2-module-reporting#269 to add the required change in sub-class.

Copy link
Member

@lippserd lippserd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Add strict type declarations to properties, function/method signatures, where
types are unambiguous and no inheritance or interface contract is affected.

`OrderByInterface::OrderBy()`: The following tests require `ExpressionInterface` & `Select` as param:
- `SelectTest::testOrderByWithExpression()`: Method `OrderBy::orderBy()` must support `ExpressionInterface` as param
- `SelectTest::testOrderByWithSelect()`: Method `OrderBy::orderBy()` must support `Select` as Param

`ConfigTest`: Due to the strict type of `Config::$options`, the value of the `options` key must be an `Array`.
`setupTest()` had an empty function body, so no replacement is necessary.
The function `arrayval()` no longer throws this exception.
`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.
@sukhwinder33445
Copy link
Contributor Author

I have adjusted the commits accordingly. Each commit is now self-contained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants