Doeke Norg
5.1K posts

Doeke Norg
@doekenorg
PHP Architect, spouse to @Renatenorg and father of 3. Follow me for more on vanilla PHP and useful patterns.
Vries, The Netherlands Katılım Mart 2009
130 Takip Edilen840 Takipçiler

@doekenorg Sorry for spoiling the fun, but I laughed at it so hard 😆. Anyway, the answer is in the docs... sort of 🤷♂️.


English

@nicksdot @sandersjj That might be thought of as premature optimization, but I don't actually build that; I only allow for that, just in case. It doesn't require a new major or updates on the user's end.
English

@nicksdot @sandersjj It isn't always bad, but it is part of the public API for the code. When it comes to your own code, that's obviously fine, but when working with packages, you can't easily rename that variable or change the logic for that path to be overwritten with an event or a different base.
English


@doekenorg @nicksdot Cool! At what time should I watch out for it?
English
Doeke Norg retweetledi

So many time-related puns. Try and find them all. ⏰
Oh, and learn about the `ClockInterface` as well.
#php #testing #clock
doeken.org/blog/psr-20-cl…
English

@nicolaibaaring @nicksdot Yep, and it will feature the music of Coldplay.
youtube.com/watch?v=d020hc…

YouTube
English

@nicksdot @sandersjj Also, no more encapsulation. When readonly was intoduced, everyone just started exposing internals, making changes more difficult. Whats wrong with adding a semantic method?! 😐
English

@sandersjj No more automatic refactoring. Changing to stringy apis is never a good idea.
English

@doekenorg Will it be timed who finds all the puns faster? 🕦
English

@agustingomes When they are available to me; I might as well. But I also like to "hide" away the parameters so I can change implementation details without changing the API. This is why I like accessor methods instead. I guess that you can use property hooks, but I don't see an advantage there.
English

@doekenorg Nowadays with the property accessors I just tend to do a readonly class instead. There may be cases in which private constructor still better, though
English

@Hundinnenstein It's not great, but I'll admit to having abused this at least once or twice in my career, when I don't own the code. You gotta do what you gotta do to make shit work.
English

@doekenorg Wow! This is a whole new level of shitcoding I couldn't even imagine. I would like to see somebody who would call a constructor method like this.
English

@_israel_viana_ Absolutely, but not everyone has that luxury. For read-only, you need PHP 8.1 at a minimum. The reality for a lot of folks is that unfortunately clients aren't remotely there yet. And it is not a lack of trust, but an absolute trust on the input :-)
x.com/doekenorg/stat…
Doeke Norg@doekenorg
Here is one that *is* immutable. Alternatively, you can also use `readonly` parameters (8.1) or classes (8.2).
English

@doekenorg IMO, immutability is great for keeping state consistent. But addding a static named constructor for every class just to prevent using __construct() on an existing object shows a bit of lack of trust in your fellow programmers 🤔 ?
(readonly params/classes are the best solution)
English

@doekenorg Using the readonly keyword you can protect against this. Might be a nice addition to your post :).
English






