APIv4 - Limited support for casting
authorTim Otten <totten@civicrm.org>
Thu, 16 Feb 2023 06:58:19 +0000 (22:58 -0800)
committerTim Otten <totten@civicrm.org>
Thu, 16 Feb 2023 06:58:19 +0000 (22:58 -0800)
commit9a0ea9b2eb47788d2f17407995f949b647f7a56e
treeee689161af211660f218aaa7a26b54d6436ddc25
parentc3874c3af0f5097b9936800ec24e711ab18b0935
APIv4 - Limited support for casting

Before
------

* `setCheckPermissions(0)` casts the `0` to `false`.
     * This is because it's a concrete setter with explict typing.
* `setUseTrash(0)` does not.
     * This is because it's a magic setter with no typing.

After
-----

* Both `setCheckPermissions(0)` and `setUseTrash(0)` cast the `0` to `false`

Technical Details
-----------------

I initially drafted in a way where `setUseTrash()` performed exactly the same casting
as `setCheckPermissions()`, but there was a countervailing test to assert that
`setDebug('debug')` is invalid, and that seemed fair.
Civi/Api4/Generic/AbstractAction.php
Civi/Api4/Utils/ReflectionUtils.php
tests/phpunit/Civi/API/RequestTest.php