Skip to content

Conversation

@Aman-Aalam
Copy link
Contributor

Fixes #24

This PR checks if the JSON response contains "meta" fields before adding them to response object, to prevent from PHP compilers from generating error messages.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, create a GitHub Issue in this repository.

@Aman-Aalam Aman-Aalam self-assigned this Sep 6, 2022
@Aman-Aalam Aman-Aalam requested review from suitedjimster and removed request for barnett September 8, 2022 14:38
{
$this->_page = $response["meta"]["page"];
// Add "meta" fields only when they exist in JSON response
$this->_page = isset($response["meta"]) ? $response["meta"]["page"] : null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which PHP version are we using?
if php7+, we can use null coalescing.$response["meta"]["page"] ?? null

@Aman-Aalam Aman-Aalam merged commit ca11941 into master Sep 8, 2022
@Aman-Aalam Aman-Aalam deleted the fix-missing-fields branch March 7, 2023 00:39
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.

Warnings about missing fields in ResourceCollector

4 participants