Skip to content

Improve return types to prevent deprecation warnings#450

Merged
basz merged 3 commits into
prooph:7.xfrom
zluiten:document-return-type
Apr 8, 2026
Merged

Improve return types to prevent deprecation warnings#450
basz merged 3 commits into
prooph:7.xfrom
zluiten:document-return-type

Conversation

@zluiten
Copy link
Copy Markdown

@zluiten zluiten commented Dec 22, 2025

What changed

  • UpcastingIterator::key() gets a native mixed return type, replacing the #[\ReturnTypeWillChange] attribute and @return mixed docblock.
  • MergedStreamIterator::current() and UpcastingIterator::current() retain their existing signatures - see below for why.
  • prooph/bookdown-template is removed from require-dev as it requires league/commonmark ~0.7 which only resolves to 0.19.x-dev, incompatible with PHP 8+. This was breaking the entire CI pipeline.

UpcastingIterator::key() is safe because UpcastingIterator is final - no subclasses can exist, so adding a return type cannot break anyone.

The other two cannot use native types without a BC break:

  • MergedStreamIterator::current() - MergedStreamIterator is not final. Adding any return type to a previously untyped method forces subclasses to declare a compatible type or receive a deprecation warning.
  • UpcastingIterator::current() - already has ?Message. Widening it to mixed is flagged as non-covariant by the BC checker, as callers may rely on the narrower type. Since ?Message already satisfies Iterator::current(): mixed covariantly, no deprecation warning is generated and no change is needed.

@zluiten zluiten force-pushed the document-return-type branch 2 times, most recently from 26de958 to ea792e8 Compare March 24, 2026 20:58
@zluiten zluiten force-pushed the document-return-type branch from ea792e8 to 9bcce9a Compare March 24, 2026 21:07
@zluiten
Copy link
Copy Markdown
Author

zluiten commented Mar 24, 2026

@basz Can you have look?

@basz basz merged commit ba143a5 into prooph:7.x Apr 8, 2026
11 checks passed
@zluiten zluiten deleted the document-return-type branch April 18, 2026 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants