Skip to content

Fix incorrect @return phpdoc types in Client class#371

Open
sawirricardo wants to merge 1 commit into
woocommerce:trunkfrom
sawirricardo:fix/return-type-phpdoc
Open

Fix incorrect @return phpdoc types in Client class#371
sawirricardo wants to merge 1 commit into
woocommerce:trunkfrom
sawirricardo:fix/return-type-phpdoc

Conversation

@sawirricardo

Copy link
Copy Markdown

Problem

The Client methods (post, put, delete, options) document their return type as \stdClass, but json_decode() (used in HttpClient::processResponse()) returns an array when the JSON response is a JSON array. This causes phpstan/phpcs type-checking errors for users who rely on the documented return type.

See issue #329 for details.

Solution

Update the @return phpdoc on post(), put(), delete(), and options() from \stdClass to \stdClass|array, which is consistent with the existing phpdoc on HttpClient::request() and HttpClient::processResponse().

Changes

  • src/WooCommerce/Client.php: Updated @return tags on post(), put(), delete(), and options() methods.

Fixes #329

The Client methods (post, put, delete, options) documented their
return type as \stdClass, but json_decode() returns array for JSON
arrays. This caused phpstan errors for users expecting the documented
type. The HttpClient::request() method already correctly documents
\stdClass|array. Update all Client method phpdocs to match.

Fixes woocommerce#329
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client return types are array not stdClass

1 participant