sveneld opened a new pull request, #3484:
URL: https://github.com/apache/thrift/pull/3484

   Step `lib/php/phpstan.neon` level from 5 to 6 and address every issue 
PHPStan surfaces along the way. Final phase of the umbrella ticket 
[THRIFT-5960](https://issues.apache.org/jira/browse/THRIFT-5960) PHP 
modernization (after 
[THRIFT-6000](https://issues.apache.org/jira/browse/THRIFT-6000) / 
[THRIFT-6001](https://issues.apache.org/jira/browse/THRIFT-6001) / 
[THRIFT-6004](https://issues.apache.org/jira/browse/THRIFT-6004)).
   
   ## Library typing fixes
   
   - `TBinarySerializer::serialize(object $object): string`
   - `TBinarySerializer::deserialize(string $string_object, class-string 
$class_name, int $buffer_size = 8192): object`
   - `TServer::__construct(object $processor, …)`
   - `TSocket` / `TSSLSocket` constructor: documented `$debugHandler` as 
`callable|string|null` via PHPDoc.
   - `TSocketPool::__construct(array $hosts, int|array $ports, bool $persist, 
…)` with `list<string>` / `int|list<int>` shape PHPDoc.
   - `TJSONProtocol` static array properties get a native `array` declaration 
plus `@var` element-type docblocks (`$JSON_CHAR_TABLE`, `$ESCAPE_CHARS`, 
`$ESCAPE_CHAR_VALS`).
   - `TBase` / `TException` internal helpers (`readMap`, `readList`, 
`readStruct`, `writeMap`, `writeList`, `writeStruct`, `__construct`, bridge 
ctor) gain `@param array<…>` shape documentation so PHPStan can reason about 
`$spec` / `$vals` / `$var` element types.
   
   ## Bug fixes
   
   - **`TBase::__wakeup()`** previously round-tripped through 
`$this->__construct(get_object_vars($this))`. That call short-circuited inside 
the body (second parameter was null) but tripped strict-mode type checks under 
tighter array-shape PHPDoc. PHP restores object state automatically on 
`unserialize`, so the body is now empty with a comment.
   - **`ThriftClassLoader::findFileInApcu()`** now uses a clear two-step 
fetch-or-recompute pattern and narrows the return via `is_string()`, 
eliminating the unreachable else-arm flagged by PHPStan.
   
   ## Baseline
   
   Regex pattern updated for the four unreachable dead-code arms in TBase / 
TException `writeMap` that mirror Thrift IDL `map<Struct, V>` semantics PHP 
arrays cannot represent — phpstan now reports the type as `array<int|string, 
mixed>` instead of bare `array`.
   
   ## Validation (Docker `thrift-php-dev:local`)
   - `phpcs` — 0 errors
   - `phpstan` (level 6) — 0 errors
   - `phpunit` Unit Suite — 637 tests, 0 failures
   - `phpunit` Integration Suite — 108 tests, 0 failures
   
   Closes the typing trajectory started by THRIFT-5960.
   
   - [x] Apache Jira ticket — 
[THRIFT-6005](https://issues.apache.org/jira/browse/THRIFT-6005)
   - [x] PR title follows the pattern "THRIFT-NNNN: …"
   - [x] Squashed to a single commit
   - [x] No behaviour changes: `__wakeup` no-op was already a no-op due to body 
short-circuit; `findFileInApcu` returns the same string/null contract; library 
API surface untouched.
   
   Generated-by: Claude Opus 4.7
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to