Volodymyr Panivko created THRIFT-5978:
-----------------------------------------
Summary: Apply declare(strict_types=1) in PHP runtime library
Key: THRIFT-5978
URL: https://issues.apache.org/jira/browse/THRIFT-5978
Project: Thrift
Issue Type: Improvement
Components: PHP - Library
Reporter: Volodymyr Panivko
Enable PHP strict typing across the PHP runtime library so the native parameter
and property types added in THRIFT-5976 (properties) and THRIFT-5977
(constructor property promotion) are enforced at runtime, instead of being
silently coerced.
Without `declare(strict_types=1)` PHP coerces `"5"` to `5`, `0.5` to `0`, etc.
— the type annotations become decorative and TypeError checks never fire.
h2. Scope
* Add `declare(strict_types=1);` between the license docblock and the namespace
declaration in:
** All 52 PHP files under `lib/php/lib/`.
** All ~71 non-fixture PHP files under `lib/php/test/` (Unit + Integration +
bootstrap).
* Out of scope: `lib/php/test/Resources/packages/*` (generated fixtures —
covered by a separate sub-ticket for regenerating with the PHP generator).
* Out of scope: C-extension PHP wrapper under `lib/php/src/ext/`.
h2. Risk
Low. Pure additive change (no signature edits, no LSP cascade). PHP enforces
strictness at the *caller* site, so loose-mode generated fixtures continue to
call strict-mode lib code without a TypeError. Tests already pass without
coercion, so no test fixes are expected.
h2. Verification
# `./vendor/bin/phpcs --report=summary` (0 errors)
# `./vendor/bin/phpstan analyse -c lib/php/phpstan.neon --no-progress` (0
errors)
# `./vendor/bin/phpunit -c lib/php/phpunit.xml --testsuite="Thrift PHP Unit
Test Suite" --no-coverage` (629 pass)
# `./vendor/bin/phpunit -c lib/php/phpunit.xml --testsuite="Thrift PHP
Integration Test Suite" --no-coverage` (106 pass)
Part of the THRIFT-5960 umbrella effort to modernize the PHP library typing.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)