Skip to content

Added @deprecateds - #48

Open
petrknap wants to merge 1 commit into
v3.xfrom
deprecations
Open

petrknap wants to merge 1 commit into
v3.xfrom
deprecations

Conversation

@petrknap

@petrknap petrknap commented Jul 11, 2026 •

Copy link
Copy Markdown
Owner
  • This pull request does not contain any breaking change.
  • I asked the AI to briefly summarize, use and improve the feature(s), and I'm okay with the output:

Based on the provided diffs (commit.diff and future.diff), here is a review of the added deprecations and changes:


Overview of Changes

The changes prepare the library for a major cleanup/refactoring by deprecating specialized optional classes, their related exceptions/helpers, and modifying method signatures within the core Optional class.


1. Deprecation of Specialized Optionals (Use Base Optional)

  • Classes Affected:

  • OptionalArray

  • OptionalBool

  • OptionalFloat

  • OptionalInt

  • OptionalObject (including OptionalStdClass)

  • OptionalResource (including OptionalStream)

  • OptionalString

  • Review: All these subclasses are marked @deprecated will be removed, use {@see Optional}. This indicates a shift toward a unified, generic-based Optional implementation rather than having explicit subclasses for every primitive type or specific structure.


2. Deprecation of Typed Optional Subsystem & Exceptions

  • Classes/Interfaces Affected:

  • TypedOptional

  • TypedOptionalException

  • CouldNotFindTypedOptionalForValue

  • CouldNotRegisterNonOptional

  • Review:

  • The entire TypedOptional class—including error triggering methods (enableErrorTriggering, disableErrorTriggering, triggerNotice) in future.diff—is marked @deprecated will be removed.

  • Associated exception classes and interfaces are also phased out, pointing to a complete removal of the typed optional registration and error-triggering infrastructure.


3. Method Signature Changes in Optional (equals)

  • Change in Optional::equals():
public function equals(mixed $obj, bool $byReference = false, bool $strict = false): bool
{
    $strict = $strict || $byReference;
    // ...
}
  • Review:

  • The $strict parameter is deprecated in favor of $byReference, and the internal method logic is refactored.

  • Backward compatibility is temporarily preserved by setting $strict = $strict || $byReference, meaning existing calls utilizing $strict will continue to work while guiding developers toward the new $byReference parameter convention.


Recommendation

  • If you are maintaining code using this library, plan to migrate from specialized optionals (OptionalString, OptionalInt, etc.) to the general Optional class.
  • Refactor any usage of TypedOptional and prepare for the removal of related helper methods and exception classes.
  • Update calls to equals() to use $byReference instead of $strict where appropriate.

@petrknap petrknap self-assigned this Jul 11, 2026
@petrknap petrknap added the documentation Improvements or additions to documentation label Jul 11, 2026
@petrknap
petrknap marked this pull request as ready for review July 11, 2026 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant