THRIFT-5985: Add native method types to PHP Exception hierarchy#3465
Merged
Conversation
Client: php Type the public surface of the PHP exception hierarchy in lib/php/lib/Exception/: - TException::__construct(string|array|null $p1 = null, int|array $p2 = 0) — preserves the bridge constructor that accepts either standard Exception args (message, code) or Thrift Base spec/vals via union types. - TApplicationException — typed __construct(?string $message, int $code) plus read()/write() with TProtocol parameter and int return. - TProtocolException — typed __construct(?string $message, int $code). - TTransportException — typed __construct(?string $message, int $code). The internal serialization helpers (readMap/writeMap/readList/...) mirror TBase's untyped helpers and are left untouched here; typing those is a separate concern. Part of the umbrella ticket THRIFT-5960 (PHP modernization). Generated-by: Claude Opus 4.7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type the public surface of the PHP exception hierarchy in
lib/php/lib/Exception/.Changes:
TException::__construct(string|array|null $p1 = null, int|array $p2 = 0)— preserves the bridge constructor that accepts either standard Exception args (message,code) or Thrift Basespec/vals. Union types capture the polymorphism explicitly.TApplicationException— typed__construct(?string $message = null, int $code = 0)plusread(TProtocol $output): intandwrite(TProtocol $output): int. Addeduse Thrift\Protocol\TProtocol;.TProtocolException— typed__construct(?string $message = null, int $code = 0).TTransportException— typed__construct(?string $message = null, int $code = 0).Out of scope:
The internal serialization helpers in
TException(readMap,readList,readStruct,writeMap,writeList,writeStruct) mirror the same untyped helpers onTBase. Typing those is a separate concern (would need to be applied consistently across both classes and would touch broader by-ref dynamic-dispatch behavior).Validation (Docker
thrift-php-dev:local):phpcs— 0 errorsphpstan(level 1) — 0 errorsphpunitUnit Suite — 635 tests, 0 failuresphpunitIntegration Suite — 108 tests, 0 failuresPart of the umbrella ticket THRIFT-5960 (PHP modernization).
string|nullfromstring|array|nullis a no-op for the standardnew TXxx($msg, $code)call pattern; the bridgenew TException($spec, $vals)still works at the base class)Generated-by: Claude Opus 4.7