Skip to content

Conversation

@VincentLanglet
Copy link
Contributor

Hi @matthewelwell @dabeeeenster

I'm getting a lot of deprecation when using this tool like

PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Projects\ProjectModel::$enable_realtime_updates is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Projects\ProjectModel::$server_key_only_feature_ids is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$name is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$allow_client_traits is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$updated_at is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$hide_sensitive_data is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$hide_disabled_flags is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$use_identity_composite_key_for_hashing is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$dynatrace_config is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$rudderstack_config is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38
PHP Deprecated:  Creation of dynamic property Flagsmith\Engine\Environments\EnvironmentModel::$webhook_config is deprecated in /var/www/wg-app/vendor/flagsmith/flagsmith-php-client/src/Concerns/JsonSerializer.php on line 38

And there is a lot more.

This is because a lot of data sent by the api is not handled (and maybe not needed to be handled) by the JsonSerializer.

A way to avoid such deprecations is to use the

#[\AllowDynamicProperties]

attribute.

@matthewelwell
Copy link
Contributor

Hey @VincentLanglet , thanks for this - from reading the documentation, it looks like this will allow the properties to be set on the objects (which I guess maintains the current behaviour from PHP<8) but I'm wondering if there is an option to ignore any unknown properties? This might be the preferred option (although we may need a major version to roll it out).

@VincentLanglet
Copy link
Contributor Author

I'm wondering if there is an option to ignore any unknown properties? This might be the preferred option

No, I don't think so ; I think it will throw an error.

Something more complexe could be implemented directly in the

protected function setValues($values)

with reflection. Like changing

$this->{ $key } = $value;

to something like

if ($reflection->hasProperty($key)) {
    $this->$key = $value;
}

But indeed this would require a major version (and it makes the JsonSerializer more complex and magic)

@matthewelwell matthewelwell merged commit ea67c93 into Flagsmith:main Aug 31, 2023
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.

2 participants