deprecated Creation of dynamic property |
Hello,
I'm using php 8.2 and ci 4.3.2 and i got Creation of dynamic property App\Controllers\Document::$compteModel is deprecated APPPATH/Controllers/Document.php at line 17 PHP Code: 11 public function initController( As you can see it above, in all my controllers, i put access to models in the init part to avoid writing many times PHP Code: [...] new someModel() in the different methods I fought that, adding Code: protected $compteModel; solved the issue Is that a good way ? Thanks, nice day ! Eric
yeah i'm on 8.2.4 I got dynamic property App\Controllers\Pages::$myDate is deprecated I messed around in my BaseController.php i put
Code: namespace App\Controllers; Im not getting errors in Dev local host apache but read Code: use \AllowDynamicProperties; // this one in namespace area
Hi all,
Thanks for those replies. There's a third way, according to https://github.com/squizlabs/PHP_CodeSni...ssues/3489 Add the magic __get() and __set() methods to ... .. to what ? So I keep my solution Beside, i don't really understand what all that means... but I'm only a(n old) hobby developper fighting to find a way to make app as good as possible. Eric
It is a simple story.
If you design that a class has a property, you should define the property. Then devs who read the source code, they know the property is there. If they typo the property name, PHP would report the error. PHP Code: <?php // https://wiki.php.net/rfc/deprecate_dynamic_properties If you cannot specify property names for a class in advance, you use magic __get() and __set().
see here
https://php.watch/versions/8.2/dynamic-p...deprecated The question is whether this is the recommended solution of the codeigniter team?
nice article @scalar1 ; it gives three approaches (if i can count) .
I went for "Exempted Dynamic Property Patterns' i.e get rid of annoying notices straight away, then apply a more appropriate fix when i have time
I have never gotten that warning message, but then I have a habit of always defining all of my Properties.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |