php-jwt icon indicating copy to clipboard operation
php-jwt copied to clipboard

feat: Allow object as payload

Open Oinkling opened this issue 1 year ago • 1 comments

Changed JWT::encode and JWT::jsonEncode so that they now accept an object as well as an array as their first argument.

As the result of JWT::decode is an object it only makes sense that the same object can be encoded again.

This also makes the use case of using JWT as a session manager more straight forward as you can just encode and decode the user object directly without array conversions.

Oinkling avatar Aug 07 '24 10:08 Oinkling

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Aug 07 '24 10:08 google-cla[bot]

I have added a single test that just uses an object payload instead of array.
As long as we're sure it can encode that everything else works exactly the same as an array payload, so any further test seemed redundant.

Oinkling avatar Apr 28 '25 09:04 Oinkling