THRIFT-6001: Type remaining core PHP lib methods and fix TException tmethod UUID drift#3480
Merged
Merged
Conversation
…method UUID drift Client: php Type the remaining untyped methods across core lib classes and fix two real defects surfaced by the audit: REAL BUG FIXES - TException::$tmethod was missing `TType::UUID => 'Uuid'`, which TBase has had since THRIFT-5980. Effect: UUID-typed fields in Thrift `exception` structs fell through to the slow recursive STRUCT path instead of the scalar fast-path during read/write. Added a unit test guarding parity between the two maps to prevent future drift. - TMultiplexedProcessor::process(TProtocol $input, TProtocol $output) now declares `: mixed` (return value is propagated from the dispatched underlying processor, whose return shape is generator-emitted; tightens to `: bool` once the generator passes through PR-3). TYPING - TBase::__construct(?array $spec = null, ?array $vals = null) - TBase::__wakeup(): void - ThriftClassLoader::registerNamespace(string, string|array): void - ThriftClassLoader::registerDefinition(string, string|array): void - ThriftClassLoader::register(bool $prepend = false): void - ThriftClassLoader::loadClass(string $class): void - ThriftClassLoader::findFileInApcu(string $class): ?string (corrects the previous loose contract; apcu_fetch returns false on cache-miss, so we coerce to null to match the nullable return) - TSocketPool::apcuFetch(string $key, ?bool &$success = null): mixed - TSocketPool::apcuStore(string $key, mixed $var, int $ttl = 0): bool - TConstant::get(string $constant): mixed Follow-up to THRIFT-6000 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 across core lib classes and fix two real defects surfaced by the typing audit.
Real bug fixes
TException::$tmethodwas missingTType::UUID => 'Uuid'— TBase has had it since THRIFT-5980, but the HackTown-duplicated map on TException drifted. Effect: UUID-typed fields in Thriftexceptionstructs fell through to the slow recursive STRUCT path instead of the scalar fast-path during read/write. Added a unit test (testTmethodMirrorsTBase) guarding parity between the two maps to prevent future drift.TMultiplexedProcessor::process()now declares: mixed(was untyped). Return value is propagated from the dispatched underlying processor, whose return shape is generator-emitted; can tighten to: boolonce the generator passes through a follow-up PR.Typing
TBase::__construct(?array $spec = null, ?array $vals = null)TBase::__wakeup(): voidThriftClassLoader::registerNamespace(string $namespace, string|array $paths): voidThriftClassLoader::registerDefinition(string $namespace, string|array $paths): voidThriftClassLoader::register(bool $prepend = false): voidThriftClassLoader::loadClass(string $class): voidThriftClassLoader::findFileInApcu(string $class): ?string— corrects the previous loose contract;apcu_fetchreturnsfalseon cache-miss, so we coerce tonullto match the nullable returnTSocketPool::apcuFetch(string $key, ?bool &$success = null): mixedTSocketPool::apcuStore(string $key, mixed $var, int $ttl = 0): boolTConstant::get(string $constant): mixedValidation (Docker
thrift-php-dev:local)phpcs— 0 errorsphpstan(level 5) — 0 errorsphpunitUnit Suite — 636 tests (+1 newtmethod-parity guard), 0 failuresphpunitIntegration Suite — 108 tests, 0 failuresFollow-up to THRIFT-6000 within the umbrella THRIFT-5960.
TBase::__constructsignature change widensnull(was untyped, now?array); backwards compatible — any existing caller that passed null or an array continues to work, while passing a different scalar now fails loudly under strict types instead of silently mis-iterating.Generated-by: Claude Opus 4.7