THRIFT-6000: Add native types to PHP JSON protocol helpers and contexts#3479
Merged
Conversation
Client: php Type the remaining untyped methods in TJSONProtocol, TSimpleJSONProtocol, their JSON/SimpleJSON Context classes, LookaheadReader, and CollectionMapKeyException. All internal/protected helpers; no public API change beyond the signature tightening. Typed: - TJSONProtocol::getTypeNameForTypeID(int $typeID): string - TJSONProtocol::getTypeIDForTypeName(string $name): int - TJSONProtocol::pushContext(BaseContext $c): void - TJSONProtocol::__construct(TTransport $trans) - TJSONProtocol::reset(): void - TJSONProtocol::readJSONSyntaxChar(string $b): void - TJSONProtocol::writeJSONString(mixed $b): void - TJSONProtocol::writeJSONInteger(int $num): void (return only) - TJSONProtocol::writeJSONObjectStart/End/ArrayStart/End(): void - TJSONProtocol::readJSONString(bool $skipContext): mixed - TJSONProtocol::readJSONNumericChars(): string - TJSONProtocol::readJSONInteger(): int - TJSONProtocol::readJSONIntegerAsString(): string - TJSONProtocol::readJSONDouble(): float - TJSONProtocol::readJSONObjectStart/End/ArrayStart/End(): void - TSimpleJSONProtocol::pushWriteContext(Context $c): void - TSimpleJSONProtocol::popWriteContext(): void (returns to default Context() on stack underflow rather than null, matching the non-null property type) - TSimpleJSONProtocol::assertContextIsNotMapKey(string $invalidKeyType): void - TSimpleJSONProtocol::writeJSONString(mixed $b): void - TSimpleJSONProtocol::writeJSONInteger(int $num): void - JSON\\BaseContext, ListContext, PairContext, LookaheadReader, SimpleJSON\\Context, ListContext, MapContext, StructContext: all read()/write()/escapeNum()/isMapKey()/__construct() typed. - CollectionMapKeyException::__construct(?string $message = null) Follow-up to THRIFT-5999 within the umbrella 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 remaining untyped methods in
TJSONProtocol,TSimpleJSONProtocol, their JSON/SimpleJSON Context classes,LookaheadReader, andCollectionMapKeyException. All internal/protected helpers; no public API change beyond the signature tightening.Typed methods
TJSONProtocol:
getTypeNameForTypeID(int $typeID): stringgetTypeIDForTypeName(string $name): intpushContext(BaseContext $c): void__construct(TTransport $trans)reset(): voidreadJSONSyntaxChar(string $b): voidwriteJSONString(mixed $b): voidwriteJSONInteger,writeJSONObjectStart/End/ArrayStart/End: return: voidreadJSONString(bool $skipContext): mixedreadJSONNumericChars(): stringreadJSONInteger(): int,readJSONIntegerAsString(): string,readJSONDouble(): floatreadJSONObjectStart/End/ArrayStart/End: return: voidTSimpleJSONProtocol:
pushWriteContext(Context $c): voidpopWriteContext(): void— returns a freshContext()on stack underflow (matches the non-null property type, parallels TJSONProtocol's BaseContext fallback)assertContextIsNotMapKey(string $invalidKeyType): voidwriteJSONString(mixed $b): void,writeJSONInteger(int $num): voidContext classes (all return/param-typed):
JSON\BaseContext,ListContext,PairContextJSON\LookaheadReader(read(): string,peek(): string)SimpleJSON\Context,ListContext,MapContext,StructContextSimpleJSON\CollectionMapKeyException::__construct(?string $message = null)Validation (Docker
thrift-php-dev:local)phpcs— 0 errorsphpstan(level 5) — 0 errorsphpunitUnit Suite — 635 tests, 0 failuresphpunitIntegration Suite — 108 tests, 0 failuresFollow-up to THRIFT-5999 within the umbrella THRIFT-5960.
Generated-by: Claude Opus 4.7