Internals are voting on the Asymmetric Visibility RFC

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Links:
    - Share your vote: rfc.stitcher.i...
    - The RFC: wiki.php.net/r...
    - Limited by committee: stitcher.io/bl...
    - My thoughts about the first version: stitcher.io/bl...
    - PHP Cloneable: github.com/spa...
    - The stream with Larry about property hooks: • Let's talk about prope...

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

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

    Were you about to comment something about final? 👀

  • @PabloLargo
    @PabloLargo Месяц назад +7

    Making a class the read-only way and having better cloning methods is the way to go, it promotes class immutability 😊

  • @CottonInDerTube
    @CottonInDerTube Месяц назад +7

    public, private, protected, final, readonly, ... all short and easy.
    But protected(set) is just breaking this "flow".
    IMO it should be a single word 100% indicating what it does, or it should be implemented.

  • @bwaidelich
    @bwaidelich Месяц назад +1

    There's a fundamental difference between setTitle() and (clone) withTitle() and that is mutability vs immutability. I was really surprised, that you didn't even mention that.
    I think the suggested syntax and especially the overlap with readonly is highly confusing..
    Personally I would also prefer "clone with" but I'm fine with the following work around:
    final readonly class SomeClass {
    public function __construct(
    public string $prop1,
    public bool $prop2,
    ) {}
    public function with(
    string $prop1 = null,
    bool $prop2 = null,
    ): self
    {
    return new self(
    $prop1 ?? $this->prop1,
    $prop2 ?? $this->prop2,
    );
    }
    }
    (to be used with named parameters)

  • @ramonennik2536
    @ramonennik2536 Месяц назад +6

    I just don't like the syntax and prefer the c# one since it may allows for expension of functionality while keeping it a little bit more readable.

    • @mohamedkaddouri9720
      @mohamedkaddouri9720 Месяц назад +1

      I total agree with you. I hope we can adapt the c# syntax for this.

    • @ClaudiuMarginean
      @ClaudiuMarginean Месяц назад

      How is the C# syntax for this?

    • @HeavenNextHD
      @HeavenNextHD Месяц назад

      @@ClaudiuMarginean public string Name { get; private set; }
      With the above, the Name property has a public getter and a private setter.

    • @ClaudiuMarginean
      @ClaudiuMarginean Месяц назад

      @@HeavenNextHD yes, it looks like a C# wit public(set), but if is in PHP style I think is more clear with public-write.

  • @user-vBqDm4l7wE
    @user-vBqDm4l7wE 4 дня назад +1

    Why not to utilize C# approach and existing property hooks ?
    For instance public string Name { get; private set; }

  • @Trapster1000
    @Trapster1000 Месяц назад

    property hooks and this is something I have been waiting for php for a good while, hopefully this is implemented aswell

  • @ddruganov
    @ddruganov Месяц назад +2

    i like how php becomes more and more like c#

    • @85bitsdeveloper
      @85bitsdeveloper Месяц назад

      Its more swift in this case

    • @ddruganov
      @ddruganov Месяц назад +2

      @@85bitsdeveloper yeah true but im just really opposed to switfs syntax in this case; i like csharps a lot better

  • @SaiyanJin85
    @SaiyanJin85 Месяц назад

    I think they should allow readonly props to be changed within the class itself by default, in my mind the use case of readonly is there in order to prevent changes from outside the class anyway. now they have to reinvent the wheel but it's a tricky problem to begin with, I hope they won't perplex the syntax at least

  • @enterusername7746
    @enterusername7746 Месяц назад +6

    Do we need this? I don‘t think so.

  • @mohamedkaddouri9720
    @mohamedkaddouri9720 Месяц назад

    This is something that also exists in c# this is in my opinion a very powerful feature to have in php. I hope this get's implemented and this is nothing like read only properties which is also available in c# haha

  • @dinitharansidu1772
    @dinitharansidu1772 Месяц назад +2

    When is PHP getting the native async feature?

    • @Perer876
      @Perer876 Месяц назад +1

      Never, it already has coroutines

  • @geoffreyvanwyk4588
    @geoffreyvanwyk4588 Месяц назад

    The RFC system is drive-by-shooting language design.

  • @pratikbhujel
    @pratikbhujel Месяц назад +2

    I didn't understand anything but I liked it, it's because I never used read-only thingy.

  • @SaiyanJin85
    @SaiyanJin85 Месяц назад

    Actually we would need both "private set" and "clone with". the one doesn't exclude the other tbh

  • @markuszeller_official
    @markuszeller_official Месяц назад

    I don't like the extra "(set)" when reading from left to right.

  • @geoffreyvanwyk4588
    @geoffreyvanwyk4588 Месяц назад

    Let us rather remove the writeonce behavior from readonly and add a separate writeonce keyword.
    The private(set) syntax is also ugly.

  • @geoffreyvanwyk4588
    @geoffreyvanwyk4588 Месяц назад

    Does PHP stand for PHP Hypertext Preprocessor or PHP Hotch Potch?

  • @CottonInDerTube
    @CottonInDerTube Месяц назад +1

    13:06 final is final until you realize you must remove it. :p

  • @no-bias-
    @no-bias- Месяц назад

    the effort should be more focus on async rather than this kind of limited base use cases.

    • @no-bias-
      @no-bias- Месяц назад

      this is just a hacking way to make immutable to mutable, the RFC did not mention this as well, what a shame.

  • @PiotrJarolewski
    @PiotrJarolewski Месяц назад +9

    Please don't..... Now I know why people hate PHP.... Please copy syntax from C# or another new languages....

    • @razvbir
      @razvbir Месяц назад

      I mean... PHP started out with a syntax very similar with C then Objects were added by popular demand (with a java like syntax). Now we are kind of borrowing things from C#

  • @hugogoncalves77
    @hugogoncalves77 Месяц назад

    Like the concept, hate the syntax.

  • @CottonInDerTube
    @CottonInDerTube Месяц назад

    Around 6:45 But isnt this book example a problem by design in the first place?
    When the property on the object must be changes "sometimes" ... then its not read only, right?

    • @phpannotated
      @phpannotated  Месяц назад

      True… to be totally correct you should say "this property is only allowed to change in specific contexts". Readonly doesn't allow that. So in a way you're making an argument for the RFC :)

  • @NewFoxesHD
    @NewFoxesHD Месяц назад

    Please dont
    private function set
    public function get
    And no readonly
    Ore am i dumb?

  • @nipph
    @nipph Месяц назад

    This syntax is not clear, it's counterintuitive, I don't like it. This, when used, is gonna make code less readable, it should be the other way. I feel like this is just progress for the sake of progress

  • @ajzack983
    @ajzack983 26 дней назад

    the syntax is shit, I would like something like:
    private writable $var;
    private readable $var;