News for hackers. Stuff that matters.
Re:PHP 8.4 by tail_exchange on Thursday November 21, 2024 @04:16PM (#42208755)
I'm also not a php developer, but I agree. This seems like a huge footgun.

I've never been a fan of this kind of magic, and I wonder how other languages deal with this case.

Re:PHP 8.4 by crimsonnoodle58 on Thursday November 21, 2024 @04:34PM (#42208906)
Well in python I assume it would be equivalent of accessing:

  self.__dict__['property_name']
And if those PHP rules were in python you could just write:

  @property
  def property_name(self):
      return self.property_name
In actual python though, that would infinitely recurse.
Re:PHP 8.4 by arkh on Friday November 22, 2024 @03:44AM (#42212165)
Or if they could follow Godot syntax: https://docs.godotengine.org/en/stable/tutorials/scripting/g...

var milliseconds: int = 0

var seconds: int:

get:

  return milliseconds / 1000

 set(value):

  milliseconds = value * 1000
Re:PHP 8.4 by kijin on Thursday November 21, 2024 @10:18PM (#42210827)
It might be a footgun, but it will be extremely obvious when it is triggered.
Re:PHP 8.4 by Liquidor on Friday November 22, 2024 @03:27AM (#42212099)
Lua has rawget() and rawset() to bypass the magic methods, which is used a lot inside/outside the metatables (objects with magic methods) to avoid magic loops I guess.