Skip to content

Add strict type declarations and modernize codebase#63

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

Add strict type declarations and modernize codebase#63
sukhwinder33445 wants to merge 9 commits intomainfrom
modernize-code

Conversation

@sukhwinder33445
Copy link
Contributor

@sukhwinder33445 sukhwinder33445 commented Dec 9, 2025

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, consistent union type ordering, and compact format.

Replace list() with array destructuring, switch/case with match
expressions, and self return types with static for better fluent
interface support.

Breaking changes — consumers of the following APIs require updates:

  • Translator (ipl-i18n: GettextTranslator, NoopTranslator)
  • Paginatable (ipl-sql: Cursor, LimitOffset)
  • Messages::addMessage() (ipl-html: Contract/FormElement)
  • Properties::getProperty() (ipl-orm: Common/PropertiesWithDefaults)
  • Raise the minimum PHP version to 8.2

Intentionally left without type declarations:

  • Validator interface: too many overrides in consumers
  • Events::on(): must match Evenement\EventEmitterInterface
  • Messages::getMessage(): must match Validator interface

closes #30

Copy link

@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.

The return type of BaseFilter::setBaseFilter can be changed to static.

@sukhwinder33445 sukhwinder33445 force-pushed the support-php-85 branch 2 times, most recently from 6408fa8 to d67ed2a Compare December 12, 2025 07:44
Base automatically changed from support-php-85 to main January 7, 2026 14:54
@lippserd lippserd dismissed BastianLedererIcinga’s stale review January 7, 2026 14:54

The base branch was changed.

@sukhwinder33445
Copy link
Contributor Author

Please rebase.

@sukhwinder33445
Copy link
Contributor Author

ipl\Stdlib\Messages::getMessage()
(without return type to match the definition of the interface ipl\Stdlib\Contract\Validator)

I assume you mean the getMessages() method. However, it already declares a return type in both the mentioned trait and the interface. Since both are part of ipl-stdlib, the return type can be added there.

Copy link
Contributor Author

@sukhwinder33445 sukhwinder33445 left a comment

Choose a reason for hiding this comment

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

Everything else looks good to me.

@sukhwinder33445
Copy link
Contributor Author

ipl\Stdlib\Messages::getMessage()
(without return type to match the definition of the interface ipl\Stdlib\Contract\Validator)

I assume you mean the getMessages() method. However, it already declares a return type in both the mentioned trait and the interface. Since both are part of ipl-stdlib, the return type can be added there.

Please ignore, we cannot add a return type to getMessages() as it would require changes in the imedge module, which we do not maintain.

Copy link
Contributor Author

@sukhwinder33445 sukhwinder33445 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 to me.

@lippserd lippserd force-pushed the modernize-code branch 3 times, most recently from 4a6fb1e to a5d07c8 Compare March 19, 2026 13:24
Jan-Schuppik and others added 8 commits March 19, 2026 14:46
Add strict type declarations to properties, function/method signatures, where
types are unambiguous and no inheritance is affected. Remove any now
superfluous type checks.

PHPDoc adjusted: nullable shorthand, union type ordering, compact format.

Raise minimum PHP version to 8.0.

Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
Raise minimum PHP version to 8.2.

Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
This change requires adjustments to the following consumers:

ipl-html:
    - src/Contract/FormElement.php

PHPDoc adjusted: nullable shorthand, union type ordering, compact format.
This change requires adjustments to the following consumers:

ipl-orm:
    - src/Common/PropertiesWithDefaults.php
This change requires adjustments to the following consumers:

ipl-sql
    - src/Cursor.php
    - src/LimitOffset.php

PHPDoc adjusted: nullable shorthand, union type ordering, compact format.
This change requires adjustments to the following consumers:

ipl-i18n
    - src/GettextTranslator.php
    - src/NoopTranslator.php

PHPDoc adjusted: nullable shorthand, union type ordering, compact format.
@lippserd lippserd added this to the v0.15.0 milestone Mar 19, 2026
@lippserd lippserd changed the title Modernize code Add strict type declarations and modernize codebase Mar 20, 2026
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.

4 participants