ivan_morozov10 Oct 2025 11:42

PHP 8.2 deprecated dynamic properties (setting undefined properties on objects), removed in 9.0. We had about 80 places in our codebase using them.

Sharing the migration experience.

Replies (6)
alex_petrov10 Oct 2025 12:06

The deprecation warnings in logs are a good starting point. Enable log_errors and watch for “Creation of dynamic property” messages. Then search the codebase for patterns that create them.

0
nphp10 Oct 2025 12:59

stdClass is exempt. Dynamic properties on stdClass still work. The deprecation is for user-defined classes only. Most JSON decode and DB query results use stdClass so those are safe.

0
sergey_web10 Oct 2025 14:47

The AllowDynamicProperties attribute on a class suppresses the deprecation. Use it as a temporary fix for code you cannot change immediately, but add a TODO to remove it before PHP 9.

0
ivan_morozov10 Oct 2025 15:35

The main migration path: add property declarations. For tests that set arbitrary properties on mocks, use mock expectations or add the property with a default null.

0
vova10 Oct 2025 17:13

Legacy ActiveRecord-style ORMs and data mapper classes were the biggest source of dynamic properties in our case. Some required non-trivial refactoring to add explicit property declarations with nullable types.

0
katedev10 Oct 2025 18:59

Rector has an automated rule for this: AddAllowDynamicPropertiesAttributeRector. It does not fix the root problem but handles the deprecation mechanically while you plan the real fixes.

0
Write a reply
Markdown. ```php blocks are runnable.