Skip to content

THRIFT-6001: Type remaining core PHP lib methods and fix TException tmethod UUID drift#3480

Merged
sveneld merged 1 commit into
apache:masterfrom
sveneld:THRIFT-6001
May 15, 2026
Merged

THRIFT-6001: Type remaining core PHP lib methods and fix TException tmethod UUID drift#3480
sveneld merged 1 commit into
apache:masterfrom
sveneld:THRIFT-6001

Conversation

@sveneld
Copy link
Copy Markdown
Contributor

@sveneld sveneld commented May 14, 2026

Type the remaining untyped methods across core lib classes and fix two real defects surfaced by the typing audit.

Real bug fixes

  • TException::$tmethod was missing TType::UUID => 'Uuid' — TBase has had it since THRIFT-5980, but the HackTown-duplicated map on TException drifted. 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 (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 : bool once the generator passes through a follow-up PR.

Typing

  • TBase::__construct(?array $spec = null, ?array $vals = null)
  • TBase::__wakeup(): void
  • ThriftClassLoader::registerNamespace(string $namespace, string|array $paths): void
  • ThriftClassLoader::registerDefinition(string $namespace, string|array $paths): 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

Validation (Docker thrift-php-dev:local)

  • phpcs — 0 errors
  • phpstan (level 5) — 0 errors
  • phpunit Unit Suite — 636 tests (+1 new tmethod-parity guard), 0 failures
  • phpunit Integration Suite — 108 tests, 0 failures

Follow-up to THRIFT-6000 within the umbrella THRIFT-5960.

  • Apache Jira ticket — THRIFT-6001
  • PR title follows the pattern "THRIFT-NNNN: …"
  • Squashed to a single commit
  • TBase::__construct signature change widens null (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

…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
@mergeable mergeable Bot added the php label May 14, 2026
@sveneld sveneld marked this pull request as ready for review May 15, 2026 05:50
@sveneld sveneld merged commit 5cc4fa2 into apache:master May 15, 2026
94 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant