The way I see it, it might look similar to strict_types opt-in, but
only on the surface. The amount of changes needed to make legacy code
compliant with strict_types directive, would be tremendous, also there
would be no simple one-size-fits-all solution like the
#[AllowDynamicProperties]. In that sense, these two are hardly
comparable.
I agree with the change (not that I have a voting karma, just
watching). I also agree with Andreas Heigl saying that at certain point
changes like this probably should happen, and regardless of exactly
when, it is going to cause debate and complaints, but we as community
should probably prefer having a long deprecation cycle for smoother
transition, which is why the suggested timeline is IMO good (that is,
if the community represented by core devs will vote for this RFC).
Opt-in strategy - #[DenyDynamicProperties] - for a change like this
would effectively do nothing. I personally would be against this change
at all then.
Many thanks to the PHP team from userland, also for letting anyone
voice their thoughts and concerns on important matters!
Regards,
Victor Bolshov,
Software developer
On za, nov 13, 2021 at 08:26, Peter Bowyer <phpmailingli...@gmail.com>
wrote:
On Sat, 13 Nov 2021, 00:14 Christoph M. Becker, <cmbecke...@gmx.de
<mailto:cmbecke...@gmx.de>> wrote:
Offering an
opt-out of dynamic properties or some switch to disable the
deprecation
would not help in that regard.
Given this is a big change to the way PHP has behaved for decades I
did
wonder why the RFC didn't propose an opt-out of dynamic properties
rather
than opt-in, preserving the long-term language behaviour. So thanks
for
covering that.
I think you and the PHP internals community will be surprised by how
widely
used dynamic properties are. I read through a handful of WordPress
plugins
we have installed and found a few. And in my own where I'm using a
named
class instead of an array.
I work with modern framework based code most of the time and I find
it easy
to forget what is out there as quintessential or traditional PHP code.
Whether we have #[AllowDynamicProperties] or #[DenyDynamicProperties]
one
set of PHP users is going to be doing a find & replace across their
codebase.
From a DX perspective I'd rather have #[DenyDynamicProperties] as
it's like
declaring strict_mode and opt-in.
Either way are the planned engine changes feasible, as the feature of
dynamic properties stays in the language but toggled off/on per class?
Peter