Commit graph

9 commits

Author SHA1 Message Date
Protobuf Team Bot
8b43dbe00e PHP C Ext: Harden behavior in the face of a bugged custom error handler.
PiperOrigin-RevId: 933773540
2026-06-17 09:39:09 -07:00
Brent Shaffer
aee03b7892 feat(php): Add PHP typehints for setters and remove redundant GPBUtil checks (#25296)
This PR modifies `php_generator.cc` to:
- Add PHP typehints to setter method signatures for all types (for 64-bit integers, the type hint is `int|string` to maintain compatibility with 32-bit systems)
- Remove redundant `GPBUtil::check...` for primitive types and messages (the PHP type hint provides sufficient validation)
- Retain `GPBUtil::check...` for 32 and 64-bit integers, strings (for UTF-8 validation), enums, maps, and repeated fields

Additionally makes the following changes:
- Updates descriptor protos with generator changes
- Suppresses float to int "loss of precision" warnings in tests which expect it
- Removes compatibility in tests with PHPUnit 6, which is no longer needed
- Proper casing in gencode for `true` and `false` (instead of `True` and `False`)

Closes #25296

PiperOrigin-RevId: 856990912
2026-01-15 23:44:59 -08:00
Andrei Tcaci
363fa89b1f RepeatedField: unset by index (#11425)
Instead of using `array_pop()` to remove last element use `unset()` to remove by index

Closes #11425

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/11425 from Leprechaunz:unset-by-index a47fba57e4
PiperOrigin-RevId: 508691545
2023-02-10 10:17:48 -08:00
Joshua Haberman
7e95c64dfb
[PHP] Fixed $msg->setMessage(null) to properly clear the message. (#8472)
* [PHP] Fixed $msg->setMessage(null) to properly clear the message.

Fixes: https://github.com/protocolbuffers/protobuf/issues/8457

* Changed pure PHP to throw TypeError, and added a test for null.

* Added more tests and fixed null in setter for oneof.
2021-05-14 16:48:45 -07:00
Joshua Haberman
b0d90e3abe
Fixed PHP memory leaks and arginfo errors (#8614)
* Fixed a bunch of incorrect arginfo and a few incorrect error messages.

* Passes mem check test with no leaks!

* WIP.

* Fix build warning that was causing Bazel build to fail.

* Added compatibility code for PHP <8.0.

* Added test_valgrind target and made tests Valgrind-clean.

* Updated Valgrind test to fail if memory leaks are detected.

* Removed intermediate shell script so commands are easier to cut, paste, and modify.

* Passing all Valgrind tests!

* Hoist addref into ObjCache_Get().

* Removed special case of map descriptors by keying object map on upb_msgdef.

* Removed all remaining RETURN_ZVAL() macros.

* Removed all explicit reference add/del operations.

* Added REFCOUNTING.md to Makefile.am.
2021-05-13 23:16:49 -07:00
Joshua Haberman
f3e53a05d6
Fixed clone for Message, RepeatedField, and MapField. (#8245)
Also updated the code to use a TypeInfo struct for convenient
passing of type and desc together. This simplified a lot of code
and made this change easier to write.
2021-02-02 09:15:10 -08:00
Paul Yang
823f351448
Port for php8 (#8105)
* Port for php8

* Port php c extension for php8

* Update composer.json

* Drop php7.0 support

* Update phpunit for php7.1 in c extension test

* Add back support for php7.0

* Add badge for php8 continuous build
2020-12-04 13:46:34 -08:00
Joshua Haberman
cae85a9f11
PHP: Added == operators for Map and Array. (#7900) 2020-09-22 11:44:52 -07:00
Paul Yang
d4ca92962c
Port php c extension to php8 (#7793)
* Only ported c extension to php8.
* Didn't fixed the issue of throwing warnings for missing arginfo in bundled files.
* Tests not fixed, because syntax of phpunit (<7 vs >9.3) are not compatible.
* In next release, needs to drop php5 and php7.0 support (in order to use phpunit > 7)
2020-08-11 19:30:46 -07:00
Renamed from php/tests/array_test.php (Browse further)