[
https://issues.apache.org/jira/browse/THRIFT-5958?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18081256#comment-18081256
]
Volodymyr Panivko commented on THRIFT-5958:
-------------------------------------------
Resolved as part of the THRIFT-5960 modernization umbrella: PHPStan level was
stepped from 1 → 6 (THRIFT-5999 / THRIFT-6005) and the baseline collapsed from
the initial findings to just two explanatory entries documenting unreachable
map<Struct,V> map-key arms in TBase/TException::writeMap (defensive dead code
by design).
> Resolve initial PHPStan baseline findings
> -----------------------------------------
>
> Key: THRIFT-5958
> URL: https://issues.apache.org/jira/browse/THRIFT-5958
> Project: Thrift
> Issue Type: New Feature
> Components: PHP - Library
> Affects Versions: 0.24.0
> Reporter: Volodymyr Panivko
> Assignee: Volodymyr Panivko
> Priority: Major
>
> THRIFT-5957 introduced phpstan/phpstan ^1.12 with a baseline that pins
> 5 issues already present in lib/php/lib/. All are "should return X but
> return statement is missing" errors caught at level 1.
> This ticket clears the baseline to zero by fixing each finding
> individually. After this PR, lib/php/phpstan-baseline.neon should
> contain only "parameters: ignoreErrors: []".
> Findings to fix:
> 1. lib/ClassLoader/ThriftClassLoader.php:130
> Method findFile() declares @return string but the function can
> fall through without a return when no file is matched.
> Fix: declare native return type ?string and add `return null` at
> the end of the function body. PSR-4 autoloaders may legitimately
> return null.
> 2. lib/Protocol/TJSONProtocol.php:477 writeStructBegin
> 3. lib/Protocol/TJSONProtocol.php:488 writeStructEnd
> 4. lib/Protocol/TSimpleJSONProtocol.php:165 writeStructBegin
> 5. lib/Protocol/TSimpleJSONProtocol.php:175 writeStructEnd
> Method declares @return int (bytes written) but delegates to a
> writeJSONObjectStart/End helper without returning. Other Thrift
> libraries (Java, Go) treat JSON struct delimiters as 0-byte from
> the protocol-counter perspective.
> Fix: explicitly `return 0;` after the helper call. Document
> intent with a brief // comment.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)