Skip to content

PHP 8.2+: E_DEPRECATED when API returns fields not declared on Details (e.g. readme) #110

@agencypin

Description

@agencypin

On PHP 8.2+, assigning keys from the API response that are not declared as properties on ipinfo\ipinfo\Details triggers:

Deprecated: Creation of dynamic property ipinfo\ipinfo\Details::$readme is deprecated

This happens in Details::__construct() because it loops over $raw_details and assigns $this->$property = $value for every key, while Details only declares a fixed list of properties. The API can return additional keys (e.g. readme).

Environment

  • Package: ipinfo/ipinfo v3.5.0
  • PHP: 8.2+ (also observed on 8.3)

Minimal reproduction

new \ipinfo\ipinfo\Details([
    'ip' => '8.8.8.8',
    'readme' => 'https://ipinfo.io/missingauth',
]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions