Commit graph

9 commits

Author SHA1 Message Date
Protobuf Team Bot
b9ab5812ce Bump version dependencies on phpunit/phpunit to ">=11.5.0 <12.0.0"
PiperOrigin-RevId: 861973659
2026-01-27 18:34:56 -08: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
Piotr Grabski-Gradziński
996e04c5ef Make PHPDoc for enum getters/setters correspond to enum class. (#24515)
Make PHPDoc for enum getters/setters correspond to enum class.

Fixes for #23385.

Closes #24515

PiperOrigin-RevId: 835501674
2025-11-21 23:41:57 -08:00
Brent Shaffer
e04fe69a9f feat(php): improve return typehint when repeatedfield (#11734)
Adds the type of the `RepeatedField` to the PHPDoc, e.g.

```php
/**
 * @return \Google\Protobuf\Internal\RepeatedField<int>
 */
```

Whereas before, the `<int>` part was not included.

This is the "getter" counterpart for https://github.com/protocolbuffers/protobuf/pull/4533

Closes #11734

PiperOrigin-RevId: 726881276
2025-02-14 05:06:51 -08:00
Brent Shaffer
9ba808b798
fix: phpdoc syntax for repeatedfield parameters (#9784) 2022-04-18 16:07:02 -07:00
Joshua Haberman
8b87075924
Updated and simplified PHP testing structure (#8558)
* Simplified PHP testing setup.

- Consolidated on a single autoloader, created by composer.
- Consolidated on a single phpunit invocation strategy: we run
  phpunit on a directory, which will run all tests matching *Test.php
  in that directory.
- We now rely on autoloading to import all test protos. require_once()
  calls for test protos are removed.
- For now the valgrind tests are removed. A follow-up PR will re-enable
  them in a more robust way.

* More improvements to PHP testing.

1. Replace custom PHPUnit-selection logic in test.sh with generic
   composer version selection.
2. Optimized both test proto generation and the custom extension
   build to avoid unnecessary work when the files are already up
   to date.

* Added assertions to verify that the C test doesn't use PHP sources.

* Updated tests.sh for the new PHP testing commands.

* Removed obsolete rules from tests.sh.

* Fixed generate_test_protos.sh for when tmp does not exist.

Also removed undefined_test.php and fixed Makefile.am.

* Added php8.0_all again which is still used.

* Added missing file to Makefile.am.

* Re-added php_all_32 rule which is also still used.

* Updated testing commands for macOS and download composer.

* Use /usr/local/bin on mac instead of /usr/bin, since the latter is not writable.
2021-05-04 10:19:22 -07:00
Christian Alexander Wolf
f4d0f7c85e
feat: add support for deprecated fields to PHP compiler (#8223)
* feat: add support for deprecated fields to PHP compiler

* PR feedback 1
2021-01-29 11:33:27 -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
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/generated_phpdoc_test.php (Browse further)