[ 
https://issues.apache.org/jira/browse/THRIFT-5963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Volodymyr Panivko updated THRIFT-5963:
--------------------------------------
    Description: 
After lib/php/lib/ is fully typed, the C++ generator at
compiler/cpp/src/thrift/generate/t_php_generator.cc still emits PHP
without declare(strict_types=1), without native parameter or return
types, without typed properties. Generated structs work but look
archaic next to a fully-typed runtime library.

This ticket adds modern emission:

  * declare(strict_types=1) at the top of every emitted file.
  * Native return types on getName(), read(), write(),
    constructor-from-array, validators.
  * Native parameter types on read(TProtocol $input),
    write(TProtocol $output), validators.
  * Typed properties on struct fields where the Thrift type maps to a
    PHP scalar or class (string, int, bool, float, array, ClassName,
    nullable variants).
  * Constructor property promotion is intentionally NOT used — Thrift
    constructors do array-deserialization, not pure assignment.
  * Add a new helper type_to_native_signature() in the generator
    (alongside the existing type_to_phpdoc()).
  * Regenerate all golden test fixtures.

This is a breaking change for downstream code that:
  * Relied on PHP's loose-typing coercion on struct fields (e.g.,
    assigning a string to an int field).
  * Subclasses generated structs and overrides read/write with
    different signatures.

Plain users that follow the documented Thrift IDL types continue to
work.

  was:
With THRIFT-5956 raising the floor to PHP 8.1 and the test suite
migrated to PHP 8 attributes, we can upgrade PHPUnit:

  * PHPUnit 10 requires PHP 8.1 — works for our floor.
  * PHPUnit 11 requires PHP 8.2.

This ticket:

  * Bumps phpunit/phpunit constraint in composer.json.
  * Bumps lib/php/phpunit.xml schema URL to match.
  * Removes deprecated phpunit.xml options
    (convertErrorsToExceptions, convertNoticesToExceptions,
    convertWarningsToExceptions) which are removed in 10+.
  * Updates php-mock/php-mock-phpunit constraint to a version that
    supports the chosen PHPUnit major (likely ^3.x for PHPUnit 10).
  * Fixes any test code that breaks under the new PHPUnit (assertion
    aliases removed, data provider signature changes, etc.).

Decision to make in PR:
  * Pin to PHPUnit 10 (broader, supports PHP 8.1 floor) or 11 (newer,
    requires also bumping floor to 8.2).


> Modernize C++ generator: typed properties and native return types
> -----------------------------------------------------------------
>
>                 Key: THRIFT-5963
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5963
>             Project: Thrift
>          Issue Type: New Feature
>          Components: PHP - Compiler, PHP - Library
>    Affects Versions: 0.24.0
>            Reporter: Volodymyr Panivko
>            Assignee: Volodymyr Panivko
>            Priority: Major
>
> After lib/php/lib/ is fully typed, the C++ generator at
> compiler/cpp/src/thrift/generate/t_php_generator.cc still emits PHP
> without declare(strict_types=1), without native parameter or return
> types, without typed properties. Generated structs work but look
> archaic next to a fully-typed runtime library.
> This ticket adds modern emission:
>   * declare(strict_types=1) at the top of every emitted file.
>   * Native return types on getName(), read(), write(),
>     constructor-from-array, validators.
>   * Native parameter types on read(TProtocol $input),
>     write(TProtocol $output), validators.
>   * Typed properties on struct fields where the Thrift type maps to a
>     PHP scalar or class (string, int, bool, float, array, ClassName,
>     nullable variants).
>   * Constructor property promotion is intentionally NOT used — Thrift
>     constructors do array-deserialization, not pure assignment.
>   * Add a new helper type_to_native_signature() in the generator
>     (alongside the existing type_to_phpdoc()).
>   * Regenerate all golden test fixtures.
> This is a breaking change for downstream code that:
>   * Relied on PHP's loose-typing coercion on struct fields (e.g.,
>     assigning a string to an int field).
>   * Subclasses generated structs and overrides read/write with
>     different signatures.
> Plain users that follow the documented Thrift IDL types continue to
> work.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to