I try to solve this error:

main.CRITICAL: Deprecated Functionality: Creation of dynamic property VENDOR\MODULE\Model\RedsysFactory::$helper is deprecated in /var/www/vhosts/xxxxxx.com/httpdocs/app/code/VENDOR/MODULE/Model/FILE.php on line 71 [] [] main.ERROR: Please provide payment for the order. [] []

LINE 71 SAID: $this->helper = $helper;

I try to use this code:

 * Use the fully-qualified AllowDynamicProperties, otherwise the #[AllowDynamicProperties] attribute on "MyClass" WILL NOT WORK.
use \AllowDynamicProperties;

class MyClass

but don´t work

Any idea

  • hi dear, can you share the full code? Feb 12 at 5:08

2 Answers 2


Define the helper class like this

namespace ....

use Vendor\Modulename\Helper\Data;

class MyClass
    protected $helper;
    public function __construct(
        Data $helper
    ) {
        $this->helper = $helper;

Dynamic properties have been deprecated in php 8.2 and will gives fatal error from php 9.0 so declaring explicitly the properties is a more long-term solution than just use AllowDynamicProperties.

You can find a correct usage of this attribute here:

class MyClass { }


use AllowDynamicProperties;

class MyClass { }

In my Magento 2 projects I explicitly declared the missing properties writing this script to avoid to do it manually. It:

  • recursively open all the php files in a Magento module
  • thanks to ReflectionClass get information on constructor and properties
  • generate the property declarations missing
  • add the declarations in the php file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.