Это видео недоступно.
Сожалеем об этом.

Deprecated Dynamic Properties in PHP 8.2

Поделиться
HTML-код
  • Опубликовано: 12 авг 2024
  • A close look at how to deal with deprecated dynamic properties in PHP 8.2

Комментарии • 26

  • @Skatox
    @Skatox Год назад +4

    I've used PHP for almost 15 years and didn't know this was possible. I only added dynamic properties for stdClass. So I guess I'm happy that something I don't use is deprecated.

  • @wildfireDZ
    @wildfireDZ Год назад +4

    Dynamic properties is one of the best thing about php compared to languages like Java. I see it as a stepback

    • @hmb8801
      @hmb8801 10 месяцев назад +1

      It's just warning, it still works.

    • @davespicer2143
      @davespicer2143 9 месяцев назад

      @@hmb8801 not anymore. It's an app breaker now in 8.2.12. Hell of a way to ensure webadmins don't use PHP 8.2 + on their servers.

  • @andrewv.157
    @andrewv.157 Год назад +2

    I would not say that I used them a lot, but it was extremely useful to have them when needed. It made the object very agile.
    I like to work with object as a result from the dB. And aggregating associated data's together in one object with dynamic property added from the main object was a cool feature that never cause any trouble to my code or users.

    • @jnath
      @jnath Год назад

      This is what most ORM do and I really liked it. Good thing dynamic property is still allowed with stdClass

  • @lostcarpark
    @lostcarpark Год назад

    Makes perfect sense!

  • @webdarked
    @webdarked Год назад +1

    I've been waiting for this moment for so long!

  • @redguard128
    @redguard128 Год назад +2

    I never used this because I learnt computer science using Pascal, C, C++, Java, C#, etc. All those languages required you to think before doing something. I learnt PHP and JavaScript after getting my bachelor degree and I never programmed using dynamic properties. And I hated JavaScript for never knowing what properties an object actually has.

  • @dresnyd
    @dresnyd Год назад

    I mean, this is good because it allows you to make certain assumptions about the code. Even allowing the interpreter to store instances using those assumptions. Like using a fixed size storage for efficiency.

  • @johnnyj4425
    @johnnyj4425 9 месяцев назад

    I'm a beginner on php and I already have to deal with this issue

  • @barneylaurance1865
    @barneylaurance1865 Год назад +1

    I didn't realize stdClass implemented magic getters and setters, I assumed it was just either treated as a special case for dynamic properties or it was annotated with #[AllowDynamicProperties]. Is there any way to tell the difference?

    • @pashapepeh
      @pashapepeh Год назад

      I guess extending stdClass will work in the future version of PHP and AllowDynamicProperties will not

  • @paulfontaine7819
    @paulfontaine7819 Год назад

    When an application uses Dynamic Properties on a library object (which should not be modified), how would you avoid the deprecation message? Other than rewriting the application, which wasn't broke and fears fixing ;-)

  • @robsontenorio2
    @robsontenorio2 2 месяца назад

    Will #[AllowDynamicProperties] prevent my code to break in the future?
    Or it just suppress the warnings for now?

    • @phpannotated
      @phpannotated  2 месяца назад

      Just to skip the warnings. Although there's no clarity yet if the deprecated dynamic proparties will ever be truly removed

  • @hmb8801
    @hmb8801 11 месяцев назад

    I have PHP 8.2, how come I don't get any warning?

    • @phpannotated
      @phpannotated  10 месяцев назад

      Possibly because you don't have dynamic properties in your code, or because deprecation warnings are configured to silenced.

  • @davespicer2143
    @davespicer2143 9 месяцев назад

    I saw somebody on SO say that this would be the single biggest breaking change to PHP in its history over a year ago, and that it would take out a huge amount of applications. Now 8.2.12 is here it has fulfilled exactly that prophecy for anybody trying to use it with existing code. No longer a warning, now an app killer. Utterly stupid change to the codebase that is going to make many webadmins keep running < 8.2 environments on their servers as the work involved in rectifying the code could be huge on larger projects - which is terrible for security going forward. Stupid, stupid change.

  • @Nodsaibot
    @Nodsaibot Год назад

    done error_reporting(0)

    • @ecx007
      @ecx007 Год назад

      Change or die.

    • @Nodsaibot
      @Nodsaibot Год назад

      @@ecx007 if(change) die();

  • @golem427
    @golem427 Год назад

    Ain't it all a bit snobbish ?

  • @davefrench3608
    @davefrench3608 Год назад

    Great idea, being able to abuse your class by just randomly accessing data outside of the class design is just terrible.
    Would never pass code review in my company.

  •  Год назад +1

    Excuse me, but you definitely want deprecation warnings in production, and you absolutely should not be showing any of PHPs error messages to the user whatsoever, so the argument of hiding it from the user is invalid.
    Deprecation warnings are useful in production because they can catch things you may not have tests for. Log them, and preferably to something better than a text file (Sentry, bugsnag, whatever). And turn off display_errors.

  • @n3rvio
    @n3rvio 11 месяцев назад +2

    What is improved by this?
    I would cut off the hands of the person who proposed this barbarity.. // ironic mode
    Should all languages be same boring / strict? aghh..